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 to demonstrate what I mean, a piece of log in MCP: [14:02:29.6] UpdateAttributeValue(mode=0) [14:02:29.6] WriteRequest sent to handle 0x0015 with value [2, 0] [14:02:29.8] Updated handle 0015 with value [2, 0] [14:02:41.5] EnableServices({0x000D:1,0x0011:1,0x0015:2,0x0019:2,}) [14:02:41.7] Updated handle 0015 with value [2, 0] [14:02:41.7] Successfully updated the store value of CCCD [14:02:41.9] Updated handle 0011 with value [1, 0] [14:02:41.9] Successfully updated the store value of CCCD [14:02:42.1] Updated handle 0019 with value [2, 0] [14:02:42.1] Successfully updated the store value of CCCD [14:02:42.2] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:42.3] Updated handle 000D with value [1, 0] [14:02:42.3] Successfully updated the store value of CCCD [14:02:42.4] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:42.6] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:42.8] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.0] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:43.2] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.4] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:43.6] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.8] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:44.0] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:44.0] DisableServices({0x000D:1,0x0011:1,0x0015:2,0x0019:2,}) [14:02:44.2] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:44.2] Updated handle 0015 with value [0, 0] [14:02:44.2] Successfully updated the store value of CCCD [14:02:44.4] Updated handle 0011 with value [0, 0] [14:02:44.4] Successfully updated the store value of CCCD [14:02:44.6] Updated handle 0019 with value [0, 0] [14:02:44.6] Successfully updated the store value of CCCD [14:02:44.8] Updated handle 000D with value [0, 0] [14:02:44.8] Successfully updated the store value of CCCD

    On the first write of the CCCD (handle 15) at [14:02:29.6], nothing seems to happen. However, when I do the 'enable services' (at[14:02:41.5]) I start getting values on 2 of the 4 indicate/notify characteristics.

    So what is the difference between writing directly to the CCCD with the right value, and doing a 'start services'?

Reply
  • maybe to demonstrate what I mean, a piece of log in MCP: [14:02:29.6] UpdateAttributeValue(mode=0) [14:02:29.6] WriteRequest sent to handle 0x0015 with value [2, 0] [14:02:29.8] Updated handle 0015 with value [2, 0] [14:02:41.5] EnableServices({0x000D:1,0x0011:1,0x0015:2,0x0019:2,}) [14:02:41.7] Updated handle 0015 with value [2, 0] [14:02:41.7] Successfully updated the store value of CCCD [14:02:41.9] Updated handle 0011 with value [1, 0] [14:02:41.9] Successfully updated the store value of CCCD [14:02:42.1] Updated handle 0019 with value [2, 0] [14:02:42.1] Successfully updated the store value of CCCD [14:02:42.2] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:42.3] Updated handle 000D with value [1, 0] [14:02:42.3] Successfully updated the store value of CCCD [14:02:42.4] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:42.6] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:42.8] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.0] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:43.2] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.4] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:43.6] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:43.8] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:44.0] Received a HandleValueIndication on handle 0013 with value 050000003200000000000000 [14:02:44.0] DisableServices({0x000D:1,0x0011:1,0x0015:2,0x0019:2,}) [14:02:44.2] Received a HandleValueIndication on handle 0017 with value 050000003200000000000000 [14:02:44.2] Updated handle 0015 with value [0, 0] [14:02:44.2] Successfully updated the store value of CCCD [14:02:44.4] Updated handle 0011 with value [0, 0] [14:02:44.4] Successfully updated the store value of CCCD [14:02:44.6] Updated handle 0019 with value [0, 0] [14:02:44.6] Successfully updated the store value of CCCD [14:02:44.8] Updated handle 000D with value [0, 0] [14:02:44.8] Successfully updated the store value of CCCD

    On the first write of the CCCD (handle 15) at [14:02:29.6], nothing seems to happen. However, when I do the 'enable services' (at[14:02:41.5]) I start getting values on 2 of the 4 indicate/notify characteristics.

    So what is the difference between writing directly to the CCCD with the right value, and doing a 'start services'?

Children
No Data
Related