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);    

Parents Reply
  • SDK v15.

    err_code = ble_cus_init(&m_cus, &cus_init);
            APP_ERROR_CHECK(err_code);

    returns NRF_SUCESS and the rest of the code in main() for initializing the services and advertising works. The advertising starts normally and I can scan & connect to the DK. But immediately after the connection is made the connection disconnects and I cannot reconnect. If I remove BLE_CUS_DEF(m_cus2); from main.c there is no longer this issue.

Children
Related