nRF5 SDK for Mesh v3.2.0  08c60f6
Serial example
Note
This example is not supported by the nRF52810 Series.

This example implements the serial interface for the mesh stack. It can be used unaltered as connectivity firmware for mesh devices. You can also modify the example to provide additional functionality.

Table of contents

  • Serial interface initialization
  • Offloading feature
  • Setup
  • Testing the example

Serial interface initialization @anchor serial_example_initialization

The example shows how to initialize and use the serial interface. To initialize the serial interface, only two API calls are required:

The nrf_mesh_serial_init() API initializes the serial bearer interface, and the nrf_mesh_serial_enable() API sends the SERIAL_OPCODE_EVT_DEVICE_STARTED event over the serial interface to notify the external host that the device is ready to accept serial commands.

Offloading feature @anchor serial_example_offloading

This example demonstrates how to offload certain mesh-related tasks to the external host using a serial interface, which improves the performance of the mesh stack. The ECDH operations used in the provisioning process are a suitable candidate for such offloading.

The ECDH offloading allows the device to take advantage of the more powerful processor of the host to perform ECDH operations during provisioning.

The offloading is enabled by calling mesh_opt_prov_ecdh_offloading_set with enabled=true.

When this offloading is enabled, the serial interface sends the SERIAL_OPCODE_EVT_PROV_ECDH_REQUEST event to the host processor with the public and private keys. The host processor then performs the ECDH shared secret calculation and sends the calculated value back using the SERIAL_OPCODE_CMD_PROV_ECDH_SECRET serial command.


Setup @anchor serial_example_setup

You can find the source code of the serial example in the following folder: <InstallFolder>/examples/serial


Testing the example @anchor serial_example_testing

To test the serial example:

  1. Build the example by following the instructions in Building the mesh stack.
  2. Program the board by following the instructions in Running examples.
  3. When the the serial example is running, start testing it using the Interactive PyACI. Refer to the Interactive PyACI documentation for details.
nrf_mesh_serial_enable
uint32_t nrf_mesh_serial_enable(void)
Enable the serial connection.
nrf_mesh_serial_init
uint32_t nrf_mesh_serial_init(nrf_mesh_serial_app_rx_cb_t app_rx_cb)
Initialize the serial module and all its related submodules.