I updated the hid_demo_task as below. I could find the battery level was changed and set. But when I use Bluelight to read the battery level it still keeps 0x64.
Code: Untitled.c Select all
void hid_demo_task(void *pvParameters)
{
static bool send_volum_up = false;
static uint8_t tcn=0;
static uint8_t lvlBatt=100;
while (1) {
tcn++;
if (tcn>=5) {
tcn=0;
if (lvlBatt>30) lvlBatt--;
esp_hidd_dev_battery_set(hid_dev,lvlBatt);
ESP_LOGI(TAG, "Batt Level = %d",lvlBatt);
}
if (dev_connected) {
ESP_LOGI(TAG, "Send the volume");
if (send_volum_up) {
esp_hidd_send_consumer_value(HID_CONSUMER_VOLUME_UP, true);
vTaskDelay(100 / portTICK_PERIOD_MS);
esp_hidd_send_consumer_value(HID_CONSUMER_VOLUME_UP, false);
} else {
esp_hidd_send_consumer_value(HID_CONSUMER_VOLUME_DOWN, true);
vTaskDelay(100 / portTICK_PERIOD_MS);
esp_hidd_send_consumer_value(HID_CONSUMER_VOLUME_DOWN, false);
}
send_volum_up = !send_volum_up;
}
vTaskDelay(2000 / portTICK_PERIOD_MS);
}
}
Code: Untitled.tex Select all
I (61098) HID_DEV_DEMO: Batt Level = 94
I (61098) HID_DEV_DEMO: Send the volume
W (61098) Test: cmd=233,press=1
W (61198) Test: cmd=233,press=0
I (63198) HID_DEV_DEMO: Send the volume
W (63198) Test: cmd=234,press=1
W (63298) Test: cmd=234,press=0
I (65298) HID_DEV_DEMO: Send the volume
W (65298) Test: cmd=233,press=1
W (65398) Test: cmd=233,press=0
I (67398) HID_DEV_DEMO: Send the volume
W (67398) Test: cmd=234,press=1
W (67498) Test: cmd=234,press=0
I (69498) HID_DEV_DEMO: Send the volume
W (69498) Test: cmd=233,press=1
W (69598) Test: cmd=233,press=0
I (71598) HID_DEV_DEMO: Batt Level = 93
I (71598) HID_DEV_DEMO: Send the volume
W (71598) Test: cmd=234,press=1
W (71698) Test: cmd=234,press=0