bluetooth_low_energy
A Flutter plugin for controlling the bluetooth low energy.
Features
CentralManager
xSet up the central manager.xGet/Listen the state of the central manager.xStart/Stop discovery.xConnect/Disconnect peripherals.xGet maximum write length of peripherals.xRead RSSI of peripherals.xDiscover GATT.xGet GATT services.xGet GATT characteristics.xGet GATT descriptors.xRead/Write/Notify GATT characteristics.xRead/Write GATT descriptors.
PeripheralManager
xSet up the peripheral manager.xGet/Listen the state of the peripheral manager.xAdd/Remove/Clear service(s).xStart/Stop advertising.xGet maximum write length of centrals.xListen read/write/notify characteristic requests from centrals.xSend read/write characteristic replies to centrals.xNotify characteristic value changed to centrals.
Getting Started
Add bluetooth_low_energy as a dependency in your pubspec.yaml file.
dependencies:
bluetooth_low_energy: ^<latest-version>
Remember to call await CentralManager.setUp() and await PeripheralManager.setUp() before use any apis of this plugin.
Note: Bluetooth Low Energy doesn't work on emulators, so use physical devices which has bluetooth features for development.
Android
Make sure you have a miniSdkVersion with 21 or higher in your android/app/build.gradle file.
iOS and macOS
According to Apple's documents, you must include the NSBluetoothAlwaysUsageDescription on or after iOS 13, and include the NSBluetoothPeripheralUsageDescription key before iOS 13.
Note: The PeripheralManager#startAdvertising only support name and serviceUUIDs, see the startAdvertising document
Linux
Not tested enough, if you occured any problems, file an issue to let me know about it, i will fix it as soon as possible.
PeripheralManager api is not supported because the bluez plugin doesn't support this yet, see How to use bluez to act as bluetooth peripheral
Windows
Not implemented yet but maybe someday or someone can use the win32 api to implement this plugin_interface or someday the flutter team support C# on windows platform or someday I am familiar with C++ language...
Libraries
- bluetooth_low_energy
- A Flutter plugin for controlling the bluetooth low energy, supports central and peripheral apis.