BLEDeviceManager
A device manager for a Bluetooth Low Energy (BLE) device.
E.g. a heart rate monitor. The app finds the device (e.g., by scanning) and calls pair with its BLE address before connecting. The BLE address and name are also taken from the registration, if any. Bluetooth permissions are checked and asked for; on Android this includes location.
- Inheritance
-
- Object
- DeviceManager<
TDeviceConfiguration, TRegistration> - HardwareDeviceManager<
TDeviceConfiguration, TRegistration> - BLEDeviceManager
Constructors
BLEDeviceManager
- String deviceType, {
- TDeviceConfiguration? configuration,
Properties
bleAddress
The BLE address of this device.
The format of the BLE address is platform-specific. On Android, it is typically a MAC address of the form 00:04:79:00:0F:4D. On iOS, it is typically be a UUID string on the form E2C56DB5-DFFB-48D2-B060-D0F5A71096E0.
Returns null if unknown. Typically, the BLE address is only known after pairing with a specific BLE device.
bleName
The BLE name of this device, if known.
displayName
Default display name for a BLE device is its BLE name or address.
manufacturerData
Manufacturer specific data. The first 2 bytes are the Company Identifier Codes.
serviceUuids
Advertised services of this device, if known.
Methods
onConfigure
Callback on configure.
When called, the configuration and the registration is available.
Is to be overridden in sub-classes. Note, however, that it must not be doing a lot of work on startup.
onHasPermissions
Callback on hasPermissions.
Can be overridden in sub-classes for device-specific permission handling.
onPaired
Called by pair after the BLE device information is set.
Returns true if pairing succeeded. By default, pairing always succeeds; override for device-specific pairing.
onRequestPermissions
Callback on requestPermissions.
Can be overridden for device-specific permission handling.
pair
Pairs this device manager with the BLE device at bleAddress.
Optionally sets its bleName, serviceUuids, and manufacturerData. Sets status to DeviceStatus.paired if onPaired returns true.