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

P_evt_write handle doesn't match

Hi,

I have a basic characteristic on which I would like to write. I did this on so many projects without any problem but here, the value handle of my characteristic doesn't match with the expected one.

static void on_write(ble_acs_t * p_acs, ble_evt_t * p_ble_evt)
{
  ble_gatts_evt_write_t * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
  NRF_LOG_ERROR("p_evt_write handle %d  reset handle %d\n",p_evt_write->handle, p_acs->reset_handles.value_handle);
  if ( (p_evt_write->handle == p_acs->reset_handles.value_handle) && (p_evt_write->len == ACCEL_RESET_CHAR_MAX_LEN) ) {

    if(p_evt_write->data[0] == 0x01)
    {
        reset_flag = true;
    }

  } 
  
}

Example : p_evt_write_handle is equal to 24 and p_acs->reset_handles.value_handle is equal to 117. Furthermore, this value is really weird because it seems to be too high. I only have 1 service and 3 characteristics so 117 ...

Any idea? I think that I missed something

Parents
  • Sounds strange that p_evt_write->handle is 24 when you 1 service and 3 characteristics, but what handle do you expect? The only thing I can think of straight away is that this is not actually a write event, but some other event, you could double check that p_ble_evt->header.evt_id is actually BLE_GATTS_EVT_WRITE.

    I'm not sure why p_acs->reset_handles.value_handle is 117 either, but as you say it sounds incorrect. But this is forwarded from main.c isn't it? You have something like ble_acs_on_ble_evt(&m_acs, p_ble_evt); in ble_evt_dispatch() in main? Are you sure the handle is actually set? It is typically set in services_init(). Have you checked the value of p_acs->reset_handles.value_handle after it is called? If it is 117 I guess you have found the culprit. If not, you should check why this is set to 117 at a later time in your program.

Reply
  • Sounds strange that p_evt_write->handle is 24 when you 1 service and 3 characteristics, but what handle do you expect? The only thing I can think of straight away is that this is not actually a write event, but some other event, you could double check that p_ble_evt->header.evt_id is actually BLE_GATTS_EVT_WRITE.

    I'm not sure why p_acs->reset_handles.value_handle is 117 either, but as you say it sounds incorrect. But this is forwarded from main.c isn't it? You have something like ble_acs_on_ble_evt(&m_acs, p_ble_evt); in ble_evt_dispatch() in main? Are you sure the handle is actually set? It is typically set in services_init(). Have you checked the value of p_acs->reset_handles.value_handle after it is called? If it is 117 I guess you have found the culprit. If not, you should check why this is set to 117 at a later time in your program.

Children
No Data
Related