bluetooth_low_energy 5.0.7 copy "bluetooth_low_energy: ^5.0.7" to clipboard
bluetooth_low_energy: ^5.0.7 copied to clipboard

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

bluetooth_low_energy #

A Flutter plugin for controlling the bluetooth low energy.

Features #

CentralManager #

  • Get/Listen the state of the central manager.
  • Listen connection state cahgned.
  • Listen GATT characteristic notified.
  • Start/Stop discovery.
  • Connect/Disconnect peripherals.
  • Read RSSI of peripherals.
  • Discover GATT.
  • Read/Write GATT characteristics.
  • Set GATT characteristics notify state.
  • Read/Write GATT descriptors.

PeripheralManager #

  • Get/Listen the state of the peripheral manager.
  • Listen GATT characteristic read/written/notifyStateChanged.
  • Add/Remove/Clear service(s).
  • Start/Stop advertising.
  • Read/Write(Notify) GATT characteristics.

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.

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

Linux #

PeripheralManager is not implemented because the bluez plugin doesn't support this yet, see How to use bluez to act as bluetooth peripheral.

Windows #

PeripheralManager is not implemented, it will be implemented in the future.

Note: The CentralManager#readRSSI method is not implemented on windows(windows doesn't support read RSSI after connected), avoid call this when running on windows devices.