mirror of
https://github.com/T-vK/ESP32-BLE-Keyboard.git
synced 2026-02-20 01:41:32 +01:00
Merge pull request #13 from grafmar/master
setting battery level also in hid, if it was created, yet
This commit is contained in:
@@ -89,7 +89,7 @@ static const uint8_t _hidReportDescriptor[] = {
|
||||
END_COLLECTION(0) // END_COLLECTION
|
||||
};
|
||||
|
||||
BleKeyboard::BleKeyboard(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel)
|
||||
BleKeyboard::BleKeyboard(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel) : hid(0)
|
||||
{
|
||||
this->deviceName = deviceName;
|
||||
this->deviceManufacturer = deviceManufacturer;
|
||||
@@ -112,6 +112,8 @@ bool BleKeyboard::isConnected(void) {
|
||||
|
||||
void BleKeyboard::setBatteryLevel(uint8_t level) {
|
||||
this->batteryLevel = level;
|
||||
if (hid != 0)
|
||||
this->hid->setBatteryLevel(this->batteryLevel);
|
||||
}
|
||||
|
||||
void BleKeyboard::taskServer(void* pvParameter) {
|
||||
|
||||
@@ -89,7 +89,6 @@ typedef struct
|
||||
class BleKeyboard : public Print
|
||||
{
|
||||
private:
|
||||
uint8_t _buttons;
|
||||
BleConnectionStatus* connectionStatus;
|
||||
BLEHIDDevice* hid;
|
||||
BLECharacteristic* inputKeyboard;
|
||||
@@ -97,7 +96,6 @@ private:
|
||||
BLECharacteristic* inputMediaKeys;
|
||||
KeyReport _keyReport;
|
||||
MediaKeyReport _mediaKeyReport;
|
||||
void buttons(uint8_t b);
|
||||
static void taskServer(void* pvParameter);
|
||||
public:
|
||||
BleKeyboard(std::string deviceName = "ESP32 BLE Keyboard", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100);
|
||||
|
||||
Reference in New Issue
Block a user