bluetooth_low_energy

A Flutter plugin for controlling the bluetooth low energy, supports central and peripheral roles.

CentralManager

API Android iOS macOS Windows Linux
logLevel
state
stateChanged
authorize
showAppSettings
discovered
connectionStateChanged
mtuChanged
characteristicNotified
startDiscovery
stopDiscovery
retrieveConnectedPeripherals
connect
disconnect
requestMTU
getMaximumWriteLength
readRSSI
readCharacteristic
writeCharacteristic
setCharacteristicNotifyState
readDescriptor
writeDescriptor

PeripheralManager

API Android iOS macOS Windows Linux
logLevel
state
stateChanged
authorize
showAppSettings
connectionStateChanged
mtuChanged
characteristicReadRequested
characteristicWriteRequested
characteristicNotifyStateChanged
descriptorReadRequested
descriptorWriteRequested
addService
removeService
removeAllServices
startAdvertising
stopAdvertising
getMaximumNotifyLength
respondReadRequestWithValue
respondReadRequestWithError
respondWriteRequest
respondWriteRequestWithError
notifyCharacteristic

Getting Started

Add bluetooth_low_energy as a dependency in your pubspec.yaml file.

dependencies:
  bluetooth_low_energy: ^<latest-version>

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 minSdk with 21 or higher in your android/app/build.gradle file.

iOS and macOS

According to the Apple's documents, you must include the NSBluetoothAlwaysUsageDescription on or after iOS 13, and include the NSBluetoothPeripheralUsageDescription key before iOS 13.

When use bluetooth or other hardwares on macOS, developers need to configure the app sandbox.

Note: The PeripheralManager#startAdvertising only support name and serviceUUIDs, see the Apple's document.

Winodows

Note: The PeripheralManager#startAdvertising not support name, see the Microsoft's document.

Linux

The PeripheralManager API is not implemented since the bluez didn't support this feature yet.

Migrations

Libraries

bluetooth_low_energy
A Flutter plugin for controlling the bluetooth low energy, supports central and peripheral apis.