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.
Make sure your project meets the minimum requirements:
- Minimum iOS target: 13.0
- Minimum Android SDK: 29
- Kotlin version: 1.7.10
flutter pub add blev
flutter pub upgrade blev
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>
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.
View example apps in the /example
directory to learn how to best use this package. There are two combined examples:
- central and peripheral
- Demonstrates a central and peripheral sending messages to each over L2CAP channels.
- central_socks_client and peripheral_socks_server
- Demonstrates a central and peripheral acting as a client and server for doing HTTP over SOCKS5.
You can view the code for Flutter BLE on GitHub.
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.
Copyright 2021-2024 Viam Inc.
Apache 2.0 - See LICENSE file