BlePeripheral class

BlePeripheral is the main class to interact with the BLE peripheral plugin.

Constructors

BlePeripheral()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

addService(BleService service, {Duration? timeout}) → Future<void>
Add a service to the peripheral, and get success result in setServiceAddedCallback Make sure to add next service only after getting success result for previous service add all services before calling startAdvertising
askBlePermission() → Future<bool>
To ask for ble permission
clearServices() → Future<void>
Clear all services from the peripheral
getServices() → Future<List<String>>
Get list of services added to the peripheral
initialize() → Future
Make sure to call this method before calling any other method
isAdvertising() → Future<bool?>
check if blePeripheral is advertising
isSupported() → Future<bool>
check if blePeripheral is supported on the device
removeService(String serviceId) → Future<void>
Remove a service from the peripheral
setAdvertisingStatusUpdateCallback(AdvertisementStatusUpdateCallback callback) → void
Get the callback when advertising is started or stopped
setBleStateChangeCallback(BleStateCallback callback) → void
Get the callback when bluetooth radio state changes
setBondStateChangeCallback(BondStateCallback callback) → void
Get the callback when bond state changes
setCharacteristicSubscriptionChangeCallback(CharacteristicSubscriptionChangeCallback callback) → void
Only available on iOS/Mac/Windows
setConnectionStateChangeCallback(ConnectionStateChangeCallback callback) → void
Only available on Android
setInstance(BlePeripheralInterface instance) → void
Set custom platform specific implementation (e.g. for testing)
setMtuChangeCallback(MtuChangeCallback callback) → void
Only available on Android/Windows
setReadRequestCallback(ReadRequestCallback callback) → void
Get the callback when a read request is made
setServiceAddedCallback(ServiceAddedCallback callback) → void
Get the callback when a service is added
setWriteRequestCallback(WriteRequestCallback callback) → void
Get the callback when a write request is made
startAdvertising({required List<String> services, String? localName, int? timeout, ManufacturerData? manufacturerData, bool addManufacturerDataInScanResponse = false}) → Future<void>
Start advertising with the given services and local name make sure to add services before calling this method
stopAdvertising() → Future<void>
Stop advertising
updateCharacteristic({required String characteristicId, required Uint8List value, String? deviceId}) → Future<void>
To update the value of a characteristic