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

strange error code 13313 (0x3401) returned by sd_ble_gatts_hvx()

Hi, I'm trying to update attribute value and notify it to client using sd_ble_gatts_hvx() function:

  memset(ms, 0, sizeof(params));
  params.type=BLE_GATT_HVX_NOTIFICATION;
  params.handle=p_lbs->button_char_handles.value_handle;
  params.p_data=&button_state;
  params.p_len=&len;
  err_code=sd_ble_gatts_hvx(p_lbs->conn_handle, ms);
  
  DPRINTF("BLE button update: state=%u, len=%u, conn_h=%u, svc_h=%u, val_h=%u, err=%u\n", *params.p_data, *params.p_len, p_lbs->conn_handle, p_lbs->service_handle, params.handle, err_code);
  return(err_code);

When connection is not established and connection handle is invalid (65535) I got error code 8 - NRF_ERROR_INVALID_STATE, shats OK. BLE button update: state=0, len=1, conn_h=65535, svc_h=12, val_h=14, err=8 When I connect via android tablet and try to read the value and change it I got strange error code 13313 (0x3401) that doesn't match any known NRF_ERROR_xx code. BLE button update: state=1, len=1, conn_h=0, svc_h=12, val_h=14, err=13313 But the updated value is readed OK. I tried more times update and tap read button on tablet and got same error but with good value. When I turn on the notify on tablet it works too (value is updated automatically) and returning error 0 like expected. BLE button update: state=0, len=1, conn_h=0, svc_h=12, val_h=14, err=0 Interesting that when I stop notify on tablet it keeps returning error 0 and not 13313. The updated value can still be read manually tapping read button...

Parents
  • I tried again with some more printings on event but found that BLE_GATTS_EVT_SYS_ATTR_MISSING event didn't come so sd_ble_gatts_sys_attr_set() is not called. I only captured event BLE_GAP_EVT_CONN_PARAM_UPDATE on which I do nothing - shoul I? I tried multiple read/write from client and write (notify) on server but BLE_GATTS_EVT_SYS_ATTR_MISSING didn't come up. When I turned notification on the client I got BLE_GATTS_EVT_WRITE (BLE remote client write to CCCD handle: 16) and after this happen the error disappear (code 0) on notify the attribute. If I disable notification on client and notify again on server I got error 8 but I can read new value if I tap read button on client.

    Here's my debug log: bleinit OK advstart OK BLE app event: 10h BLE client connected, handle=2579 BLE app event: 12h BLE connection parameters updated

    seta[1]=20 // this I use to set atribute value and notify (calls sd_ble_gatts_hvx) BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=3401h OK seta[1]=30 BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=3401h OK BLE app event: 50h BLE usr.attr update from remote client: val_h=14, len=1, 1st Byte=50h seta[1]=40 BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=3401h OK BLE app event: 50h

    // I enabled notification on client BLE remote client write to CCCD handle: 16 seta[1]=41 BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=0000h OK BLE app event: 01h BLE packet was transmitted, packet count: 1 seta[1]=42 BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=0000h OK BLE app event: 01h BLE packet was transmitted, packet count: 1 BLE app event: 50h BLE remote client write to CCCD handle: 16

    // I disabled notification on client seta[1]=43 BLE usr.attr update: len=1, conn_h=2579, svc_h=12, val_h=14, err=0008h OK

  • BTW it would be very helpful to have some single document with all error codes because tracking by error numbers is hard as it's defined by combinations like 0x2000+0x0100+0x0030+0x0001 and I cannot simply search for 0x2131 string...

Reply Children
No Data
Related