Bluetooth Mesh on Apache Mynewt

Bluetooth Mesh implementation is the latest addition to Apache Mynewt Nimble stack. This tutorial will should you how to use it. If you want to learn more about Bluetooth Mesh visit this site.

This tutorial will provide you with a simple yet fully functional mesh structure.

For this demo, we will use Bluetooth Mesh by Silicon Labs application for Android, which will act as a provisioner.  You can download it for Android using Google Play. Furthermore, we need to use the blemesh application running on multiple nRF52840 PDK devices acting as nodes.

Bluetooth Mesh provides two bearers in form of GATT and advertising. Unfortunately, Silicon Labs application only supports PB-GATT (GATT Provisioning Bearer), so we have to enable PB-GATT for all nodes – this can be done by setting BLE_MESH_PB_GATT configuration option. One of our targets should also contain GATT Proxy Service so it can relay messages between application and other nodes which do not use GATT bearer. This is done by setting BLE_MESH_GATT_PROXY flag.

Building targets

Let’s start by creating target for a proxy device:

$ newt target create blemesh
$ newt target set blemesh app=@apache-mynewt-core/apps/blemesh
$ newt target set blemesh bsp=@apache-mynewt-core/hw/bsp/nordic_pca10056
$ newt target set blemesh build_profile=optimized
$ newt target set blemesh syscfg=BLE_MESH_PB_GATT=1: \
> BLE_MESH_DEV_UUID='(uint8_t[16]){0x22, 0x20, 0}'

Note that we do not set device public address since Bluetooth Mesh implementation uses non-resolvable private address (NRPA) as they are not really important in mesh. What is important though is a device UUID as set above.

We also need target for bootloader:

$ newt target create nrf52840_boot
$ newt target set nrf52840_boot app=@apache-mynewt-core/apps/boot
$ newt target set nrf52840_boot bsp=@apache-mynewt-core/hw/bsp/nordic_pca10056
$ newt target set nrf52840_boot build_profile=optimized

Now you can build and flash bootloader and application onto device:

$ newt build nrf52840_boot
$ newt load nrf52840_boot
$ newt build blemesh
$ newt create-image blemesh 0
$ newt load blemesh

Afterwards, our devices is all set and ready for action. But one device is not enough to form an interesting mesh network, therefore we will prepare more.  This process is pretty similar to the previous one, so you can just amend your previous target or create another one. The only significant difference is that each other device should get different device UUID. Also they should only have GATT Provisioning Service enabled (i.e. no GATT Proxy Service):

$ newt target set blemesh syscfg=BLE_MESH_PB_GATT=1: \
> BLE_MESH_DEV_UUID='(uint8_t[16]){0x22, 0x21, 0}'

Now you can flash bootloader and application onto other device(s).

Configuring Bluetooth Mesh Silicon Labs application

As soon as your devices are ready, it is time to create your own mesh network using the Android app. We’ve recorded a video that should help you with the whole process:

Note that you also need some serial terminal program to monitor the output of every device, as they will show the authorization code that is required to provision your device.

Then, if you follow the rest of the instructions from the video, everything should work just fine.

Happy meshing!

Szymon Czapracki

Any questions?

Do not hesitate to contact us.

    Codecoup sp. z o.o.
    ul. Strzegomska 138
    54-429 Wrocław
    Poland
    +48 660 540 140
    hello@codecoup.pl
    Copyright © 2021 
    crossmenu