# Models

Canonical page: https://docs.ovok.com/flutter-sdk/reference/ovok_flutter/models

{/* Generated by scripts/generate_reference.dart; do not edit. */}

## BluetoothAdapterState [#bluetoothadapterstate]

```dart
enum BluetoothAdapterState
```

The state of the device's Bluetooth adapter.

### Values [#values]

#### BluetoothAdapterState.unknown [#bluetoothadapterstateunknown]

```dart
static const BluetoothAdapterState unknown
```

The platform has not reported its adapter state yet.

#### BluetoothAdapterState.on [#bluetoothadapterstateon]

```dart
static const BluetoothAdapterState on
```

Bluetooth is ready for use.

#### BluetoothAdapterState.off [#bluetoothadapterstateoff]

```dart
static const BluetoothAdapterState off
```

Bluetooth is turned off.

#### BluetoothAdapterState.unauthorized [#bluetoothadapterstateunauthorized]

```dart
static const BluetoothAdapterState unauthorized
```

The app is not authorized to use Bluetooth.

#### BluetoothAdapterState.unsupported [#bluetoothadapterstateunsupported]

```dart
static const BluetoothAdapterState unsupported
```

This device does not support Bluetooth LE.


## BluetoothAdvertisement [#bluetoothadvertisement]

```dart
class BluetoothAdvertisement
```

What a peripheral advertised during scanning.

### Constructors [#constructors]

#### BluetoothAdvertisement.new [#bluetoothadvertisementnew]

```dart
BluetoothAdvertisement({
  required String name,
  required Iterable<String> serviceUuids,
  String? manufacturerData,
})
```

Creates an advertisement snapshot.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `name` | `String` | required named |  |
| `serviceUuids` | `Iterable<String>` | required named |  |
| `manufacturerData` | `String?` | named |  |

### Properties [#properties]

#### BluetoothAdvertisement.name [#bluetoothadvertisementname]

```dart
final String name
```

The advertised name, or an empty string when unavailable.

#### BluetoothAdvertisement.serviceUuids [#bluetoothadvertisementserviceuuids]

```dart
final List<String> serviceUuids
```

The advertised service UUIDs.

#### BluetoothAdvertisement.manufacturerData [#bluetoothadvertisementmanufacturerdata]

```dart
final String? manufacturerData
```

The base64 encoded manufacturer data, or null when absent.


## BluetoothConnectionState [#bluetoothconnectionstate]

```dart
enum BluetoothConnectionState
```

The state of a supported nearby device.

### Values [#values-1]

#### BluetoothConnectionState.idle [#bluetoothconnectionstateidle]

```dart
static const BluetoothConnectionState idle
```

The device has not started connecting.

#### BluetoothConnectionState.connecting [#bluetoothconnectionstateconnecting]

```dart
static const BluetoothConnectionState connecting
```

The runtime is opening the device connection.

#### BluetoothConnectionState.connected [#bluetoothconnectionstateconnected]

```dart
static const BluetoothConnectionState connected
```

The device connection is open.

#### BluetoothConnectionState.measuring [#bluetoothconnectionstatemeasuring]

```dart
static const BluetoothConnectionState measuring
```

The device is sending measurements.

#### BluetoothConnectionState.disconnected [#bluetoothconnectionstatedisconnected]

```dart
static const BluetoothConnectionState disconnected
```

The device connection is closed.

#### BluetoothConnectionState.failed [#bluetoothconnectionstatefailed]

```dart
static const BluetoothConnectionState failed
```

The device connection failed.


## BluetoothDeviceReading [#bluetoothdevicereading]

```dart
class BluetoothDeviceReading
```

A measurement reported by a supported Bluetooth device.

### Constructors [#constructors-1]

#### BluetoothDeviceReading.new [#bluetoothdevicereadingnew]

```dart
BluetoothDeviceReading({
  required String id,
  required BluetoothReadingDevice device,
  required JsonMap measurement,
  required DateTime receivedAt,
  required BluetoothSaveState save,
})
```

Creates a device reading snapshot.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `id` | `String` | required named |  |
| `device` | `BluetoothReadingDevice` | required named |  |
| `measurement` | `JsonMap` | required named |  |
| `receivedAt` | `DateTime` | required named |  |
| `save` | `BluetoothSaveState` | required named |  |

### Properties [#properties-1]

#### BluetoothDeviceReading.id [#bluetoothdevicereadingid]

```dart
final String id
```

A reading ID; timestamped readings use the same ID when resent.

#### BluetoothDeviceReading.device [#bluetoothdevicereadingdevice]

```dart
final BluetoothReadingDevice device
```

The device that produced the reading.

#### BluetoothDeviceReading.measurement [#bluetoothdevicereadingmeasurement]

```dart
final JsonMap measurement
```

The decoded Ovok measurement.

#### BluetoothDeviceReading.receivedAt [#bluetoothdevicereadingreceivedat]

```dart
final DateTime receivedAt
```

When this app received the reading.

#### BluetoothDeviceReading.save [#bluetoothdevicereadingsave]

