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

How to write to CCCD in another node?

So I'm still trying to get my way around the DFU service implementation, and I'm currently having trouble with the first step, which is to enable the control point notification (Write 0x0001 to CCCD).

I checked the Characteristics tutorial, but I still couldn't understand how to do this. I was also looking at this question:

devzone.nordicsemi.com/.../

and I don't know where can I find the 0x11 handle OP is talking about. I apologize for such a basic question, this is my first time working with a BLE project.

Thanks!

EDIT: I'm trying to do this from an NRF central node, not from Master Control Panel.

So far, I have finished the DFU service and characteristics discovery in the Central node. I saved the DFU control point characteristic CCCD handle in the ble_dfu_on_db_disc_evt() as follows:

for (i = 0; i < p_evt->params.discovered_db.char_count; i++)
{
    switch (p_chars[i].characteristic.uuid.uuid)
    {
        case BLE_DFU_CTRL_PT_UUID:
            SEGGER_RTT_WriteString(0, "Discovered DFU control point characteristic\n");
            p_ble_dfu->dfu_ctrl_pt_handles.cccd_handle = p_chars[i].cccd_handle;
            p_ble_dfu->dfu_ctrl_pt_handles.value_handle = p_chars[i].characteristic.handle_value;
            break;

        case BLE_DFU_PKT_CHAR_UUID:
            SEGGER_RTT_WriteString(0, "Discovered DFU packet characteristic\n");
            p_ble_dfu->dfu_pkt_handles.cccd_handle = p_chars[i].cccd_handle;
            p_ble_dfu->dfu_pkt_handles.value_handle = p_chars[i].characteristic.handle_value;
            break;

        default:
            break;
    }
}

then what I'm trying to do is this:

void ble_dfu_enable_ctrl_pt_notifications(ble_dfu_t *p_ble_dfu)
{
    if (p_ble_dfu->conn_handle != BLE_CONN_HANDLE_INVALID)
    {
        uint16_t               len = 2;
        uint8_t data[2] = {0x00, 0x01};
        ble_gatts_hvx_params_t hvx_params;
        memset(&hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = p_ble_dfu->dfu_ctrl_pt_handles.cccd_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = 0;
        hvx_params.p_len  = &len;
        hvx_params.p_data = data;  

        sd_ble_gatts_hvx(p_ble_dfu->conn_handle, &hvx_params);
        SEGGER_RTT_WriteString(0, "Enabled control point notifications\n");
    }
}
Related