From b64348dbc56c96ea0a4ca634071b8c689a9b9dac Mon Sep 17 00:00:00 2001 From: Mathew Date: Sun, 23 Feb 2020 20:10:35 +1300 Subject: [PATCH] Fixes to media keys connect and disconnect. --- BleConnectionStatus.cpp | 7 +++++++ BleConnectionStatus.h | 1 + BleKeyboard.cpp | 1 + 3 files changed, 9 insertions(+) diff --git a/BleConnectionStatus.cpp b/BleConnectionStatus.cpp index f7468f2..baf51ed 100644 --- a/BleConnectionStatus.cpp +++ b/BleConnectionStatus.cpp @@ -8,6 +8,9 @@ void BleConnectionStatus::onConnect(BLEServer* pServer) this->connected = true; BLE2902* desc = (BLE2902*)this->inputKeyboard->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); desc->setNotifications(true); + + desc = (BLE2902*)this->inputMediaKeys->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); + desc->setNotifications(true); } void BleConnectionStatus::onDisconnect(BLEServer* pServer) @@ -15,4 +18,8 @@ void BleConnectionStatus::onDisconnect(BLEServer* pServer) this->connected = false; BLE2902* desc = (BLE2902*)this->inputKeyboard->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); desc->setNotifications(false); + + desc = (BLE2902*)this->inputMediaKeys->getDescriptorByUUID(BLEUUID((uint16_t)0x2902)); + desc->setNotifications(false); + } diff --git a/BleConnectionStatus.h b/BleConnectionStatus.h index fbd59b6..7fd2667 100644 --- a/BleConnectionStatus.h +++ b/BleConnectionStatus.h @@ -16,6 +16,7 @@ class BleConnectionStatus : public BLEServerCallbacks void onDisconnect(BLEServer* pServer); BLECharacteristic* inputKeyboard; BLECharacteristic* outputKeyboard; + BLECharacteristic* inputMediaKeys; }; #endif // CONFIG_BT_ENABLED diff --git a/BleKeyboard.cpp b/BleKeyboard.cpp index a361d4c..28286b5 100644 --- a/BleKeyboard.cpp +++ b/BleKeyboard.cpp @@ -128,6 +128,7 @@ void BleKeyboard::taskServer(void* pvParameter) { bleKeyboardInstance->inputMediaKeys = bleKeyboardInstance->hid->inputReport(MEDIA_KEYS_ID); bleKeyboardInstance->connectionStatus->inputKeyboard = bleKeyboardInstance->inputKeyboard; bleKeyboardInstance->connectionStatus->outputKeyboard = bleKeyboardInstance->outputKeyboard; + bleKeyboardInstance->connectionStatus->inputMediaKeys = bleKeyboardInstance->inputMediaKeys; bleKeyboardInstance->outputKeyboard->setCallbacks(new KeyboardOutputCallbacks());