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

How to know which characteristic has been written to in ble_evt_handler

I have successfully added an event handler for managing if a write operation is performed on a characteristic, but how can I know that which characteristic has been written to?

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)  //This function here handles any event that comes, just add the event name and fill in what you want to do when the event occurs.
{
    ret_code_t err_code = NRF_SUCCESS;

    switch (p_ble_evt->header.evt_id)
    {


        case BLE_GATTS_EVT_WRITE:
        {
            uint8_t * p_data = p_ble_evt->evt.gatts_evt.params.write.data;
            uint16_t length = p_ble_evt->evt.gatts_evt.params.write.len;
            
            //How to know which characteristic has been written?

            NRF_LOG_INFO("Something got WRITTEN!");
            NRF_LOG_INFO("\"%x\"",p_data[0]);
            NRF_LOG_INFO("\"%x\"",p_data[1]);
            NRF_LOG_INFO("\"%x\"",p_data[2]);
            NRF_LOG_INFO("\"%x\"",p_data[3]);
        }
        break;

Parents Reply Children
Related