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, \
NRF_BLE_QWR_DEF(m_qwr); /**< GATT module instance. */
BLE_CUS_DEF(m_cus); /**< Context for the Queued Write module.*/
What SDK version are you using?
Have you checked whether one of your function calls returns an err_code != NRF_SUCCESS?
err_code = ble_cus_init(&m_cus, &cus_init);
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.
Hi an update: I got it working after using NRF_SDH_BLE_OBSERVERS().