Bluetooth Low Energy Flutter Package

license

This package provides the following features:

  • Central
    • Discover peripherals and their services and charactersitics
      • Read values from characteristics
      • Connect to peripherals
      • Establish L2CAP COC connections over discovered/known PSMs.
      • Multiplex L2CAP COCs into sockets.
  • Peripheral
    • Advertise read-only, string based services and charactersitics
      • Publish L2CAP COC connections.
      • Multiplex L2CAP COCs into sockets.

Getting started

Make sure your project meets the minimum requirements:

  • Minimum iOS target: 13.0
  • Minimum Android SDK: 29
  • Kotlin version: 1.7.10

Installation

flutter pub add blev

Upgrading

flutter pub upgrade blev

iOS Permissions

Update Info.plist

If you are building for Apple platforms, you may have to update your app's Info.plist. NSBluetoothAlwaysUsageDescription is needed to utilize bluetooth.

<key>NSBluetoothAlwaysUsageDescription</key>
<string></string>

Android Permissions

See https://developer.android.com/develop/connectivity/bluetooth/bt-permissions for how to correctly declare and request permissions for Android devices you intend on supporting.

Usage and example apps

View example apps in the /example directory to learn how to best use this package. There are two combined examples:

GitHub

You can view the code for Flutter BLE on GitHub.

Original Credit

This project took learnings from https://github.com/appsfactorygmbh/flutter-l2cap and as such references its MIT LICENSE at the bottom of our Apache 2.0 LICENSE.

License

Copyright 2021-2024 Viam Inc.

Apache 2.0 - See LICENSE file

Libraries

ble
Shared types to be used by ble_central, ble_peripheral, and ble_socket.
ble_central
The entrypoint for any BLE Central operations.
ble_peripheral
The entrypoint for any BLE Peripheral operations.

Sockets

Sockets Abstraction

ble_socket Sockets
Socket wrapper utilities around L2CAP COCs with connection multiplexing batteries included.