I am trying to use the Cy_BLE_GetBatteryLevel to get the radio voltage level without ADC. However, the PDL references are kind of ambiguous. Generally, the BLE event parameters are casted to another pointer to read values for the event-dependent pointer structure, but for CY_BLE_EVT_RADIO_VOLTAGE_LEVEL (and temperature), it says it is of type uint16_t. Is it a typo in this case?
Further, the event CY_BLE_EVT_SET_SLAVE_LATENCY_MODE_COMPLETE mentioned being triggered by Cy-BLE_GetBatteryLevel too. Is this also a typo? Or is there any other operation should be done to get the battery level of the BLE radio?
The PDL version I'm using is 3.0.4 and BLE component version 2.10
Yes. There is a confusion in the PDL. Please find the correction below.
Calling the API Cy_BLE_GetBatteryLevel(); generates the event CY_BLE_EVT_RADIO_VOLTAGE_LEVEL and the event parameter is the pointer of the type uint16_t. The user has to type cast the event param to uint16_t pointer and deference it to get voltage level in millivolts.
battery_level = (uint16_t *)eventParam;
The event CY_BLE_EVT_SET_SLAVE_LATENCY_MODE_COMPLETE will not be generated by calling Cy_BLE_GetBatteryLevel(). This is the typo in the PDL.
Thank you for pointing this out.
Thank you for the clarification. The attached is a very simple project that just trying to get the battery level. Do you know why is it returning 0x2700, 0x0600, 0x0000 values occasionally?
I am using a CYBLE-416045-02 prototyping kit, where 0x2700 = 9984 mV does not make quite much sense. Thanks!
That's strange. Please tell us how frequently you are reading the temperature and battery values.
Also please tell us how many times you are getting error values out of 100 times.