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

Required buffer data on cccd_handle write for INDICATION

Hello,

I'm working with a nrf51822, SoftDevice S120 v2.0 and SDK v9.0 platform.

Specifically using it a Central role to connect to a Blood Pressure peripheral.

I connect to the peripheral, find the Service/Characteristic I need and register for an "Indication" like so:

uint32_t                 err_code;
ble_gattc_write_params_t write_params;
uint8_t                  buf[BLE_CCCD_VALUE_LEN];

buf[0] = BLE_GATT_HVX_INDICATION;
buf[1] = 0;

write_params.write_op = BLE_GATT_OP_WRITE_REQ;
write_params.handle   = p_client->srv_db.services[0].charateristics[p_client->my_char_index].cccd_handle;
write_params.offset   = 0;
write_params.len      = sizeof(buf);
write_params.p_value  = buf;

err_code = sd_ble_gattc_write(p_client->srv_db.conn_handle, &write_params);
APP_ERROR_CHECK(err_code);

Unfortunately this does not work for me.

i.e. I get a BLE_GATTC_EVT_WRITE_RSP back from the peripheral but BLE_GATTC_EVT_HVX never gets throw to indicate data has been received.

In this:

buf[0] = BLE_GATT_HVX_INDICATION;
buf[1] = 0

Can someone please tell me what buf[1] = 0 is supposed to be? I copied this from a NOTIFICATION example and I cant seem to find anywhere in the documentation what this buffer is supposed to contain. I suspect this may have something to do with the problem.

Thanks very much, Mark

Parents
  • After solving the pairing issue.

    I still cant write the indication with an auth error response. My logged flow is:

    • Connect to Peripheral.
    • It asks for DM_EVT_SECURITY_SETUP.
    • I invoke dm_security_setup_req and get DM_EVT_SECURITY_SETUP_COMPLETE.
    • I then write indication value to CCCD Peripheral responds with - BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION.
    • I invoke dm_security_setup_req again, this time it says "Already bonded, now encrypt".
    • I then get DM_EVT_LINK_SECURED I then try to write indication value to CCCD again but Peripheral - responds again with BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION.

    This loop continues for around 5 times and then get error 0x00000011 (NRF_ERROR_INVALID_DATA i think) when I sd_ble_gattc_write the CCCD value.

Reply
  • After solving the pairing issue.

    I still cant write the indication with an auth error response. My logged flow is:

    • Connect to Peripheral.
    • It asks for DM_EVT_SECURITY_SETUP.
    • I invoke dm_security_setup_req and get DM_EVT_SECURITY_SETUP_COMPLETE.
    • I then write indication value to CCCD Peripheral responds with - BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION.
    • I invoke dm_security_setup_req again, this time it says "Already bonded, now encrypt".
    • I then get DM_EVT_LINK_SECURED I then try to write indication value to CCCD again but Peripheral - responds again with BLE_GATT_STATUS_ATTERR_INSUF_AUTHENTICATION.

    This loop continues for around 5 times and then get error 0x00000011 (NRF_ERROR_INVALID_DATA i think) when I sd_ble_gattc_write the CCCD value.

Children
No Data
Related