Examples
Runnable SimpleDartBLE examples for Dart that list adapters, scan, connect, read, write, receive notifications, host a GATT service and use a Dongl.
The examples live alongside the other SimpleBLE binding examples:
- list_adapters: Check whether Bluetooth is enabled and print each adapter.
- list_backends: Enumerate backends and list the adapters provided by each one.
- power_cycle: Turn each adapter off and on again.
- scan: Scan for five seconds, printing peripherals as they are found, then whether each is connectable, its manufacturer data, and its service data.
- connect: Connect to a peripheral and list its services and characteristics with their capabilities.
- read: Connect to a peripheral and print a GATT characteristic in hex.
- write: Connect to a peripheral and write text to a GATT characteristic.
- notify: Connect to a peripheral and print the notifications of a characteristic for five seconds.
- peripheral: Host a GATT service that echoes writes to subscribed clients and prints client and subscription events.
- dongl: Scan with a Dongl adapter, then connect and answer pairing requests.
The examples are a Dart package that uses SimpleDartBLE from the checkout,
which builds SimpleBLE with CMake the first time. Run one from
examples/simpledartble:
cd examples/simpledartble
dart run bin/scan.dartThe examples ask for their choices on the console, and peripheral runs until
you press Ctrl+C.
For a Flutter app, see the SimpleFltBLE Examples.
For binding development, see the development guide. For events, lifetime, and handlers, see Usage.
Usage
Install SimpleDartBLE from pub.dev and use SimpleBLE from Dart programs on Windows, macOS and Linux to scan, connect, use GATT and host a local peripheral.
Usage
Install SimpleFltBLE from pub.dev and use SimpleBLE in Flutter apps on Android, iOS, macOS, Windows and Linux, with the app setup each platform needs.
