# Ports

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

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

## BluetoothCancellation [#bluetoothcancellation]

```dart
class BluetoothCancellation
```

Cancels a pending peripheral connection or device driver.

### Constructors [#constructors]

#### BluetoothCancellation.new [#bluetoothcancellationnew]

```dart
BluetoothCancellation()
```

### Properties [#properties]

#### BluetoothCancellation.isCancelled [#bluetoothcancellationiscancelled]

```dart
bool get isCancelled
```

Whether cancellation has been requested.

#### BluetoothCancellation.whenCancelled [#bluetoothcancellationwhencancelled]

```dart
Future<void> get whenCancelled
```

Completes when cancellation is requested.

### Methods [#methods]

#### BluetoothCancellation.cancel [#bluetoothcancellationcancel]

```dart
void cancel()
```

Requests cancellation once.

Returns `void`.


## BluetoothLink [#bluetoothlink]

```dart
abstract interface class BluetoothLink
```

An open GATT connection that can read and write characteristics.

### Methods [#methods-1]

#### BluetoothLink.subscribe [#bluetoothlinksubscribe]

```dart
Stream<List<int>> subscribe(String service, String characteristic)
```

Listens to notifications or indications for one characteristic.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `service` | `String` | positional |  |
| `characteristic` | `String` | positional |  |

Returns `Stream<List<int>>`.

#### BluetoothLink.write [#bluetoothlinkwrite]

```dart
Future<void> write(
  String service,
  String characteristic,
  List<int> bytes,
)
```

Writes bytes to a characteristic with response.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `service` | `String` | positional |  |
| `characteristic` | `String` | positional |  |
| `bytes` | `List<int>` | positional |  |

Returns `Future<void>`.

#### BluetoothLink.close [#bluetoothlinkclose]

```dart
Future<void> close()
```

Cancels subscriptions and disconnects.

Returns `Future<void>`.


## BluetoothPeripheral [#bluetoothperipheral]

```dart
abstract interface class BluetoothPeripheral
```

A Bluetooth peripheral discovered by a [`BluetoothScanner`](#bluetoothscanner).

### Properties [#properties-1]

#### BluetoothPeripheral.id [#bluetoothperipheralid]

```dart
String get id
```

The platform identifier for this peripheral.

#### BluetoothPeripheral.advertisement [#bluetoothperipheraladvertisement]

```dart
BluetoothAdvertisement get advertisement
```

What this peripheral advertises.

### Methods [#methods-2]

#### BluetoothPeripheral.openLink [#bluetoothperipheralopenlink]

```dart
Future<BluetoothLink> openLink(BluetoothCancellation cancellation)
```

Connects and discovers services, stopping if `cancellation` is requested.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `cancellation` | `BluetoothCancellation` | positional |  |

Returns `Future<BluetoothLink>`.


## BluetoothPermissions [#bluetoothpermissions]

```dart
abstract interface class BluetoothPermissions
```

Bluetooth permission checks and system prompts.

### Methods [#methods-3]

#### BluetoothPermissions.check [#bluetoothpermissionscheck]

```dart
Future<BluetoothPermission> check()
```

Reads the current permission without prompting.

Returns `Future<BluetoothPermission>`.

#### BluetoothPermissions.request [#bluetoothpermissionsrequest]

```dart
Future<BluetoothPermission> request()
```

Prompts for Bluetooth permission when the operating system permits it.

Returns `Future<BluetoothPermission>`.

#### BluetoothPermissions.openSettings [#bluetoothpermissionsopensettings]

```dart
Future<void> openSettings()
```

Opens the app's system settings.

Returns `Future<void>`.


## BluetoothReadingSink [#bluetoothreadingsink]

```dart
abstract interface class BluetoothReadingSink
```

Stores measurements reported by Bluetooth devices.

### Methods [#methods-4]

#### BluetoothReadingSink.save [#bluetoothreadingsinksave]

```dart
Future<BluetoothSaveResult> save(BluetoothDeviceReading reading)
```

Saves a reading or queues it for an offline retry.

| Parameter | Type | Kind | Default |
| ------ | ------ | ------ | ------ |
| `reading` | `BluetoothDeviceReading` | positional |  |

Returns `Future<BluetoothSaveResult>`.

#### BluetoothReadingSink.flushQueued [#bluetoothreadingsinkflushqueued]

```dart
Future<List<String>> flushQueued()
```

Retries queued readings and returns the IDs that were saved.

Returns `Future<List<String>>`.


## BluetoothSaveResult [#bluetoothsaveresult]

```dart
class BluetoothSaveResult
```

A completed measurement save.

### Constructors [#constructors-1]

#### BluetoothSaveResult.saved [#bluetoothsaveresultsaved]

```dart
BluetoothSaveResult.saved()
```

Creates a saved result.

#### BluetoothSaveResult.queued [#bluetoothsaveresultqueued]

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

Creates an offline queued result.

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

### Properties [#properties-2]

#### BluetoothSaveResult.status [#bluetoothsaveresultstatus]

```dart
final BluetoothSaveStatus status
```

The save outcome.

#### BluetoothSaveResult.queueId [#bluetoothsaveresultqueueid]

```dart
final String? queueId
```

The offline queue ID when queued.


## BluetoothScanner [#bluetoothscanner]

```dart
abstract interface class BluetoothScanner
```

The platform adapter's state and scan stream.

### Properties [#properties-3]

#### BluetoothScanner.state [#bluetoothscannerstate]

```dart
BluetoothAdapterState get state
```

The adapter's current state.

#### BluetoothScanner.stateChanges [#bluetoothscannerstatechanges]

```dart
Stream<BluetoothAdapterState> get stateChanges
```

Adapter state changes, including the first state when the stream is listened to.

### Methods [#methods-5]

#### BluetoothScanner.scan [#bluetoothscannerscan]

```dart
Stream<BluetoothPeripheral> scan()
```

Scans until the listener cancels or an error occurs.

Returns `Stream<BluetoothPeripheral>`.
