STM32WB BLE MESH Sensor Model

1. Technical Description

This project demonstrates STM32WB application capabilities using BLE-Mesh solution and with a sensor module and using specific Sensor Client commands.

The goal of the project is to send sensor data from the Sensor Server to the Sensor Client on Sensor Client request.

To realize this project, we use two Discovery Kits including temperature and time of flight sensors.

One board will implement a BLE Mesh Sensor Server Node, and the second board a Sensor Client Node. A short push on Sensor Client User Button 1 (B1) send a Get Temperature request to the Sensor Server, a long push will send a Get Distance request. The Server will answer to the Client and the required data will be displayed on Client logs.


1.1. Limitation with current implementation

  • The OTA RAW Data Characteristic is limited to 20 bytes
  • So ATT Packet data transmitted is limited.

The following figure is an air capture of the raw data characteristic sent by the ST BLE Sensor application

ATT Write - 20 bytes

1.2. How to increase the data throughput

  • by increasing the size of the OTA RAW data characteristic to 248 - done with CubeWB 1.12.0 release
#define OTAS_STM_RAW_DATA_SIZE    (248)                                                //otas_stm.h
#define OTA_RAW_DATA_CHAR_SIZE    OTAS_STM_RAW_DATA_SIZE      //otas_stm.c

 /**
   *  Add Raw Data Characteristic
   */
  aci_gatt_add_char(OTAS_Context.OTAS_SvcHdle,
                    OTA_UUID_LENGTH,
                    (Char_UUID_t *)OTA_RAW_DATA_CHAR_UUID,
                    OTA_RAW_DATA_CHAR_SIZE,
                    CHAR_PROP_WRITE_WITHOUT_RESP,
                    ATTR_PERMISSION_NONE,
                    GATT_NOTIFY_ATTRIBUTE_WRITE | GATT_NOTIFY_WRITE_REQ_AND_WAIT_FOR_APPL_RESP,
                    10,
                    1,
                    &(OTAS_Context.OTAS_Raw_Data_CharHdle));
  • by increasing the size of ATT Maximum Transmission Unit (MTU) which is the maximum length of an ATT packet
/**
 * Maximum supported ATT_MTU size
 * This parameter is ignored by the CPU2 when CFG_BLE_OPTIONS is set to 1"
 */
#define CFG_BLE_MAX_ATT_MTU             (251)
  • by managing with GATT Client remote application the negotiation of the ATT MTU to increase the data payload for the transmitted packets
ATT MTU Exchange

1.3. ANDROID - ST BLE Sensor v4.12.0 - How to

The version v4.12.0 is available on Google Play https://play.google.com/store/apps/details?id=com.st.bluems&hl=en&gl=US