ESP32-BLE-Keyboard icon indicating copy to clipboard operation
ESP32-BLE-Keyboard copied to clipboard

BatteryLevel not sent

Open rtausend opened this issue 3 years ago • 10 comments

Hi there!

i implemented blekeyboard on a TinyPICO and try to send the Batterylevel via

bleKeyboard.setBatteryLevel(batterypercent);

But it only rarley get sent to my Windows11 Workstation ... But sometimes it seems to get transmitted ...

Any idea whats wrong there?

Thanks a lot, Robert

rtausend avatar Jul 15 '21 11:07 rtausend

I don't know, it has never been tested with Windows 11 before.

T-vK avatar Jul 15 '21 14:07 T-vK

Hi, same Problem on Windows 10

Holen Sie sich Outlook für Androidhttps://aka.ms/AAb9ysg


From: T-vK @.> Sent: Thursday, July 15, 2021 4:43:25 PM To: T-vK/ESP32-BLE-Keyboard @.> Cc: Robert Tausend @.>; Author @.> Subject: Re: [T-vK/ESP32-BLE-Keyboard] BatteryLevel not sent (#99)

I don't know, it has never been tested with Windows 11 before.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/T-vK/ESP32-BLE-Keyboard/issues/99#issuecomment-880752812, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AC5DMX5VFUYSXNT7F3C6QGDTX3XY3ANCNFSM5ANMLNCA.

rtausend avatar Jul 15 '21 15:07 rtausend

For me it seems to only update the battery percentage upon pairing. I don't think I've seen it ever update otherwise, even after power cycling the BT device.

This is on Win10 with a Lolin32 Lite

galister avatar Jul 22 '21 00:07 galister

Hmmm sometimes it updates it, but really not stable ... Any idea what i could try here?

rtausend avatar Jul 29 '21 14:07 rtausend

I don't know to be honest. Maybe the value is only transmitted when certain events happen. I haven't actually tested that feature at all beyond setting the initial battery level. Is this only happening on Windows or does it also not update correctly on Android, iOS, Mac OS and Linux?

T-vK avatar Jul 29 '21 17:07 T-vK

Hey! I only tried it on Windows till now, on MacOS i don't even see the device in the BT Menu ... will open another Case for that and see if there is any solution... Thanks

rtausend avatar Jul 30 '21 06:07 rtausend

I use this to read the latest battery charged informations status:

https://www.bluetoothgoodies.com/?v=020d0001&osv=10.0.19043

Windows is as far as I know, not ready with implementing to poll all devices

beastdjw avatar Aug 30 '21 19:08 beastdjw

oh, I fix this bug, in BLEHIDDevice.cpp #45, you need to change this

this is origon:

BLE2904* batteryLevelDescriptor = new BLE2904();
batteryLevelDescriptor->setFormat(BLE2904::FORMAT_UINT8);
batteryLevelDescriptor->setNamespace(1);
batteryLevelDescriptor->setUnit(0x27ad);

m_batteryLevelCharacteristic = m_batteryService->createCharacteristic((uint16_t) 0x2a19, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
m_batteryLevelCharacteristic->addDescriptor(batteryLevelDescriptor);
m_batteryLevelCharacteristic->addDescriptor(new BLE2902());

this is my fix:

BLE2904* batteryLevelDescriptor = new BLE2904();
batteryLevelDescriptor->setFormat(BLE2904::FORMAT_UINT8);
batteryLevelDescriptor->setNamespace(1);
batteryLevelDescriptor->setUnit(0x27ad);

m_batteryLevelCharacteristic = m_batteryService->createCharacteristic((uint16_t) 0x2a19, BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_NOTIFY);
m_batteryLevelCharacteristic->addDescriptor(batteryLevelDescriptor);
m_batteryLevelCharacteristic->addDescriptor(new BLE2904());

BG2CRW avatar May 06 '22 19:05 BG2CRW

I've submitted a fix in the ESP Arduino GH https://github.com/espressif/arduino-esp32/pull/6864

This shall close this issue as well, I guess.

SuGlider avatar Jun 14 '22 01:06 SuGlider

Would this fix be only in the base (original) BLE library? I'm having exactly the same issue using nimBLE - battery report works only in the constructor and not via bleKeyboard.setBatteryLevel()

skotl avatar Aug 17 '22 21:08 skotl