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

debugging sd_ble_gatts_hvx

Hi

I am trying to get to the bottom of a problem I am having with sending a buffer of data on connection and indication enable. Here's what I do: I have a process running, which is capturing sensor data every 10 seconds, and keeping it in a circular buffer. When a master connects, I want to send the circular buffer to the master app. I am doing that by triggering on the event that the CCCD is written to enable indications (I am using indication because I want to make sure that the values end up in the app). When this CCCD write is happening, I send the first item in my circular buffer, and then use the BLE_GATTS_EVT_HVC event to see if I have gotten a confirmation, just as in the health thermometer example.

I am running into a number of problems

  • when I trigger on the CCCD write and immediately do a sd_ble_gatts_hvx, I get an error 8 (illegal state); if I start a timer and do the same after 10 ms, then it is ok
  • I sometimes also have a BLE_ERROR_GATTS_SYS_ATTR_MISSING error, how can I avoid that? when should I normally do a sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0) (i do not use bonding)

I have the impression that timing issues or race conditions are causing my problems, can anyone give me hint on how to solve this?

Parents
  • Maybe there is some light at the end of the tunnel. Currently I was trying to enable an indication by writing 0x02 0x00 (little endian) to the CCCD attribute value of my characteristic that I want to send indications from. And it used to trigger something in the past. But now I clicked the 'enable services' button in the MCP. And then it does seem to work. What is the difference between the 2 actions? The downside of using the enable services button seems to be that all characteristics are enabled, and hence starting to send data.

    And then, I was wondering: when clicking on an attribute of a characteristic in MCP, one can see the UUID and the handle of each of them. How are the UUID and the handle of e.g. the CCCD defined? I do not have to configure it myself I think, it just happens - I only have defined the UUID of each characterstic, and that seems to end up in the UUID attribute. Am I correct in this?

Reply
  • Maybe there is some light at the end of the tunnel. Currently I was trying to enable an indication by writing 0x02 0x00 (little endian) to the CCCD attribute value of my characteristic that I want to send indications from. And it used to trigger something in the past. But now I clicked the 'enable services' button in the MCP. And then it does seem to work. What is the difference between the 2 actions? The downside of using the enable services button seems to be that all characteristics are enabled, and hence starting to send data.

    And then, I was wondering: when clicking on an attribute of a characteristic in MCP, one can see the UUID and the handle of each of them. How are the UUID and the handle of e.g. the CCCD defined? I do not have to configure it myself I think, it just happens - I only have defined the UUID of each characterstic, and that seems to end up in the UUID attribute. Am I correct in this?

Children
No Data
Related