Error reading characteristic 2A19 battery level: the handle is invalid

Hi Everyone,

I'm currently testing the battery service with my development kit, nrF52dk, and I've found an error stating "The handle is invalid" when I press the "read" button on the nRF Connect App to read the initial battery level. (I am using a iPhone 11). 

Things that i've done:

- Creating a new folder "nrf_ble_service" into the main project

- added into the bas.c into the folder and bas.h into the main.c

- configure the sdk_config.h to enable the bas.c file

I also faced the same issue when I try to read from the "Link Loss" and "Client Characteristic Configuration".

Thanks in advance for your help!

Regards,

Zachary

Parents
  • Hi Lim, 

    I suspect that the phone was caching the ATT table. When you add a new service/characteristic into the ATT table the phone didn't do a service discovery to update that and it will get "The handle is invalid" when trying to read. 

    Please try turn off and on Bluetooth on the phone (a phone reset may be needed) and try again. 
    Also please make sure you set NRF_SDH_BLE_SERVICE_CHANGED = 1 in the sdk_config.h file so that the phone will not cache the ATT table.  

Reply
  • Hi Lim, 

    I suspect that the phone was caching the ATT table. When you add a new service/characteristic into the ATT table the phone didn't do a service discovery to update that and it will get "The handle is invalid" when trying to read. 

    Please try turn off and on Bluetooth on the phone (a phone reset may be needed) and try again. 
    Also please make sure you set NRF_SDH_BLE_SERVICE_CHANGED = 1 in the sdk_config.h file so that the phone will not cache the ATT table.  

Children
Related