Skip to content

BLEDevice

A connected device that talks to the phone over Bluetooth Low Energy (BLE).

Holds the scan settings used to find the device. Its registration is a BLEDeviceRegistration. Extend it for a specific BLE device, like BLEHeartRateDevice.

Inheritance
Implementers
Annotations

Constructors

BLEDevice.fromJson

BLEDevice<TRegistration extends BLEDeviceRegistration>.fromJson(
  1. Map<String, dynamic> json
)

BLEDevice

BLEDevice<TRegistration extends BLEDeviceRegistration>({
  1. required String roleName,
  2. bool? isOptional = true,
  3. List<String>? serviceUuids,
  4. String? namePrefix,
  5. int? minRssi,
  6. bool allowDuplicates = true,
  7. Duration? timeout,
})

Properties

allowDuplicates

  1. @JsonKey(defaultValue: true)
bool allowDuplicates
getter/setter pair

Whether to receive repeated scan results for the same device. Useful for RSSI updates. Default is true.

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

minRssi

int? minRssi
getter/setter pair

Minimum RSSI (dBm) to accept, for example: -80.

namePrefix

String? namePrefix
getter/setter pair

Optional device name filter (substring match, case-insensitive). Applied AFTER discovery, not at the BLE controller level.

serviceUuids

  1. @JsonKey(defaultValue: [])
List<String> serviceUuids
getter/setter pair

Advertised service UUIDs to filter for. Empty means no filter.

UUIDs as strings, for example: "0000180D-0000-1000-8000-00805f9b34fb".

timeout

Duration? timeout
getter/setter pair

Scan timeout. If null, the scan has no timeout.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.