```dart
final BluetoothSaveState save
```

Whether the measurement was saved.

### Methods [#methods]

#### BluetoothDeviceReading.copyWith [#bluetoothdevicereadingcopywith]

```dart
BluetoothDeviceReading copyWith({required BluetoothSaveState save})
```

Returns a copy with the supplied save state.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `save` | `BluetoothSaveState` | required named |  |

Returns `BluetoothDeviceReading`.


## BluetoothNearbyDevice [#bluetoothnearbydevice]

```dart
class BluetoothNearbyDevice
```

A supported peripheral discovered by a scan.

### Constructors [#constructors-2]

#### BluetoothNearbyDevice.new [#bluetoothnearbydevicenew]

```dart
BluetoothNearbyDevice({
  required String id,
  required String key,
  required String name,
  required BluetoothConnectionState connection,
  BluetoothError? error,
})
```

Creates a nearby device snapshot.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `id` | `String` | required named |  |
| `key` | `String` | required named |  |
| `name` | `String` | required named |  |
| `connection` | `BluetoothConnectionState` | required named |  |
| `error` | `BluetoothError?` | named |  |

### Properties [#properties-2]

#### BluetoothNearbyDevice.id [#bluetoothnearbydeviceid]

```dart
final String id
```

The platform identifier for the peripheral.

#### BluetoothNearbyDevice.key [#bluetoothnearbydevicekey]

```dart
final String key
```

The device key reported with its readings.

#### BluetoothNearbyDevice.name [#bluetoothnearbydevicename]

```dart
final String name
```

The name from its advertisement.

#### BluetoothNearbyDevice.connection [#bluetoothnearbydeviceconnection]

```dart
final BluetoothConnectionState connection
```

The current connection state.

#### BluetoothNearbyDevice.error [#bluetoothnearbydeviceerror]

```dart
final BluetoothError? error
```

The last connection error, when one occurred.

### Methods [#methods-1]

#### BluetoothNearbyDevice.copyWith [#bluetoothnearbydevicecopywith]

```dart
BluetoothNearbyDevice copyWith({
  String? name,
  BluetoothConnectionState? connection,
  BluetoothError? error,
  bool clearError = false,
})
```

Returns a copy with the supplied fields changed.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `name` | `String?` | named |  |
| `connection` | `BluetoothConnectionState?` | named |  |
| `error` | `BluetoothError?` | named |  |
| `clearError` | `bool` | named | `false` |

Returns `BluetoothNearbyDevice`.


## BluetoothPermission [#bluetoothpermission]

```dart
enum BluetoothPermission
```

The app's Bluetooth permission state.

### Values [#values-2]

#### BluetoothPermission.unknown [#bluetoothpermissionunknown]

```dart
static const BluetoothPermission unknown
```

The runtime has not checked permission yet.

#### BluetoothPermission.granted [#bluetoothpermissiongranted]

```dart
static const BluetoothPermission granted
```

Bluetooth access is permitted.

#### BluetoothPermission.denied [#bluetoothpermissiondenied]

```dart
static const BluetoothPermission denied
```

The user can still be asked for access.

#### BluetoothPermission.blocked [#bluetoothpermissionblocked]

```dart
static const BluetoothPermission blocked
```

Only system settings can grant access.


## BluetoothReadingDevice [#bluetoothreadingdevice]

```dart
class BluetoothReadingDevice
```

The identity of the device that produced a reading.

### Constructors [#constructors-3]

#### BluetoothReadingDevice.new [#bluetoothreadingdevicenew]

```dart
BluetoothReadingDevice({
  required String id,
  required String key,
  required String name,
})
```

Creates a device identity for a reading.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `id` | `String` | required named |  |
| `key` | `String` | required named |  |
| `name` | `String` | required named |  |

### Properties [#properties-3]

#### BluetoothReadingDevice.id [#bluetoothreadingdeviceid]

```dart
final String id
```

The platform identifier for the peripheral.

#### BluetoothReadingDevice.key [#bluetoothreadingdevicekey]

```dart
final String key
```

The device key reported with its readings.

#### BluetoothReadingDevice.name [#bluetoothreadingdevicename]

```dart
final String name
```

The name from its advertisement.


## BluetoothSaveState [#bluetoothsavestate]

```dart
class BluetoothSaveState
```

The outcome of saving a device reading.

### Constructors [#constructors-4]

#### BluetoothSaveState.saving [#bluetoothsavestatesaving]

```dart
BluetoothSaveState.saving()
```

Creates a reading that is waiting for a save result.

#### BluetoothSaveState.saved [#bluetoothsavestatesaved]

```dart
BluetoothSaveState.saved()
```

Creates a reading that was saved.

#### BluetoothSaveState.queued [#bluetoothsavestatequeued]

```dart
BluetoothSaveState.queued(String queueId)
```

Creates a reading queued for an offline retry.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `queueId` | `String` | positional |  |

#### BluetoothSaveState.failed [#bluetoothsavestatefailed]

```dart
BluetoothSaveState.failed(BluetoothError error)
```

