This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Sending multiple bluetooth notifications in quick succession (nRF Connect SDK 1.6.1)

Hey all,

I've run into an interesting situation where writing multiple notifications to successively to a multi-characteristic (custom) service causes data loss. Look like it may be similar to the case here: https://devzone.nordicsemi.com/f/nordic-q-a/77381/sending-multiple-notify-packets-per-connection-interval

The service is defined here. All characteristics have unique UUIDs (See below)

#define BT_UUID_ENV_TEMPERATURE_VAL \
    BT_UUID_128_ENCODE(0x12340002, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
#define BT_UUID_ENV_HUMIDITY_VAL \
    BT_UUID_128_ENCODE(0x12340003, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
#define BT_UUID_ENV_C02_VAL \
    BT_UUID_128_ENCODE(0x12340004, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)
#define BT_UUID_ENV_PRESURE_VAL \
    BT_UUID_128_ENCODE(0x12340005, 0xb5a3, 0xf393, 0xe0a9, 0xe50e24dcca9e)

Here's how they're defined (along with some other characteristics)

BT_GATT_SERVICE_DEFINE(env_service,
                       BT_GATT_PRIMARY_SERVICE(BT_UUID_ENV_SERVICE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_TEMPERATURE, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_HUMIDITY, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_C02, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_PRESSURE, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_AQ, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_PH, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_EC, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                       BT_GATT_CHARACTERISTIC(BT_UUID_ENV_WT, BT_GATT_CHRC_NOTIFY,
                                              BT_GATT_PERM_NONE, NULL, NULL, NULL),
                       BT_GATT_CCC(env_ccc_cfg_changed,
                                   BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
                                   );

I get no errors when sending and the data shows up ok in the console:

[00:00:16.136,016] <inf> app_ble_service_env: Env service notifications enabled
[00:00:17.208,557] <inf> app_ble_service_env: Env service notifications enabled
[00:00:18.281,066] <inf> app_ble_service_env: Env service notifications enabled
[00:00:19.841,094] <inf> app_ble_service_env: Env service notifications enabled
[00:00:36.554,168] <inf> fluidd_sensors: Fetching Sensor Data Now
[00:00:36.556,335] <inf> fluidd_sensors: Temp: 28.190000
[00:00:36.556,335] <inf> fluidd_sensors: raw hex: 
                                         1c 00 00 00 30 e6 02 00                          |....0...         
[00:00:36.558,532] <inf> fluidd_sensors: Humidity: 51.497000
[00:00:36.558,532] <inf> fluidd_sensors: raw hex: 
                                         33 00 00 00 68 95 07 00                          |3...h...         
[00:00:36.559,387] <inf> fluidd_sensors: C02: 993.0
[00:00:36.559,387] <inf> fluidd_sensors: raw hex: 
                                         e1 03 00 00 00 00 00 00                          |........         
[00:00:36.561,553] <inf> fluidd_sensors: Pressure: 101.5000
[00:00:36.561,645] <inf> fluidd_sensors: raw hex: 
                                         65 00 00 00 88 13 00 00                          |e.......  

When received on the phone side, the first two characteristics usually show up correctly (right data). But the last subscribed characteristic receives the wrong data. I'm assuming there are some limits here (max notifications per interval?) If there's a way to work around this that'd be fantastic.

Here's the data on the phone side using nRF Connect on iOS:

Thanks!

Related