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

CCCD notifications write not received by peripheral

I have setup a 1-1 paired central(+peripheral)  <=>  peripheral
Central is a 52832, SDK 16.0, SD s132 v7.0.1
peripheral is a 52811, SDK 16.0, SD s112 v7.0.1

My code is based on the hrs/hrs_c examples, and uses peer manager, whitelist, and bonding (SEC_JUST_WORKS).

When first connecting, after call to pm_conn_secure succeeds, the central trie to enable notifications from the peripheral :

nrf_ble_gq_req_t cccd_req;
uint8_t          cccd[BLE_CCCD_VALUE_LEN];
uint16_t         cccd_val = notification_enable ? BLE_GATT_HVX_NOTIFICATION : 0;

memset(&cccd_req, 0, sizeof(nrf_ble_gq_req_t));

cccd[0] = LSB_16(cccd_val);
cccd[1] = MSB_16(cccd_val);

cccd_req.type                        = NRF_BLE_GQ_REQ_GATTC_WRITE;
cccd_req.error_handler.cb            = gatt_error_handler;
cccd_req.error_handler.p_ctx         = p_ble_scale_c;
cccd_req.params.gattc_write.handle   = p_ble_scale_c->handles.scale_tx_cccd_handle;
cccd_req.params.gattc_write.len      = BLE_CCCD_VALUE_LEN;
cccd_req.params.gattc_write.offset   = 0;
cccd_req.params.gattc_write.p_value  = cccd;
cccd_req.params.gattc_write.write_op = BLE_GATT_OP_WRITE_REQ;

NRF_LOG_INFO("Configuring CCCD");

err_code = nrf_ble_gq_item_add(p_ble_scale_c->p_gatt_queue, &cccd_req, p_ble_scale_c->conn_handle);
APP_ERROR_CHECK(err_code);

NRF_LOG_DEBUG("CCCD written");


This gives the following log :

<info> app: Configuring CCCD
<debug> nrf_ble_gq: Adding item to the request queue
<debug> nrf_ble_gq: GATTC Write Request
<debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.
<debug> app: CCCD written

However, on the peripheral side, the write event is not received (BLE_GATTS_EVT_WRITE never entering).

This is only happening on the FIRST CONNECTION. If I restart the central or the peripheral, the connection is re-established by bonding, and notifications are correctly enabled and received.

Please tell me what code excerpts you want to see if needed.

Thanks for your help !
Quentin

Parents Reply Children
No Data
Related