This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiple BLE_CUS_DEF() calls error

Hi I am trying to add multiple services to the custom_ble_service tutorial example right now. When I try to create a second ble_cus_t instance 'mcus2' by calling BLE_CUS_DEF(m_cus2) the code compiles, but after I flash the code and connect to DK board with nrf_connect app there is disconnection and I cannot reconnect. I check and there is an error that causes the NRF in the DK to stop working. 

So I inspect the code and I think that I cannot make multiple calls to BLE_CUS_DEF() with different parameters. Is there a way to set and use multiple NRF_SDH_BLE_OBSERVER() if my goal is to have multiple custom services? 

#define BLE_CUS_DEF(_name)                                                                          \
static ble_cus_t _name;                                                                             \
NRF_SDH_BLE_OBSERVER(_name ## _obs,                                                                 \
                     BLE_HRS_BLE_OBSERVER_PRIO,                                                     \
                     ble_cus_on_ble_evt, &_name)

NRF_BLE_GATT_DEF(m_gatt);
NRF_BLE_QWR_DEF(m_qwr);                                                         /**< GATT module instance. */
BLE_CUS_DEF(m_cus); /**< Context for the Queued Write module.*/
BLE_CUS_DEF(m_cus2);
BLE_ADVERTISING_DEF(m_advertising);    

Related