OZEO-DOOZ / nrf_mesh_plugin

A Flutter plugin to enable mesh network management and communication using Nordic Semiconductor's SDKs.
https://pub.dev/packages/nordic_nrf_mesh
BSD 3-Clause "New" or "Revised" License
27 stars 16 forks source link
android bluetooth bluetooth-low-energy bluetooth-mesh cross-platform flutter home-automation ios mesh-network

nordic_nrf_mesh

pub version pub points pub likes pub popularity

A Flutter plugin to enable mesh network management and communication using Nordic Semiconductor's SDKs.

Features

This plugin wraps both IOS-nRF-Mesh-Library and Android-nRF-Mesh-Library to provide a Dart-only API and has the following features :

_(Note: the Bluetooth scanning and connecting features are done with flutter_reactive_ble)_

How to use

Installation

Plugin development :

Install in Flutter App :

Install plugin
Update build scripts
Android
iOS

(If it's not the case and you'd want it implemented, feel free to open an Issue or a Pull Request)

(de)provisioning

For a node to be part of a network, it must be provisioned. This critical feature is available via the NordicNrfMesh instance. Here are the signatures :

Future<ProvisionedMeshNode> provisioning(
  final MeshManagerApi meshManagerApi,
  final BleMeshManager bleMeshManager,
  final DiscoveredDevice device,
  final String serviceDataUuid, {
  final ProvisioningEvent? events,
})
Future<ConfigNodeResetStatus> deprovision(
  final MeshManagerApi meshManagerApi,
  final ProvisionedMeshNode meshNode,
)

For example usage, please refer to example app.

Bluetooth features

_(Note: the Bluetooth scanning and connecting features are done with flutter_reactive_ble)_

Scan devices :

The different scanners are available via the NordicNrfMesh instance. The API is mesh oriented so you can easily get the mesh devices around the phone, but you can still have custom scanning via NordicNrfMesh.scanWithServices.

Connect to a device :

In order to implement connection features, one must use the BleManager and BleManagerCallbacks abstract classes.

For convenience, we ship this plugin with an implementation specific to mesh nodes. To be able to handle BLE connection with a mesh proxy node, one shall create and initialize a BleMeshManager instance.

final bleMeshManager = BleMeshManager();
bleMeshManager.callbacks = MyBleCallbacks(meshManager); // must be set

(The MyBleCallbacks in the snippet above must extends BleMeshManagerCallbacks.)

After that, you will have to scan for devices, and then call the connect method like so :

DiscoveredDevice device;
// scan for device in range
[...]
// connect if found
bleMeshManager.connect(device);

Custom BLE features :

If your use case is not implemented, you should prioritize opening an Issue for a feature request. However you can still get access to other features of the flutter_reactive_ble plugin by getting its singleton instance using the following snippet :

final blePlugin = FlutterReactiveBle();

Again, this should not be done by you, feel free to ask us to implement a new method/feature ! :)

Example app

For more in depth use, please refer to example app which shows some of the most used features. In a tab based layout, it provides example usage on :

(Note: This plugin uses forks of Nordic Semiconductor's libraries. This has been done to be able to extend these libraries with some DooZ specific API, but doesn't change the source code)