Creates a reading whose save failed and can be retried.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `error` | `BluetoothError` | positional |  |

### Properties [#properties-4]

#### BluetoothSaveState.status [#bluetoothsavestatestatus]

```dart
final BluetoothSaveStatus status
```

The save state.

#### BluetoothSaveState.queueId [#bluetoothsavestatequeueid]

```dart
final String? queueId
```

The offline queue ID when [`status`](#bluetoothsavestatestatus) is queued.

#### BluetoothSaveState.error [#bluetoothsavestateerror]

```dart
final BluetoothError? error
```

The failure when [`status`](#bluetoothsavestatestatus) is failed.


## BluetoothSaveStatus [#bluetoothsavestatus]

```dart
enum BluetoothSaveStatus
```

Whether a device reading was saved or needs another attempt.

### Values [#values-3]

#### BluetoothSaveStatus.saving [#bluetoothsavestatussaving]

```dart
static const BluetoothSaveStatus saving
```

The sink has not answered yet.

#### BluetoothSaveStatus.saved [#bluetoothsavestatussaved]

```dart
static const BluetoothSaveStatus saved
```

The sink saved the reading.

#### BluetoothSaveStatus.queued [#bluetoothsavestatusqueued]

```dart
static const BluetoothSaveStatus queued
```

The sink queued the reading for a later retry.

#### BluetoothSaveStatus.failed [#bluetoothsavestatusfailed]

```dart
static const BluetoothSaveStatus failed
```

The sink could not save or queue the reading.


## BluetoothSnapshot [#bluetoothsnapshot]

```dart
class BluetoothSnapshot
```

A consistent view of the Bluetooth runtime's current state.

### Constructors [#constructors-5]

#### BluetoothSnapshot.new [#bluetoothsnapshotnew]

```dart
BluetoothSnapshot({
  required BluetoothAdapterState adapter,
  required BluetoothPermission permission,
  required bool scanning,
  required BluetoothError? scanError,
  required Iterable<BluetoothNearbyDevice> devices,
  required Iterable<String> paired,
  required Iterable<BluetoothDeviceReading> readings,
})
```

Creates an immutable runtime snapshot.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `adapter` | `BluetoothAdapterState` | required named |  |
| `permission` | `BluetoothPermission` | required named |  |
| `scanning` | `bool` | required named |  |
| `scanError` | `BluetoothError?` | required named |  |
| `devices` | `Iterable<BluetoothNearbyDevice>` | required named |  |
| `paired` | `Iterable<String>` | required named |  |
| `readings` | `Iterable<BluetoothDeviceReading>` | required named |  |

### Properties [#properties-5]

#### BluetoothSnapshot.adapter [#bluetoothsnapshotadapter]

```dart
final BluetoothAdapterState adapter
```

The current Bluetooth adapter state.

#### BluetoothSnapshot.permission [#bluetoothsnapshotpermission]

```dart
final BluetoothPermission permission
```

The last observed Bluetooth permission state.

#### BluetoothSnapshot.scanning [#bluetoothsnapshotscanning]

```dart
final bool scanning
```

Whether scanning has been requested.

#### BluetoothSnapshot.scanError [#bluetoothsnapshotscanerror]

```dart
final BluetoothError? scanError
```

The last scan error, when one occurred.

#### BluetoothSnapshot.devices [#bluetoothsnapshotdevices]

```dart
final List<BluetoothNearbyDevice> devices
```

Supported peripherals, in discovery order.

#### BluetoothSnapshot.paired [#bluetoothsnapshotpaired]

```dart
final List<String> paired
```

Paired device IDs.

#### BluetoothSnapshot.readings [#bluetoothsnapshotreadings]

```dart
final List<BluetoothDeviceReading> readings
```

Recent readings, oldest first.

### Methods [#methods-2]

#### BluetoothSnapshot.device [#bluetoothsnapshotdevice]

```dart
BluetoothNearbyDevice? device(String id)
```

Finds a nearby device by `id`.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `id` | `String` | positional |  |

Returns `BluetoothNearbyDevice?`.

#### BluetoothSnapshot.copyWith [#bluetoothsnapshotcopywith]

```dart
BluetoothSnapshot copyWith({
  BluetoothAdapterState? adapter,
  BluetoothPermission? permission,
  bool? scanning,
  BluetoothError? scanError,
  bool clearScanError = false,
  Iterable<BluetoothNearbyDevice>? devices,
  Iterable<String>? paired,
  Iterable<BluetoothDeviceReading>? readings,
})
```

Returns a new snapshot with selected fields replaced.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `adapter` | `BluetoothAdapterState?` | named |  |
| `permission` | `BluetoothPermission?` | named |  |
| `scanning` | `bool?` | named |  |
| `scanError` | `BluetoothError?` | named |  |
| `clearScanError` | `bool` | named | `false` |
| `devices` | `Iterable<BluetoothNearbyDevice>?` | named |  |
| `paired` | `Iterable<String>?` | named |  |
| `readings` | `Iterable<BluetoothDeviceReading>?` | named |  |

Returns `BluetoothSnapshot`.
