The Android-nRF-Mesh-Library allows provisioning and sending messages to Bluetooth Mesh devices.
Bluetooth Mesh specification may be found here: https://www.bluetooth.com/specifications/mesh-specifications/
The library is compatible with version 1.0.1 of the Bluetooth Mesh Profile Specification.
nRF Mesh for Android is supported on Android devices running Android 4.3 and onwards.
ExampleFirmwares
that includes a light server (Light source) and a light client (Switch) firmwares. those firmwares will work on a nrf52832
DevKit.The library may be found on jcenter and Maven Central repository. Add it to your project by adding the following dependency:
implementation 'no.nordicsemi.android:mesh:2.3.0'
Clone this project and add ble module as a dependency to your project:
include ':mesh'
project(':mesh').projectDir = file('../Android-Mesh-Library/mesh')
implementation project(':mesh')
inside dependencies.See example projects in this repository.
To start using the library in your own project take a look at the followign snippet.
MeshManagerApi mMeshManagerApi = new MeshManagerApi(context);
mMeshManagerApi.setMeshManagerCallbacks(this);
mMeshManagerApi.setProvisioningStatusCallbacks(this);
mMeshManagerApi.setMeshStatusCallbacks(this);
mMeshManagerApi.loadMeshNetwork();
The sample application uses the Android BLE Library by Nordic Semiconductor ASA and is recommended to use this dependency in your application. Follow the snippet below when using the Android-Ble-Library in combination with the Android-Mesh-Library to send and receive data.
@Override
public void onDataReceived(final BluetoothDevice bluetoothDevice, final int mtu, final byte[] pdu) {
mMeshManagerApi.handleNotifications(mtu, pdu);
}
@Override
public void onDataSent(final BluetoothDevice device, final int mtu, final byte[] pdu) {
mMeshManagerApi.handleWriteCallbacks(mtu, pdu);
}
When using your own ble library/module call the mMeshManagerApi.handleNotifications(mtu, pdu);
and mMeshManagerApi.handleWriteCallbacks(mtu, pdu);
to send and receive data.
Provisioning a node in to the network can be done in three steps,
void identifyNode(@NonNull final UUID deviceUUID) throws IllegalArgumentException;
by passing the device uuid of the unprovisioned mesh node. or call
void identifyNode(@NonNull final UUID deviceUUID, final int attentionTimer) throws IllegalArgumentException;
by passing the device uuid of the unprovisioned mesh node and the desired duration. 3. Depending on the identified device capabilities, call one of the following functions to provision the node.
void startProvisioning(@NonNull final UnprovisionedMeshNode unprovisionedMeshNode) throws IllegalArgumentException;
or
void startProvisioningWithStaticOOB(@NonNull final UnprovisionedMeshNode unprovisionedMeshNode) throws IllegalArgumentException;
or
void startProvisioningWithOutputOOB(@NonNull final UnprovisionedMeshNode unprovisionedMeshNode, final OutputOOBAction oobAction) throws IllegalArgumentException;
or
void startProvisioningWithInputOOB(@NonNull final UnprovisionedMeshNode unprovisionedMeshNode, @NonNull final InputOOBAction oobAction) throws IllegalArgumentException;
Use the MeshNetowrk
object to edit Mesh Network properties such as Network name, Provisioners and their properties (Name Address, TTL and Address Ranges), Network Keys, App Keys.
Following is an example on how to send a GenericOnOffSet message.
final GenericOnOffSet genericOnOffSet = new GenericOnOffSet(appKey, state,
new Random().nextInt(), transitionSteps, transitionStepResolution, delay);
mMeshManagerAPi.createMeshPdu(address, genericOnOffSet);
and Config messages can also be sent similarly.
Mobile Applications Team, Nordic Semiconductor ASA.
Contact: roshanrajaratnam roshan.rajaratnam@nordicsemi.no
The Android-nRF-Mesh-Library is available under BSD 3-Clause license. See the LICENSE file for more info.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。