Getting errors related to logging

The application seems to stop at an instance where I invoke a Send call to send data over to a ble central, and the callstack looks as follows. Any way to narrow down the cause?



I tried the program later and I got the following stack. Thing is: nothing useful gets printed in the debug console

Parents Reply Children
  • Error code 8 means it's NRF_ERROR_INVALID_STATE. 
    Most likely the CCCD was not enabled when you call the sd_ble_gatts_hvx() function to send the notification to the central. 
    Please enable notification on the central before sending. 
    You can test with our blinky example or ble_app_uart example. 

  • So it's the button on the right side that needs to be pressed to enable CCCD to allow notifications to be received by the central yes?

    Thing though is, as soon as I connect, I only have a few ms to enable the CCCD otherwise I start getting a bunch of logger issues. So I always have to hurry every time I connect the central to the peripheral from the nrf connect app


  • Hi, 

    You can delay sending the notification, and only wait until the CCCD being set before you start notification. Please follow what we have in our service example code, for example check the function on_hrm_cccd_write() in ble_hrs.c in ble_app_hrs example. 

    Or you can modify the code to ignore the NRF_ERROR_INVALID_STATE and not assert it. 

  • delaying sending the notification could've been an option but i'm thinking of a more robust solution.

    does ble_srv_is_notification_enabled() check whether the central has enabled the CCCD?

  • HI Morpho,

    What I meant was not about a specific time delay but more about wait for the write command that enable CCCD before you send the notification. 

    If you have a look into the ble_hrs.c file you can find that the on_write() function is called when BLE_GATTS_EVT_WRITE is received (in ble_hrs_on_ble_evt). 
    In side on_write() it will call on_hrm_cccd_write() if it's the write command to the cccd handle. 

    ble_srv_is_notification_enabled() will check if the value written to the CCCD handle is to enable or disable Notification (not Indication)

    You can implement something similar in your ble event handler of your service. 

Related