Skip to content

Commit

Permalink
Merge pull request #16 from mwinters-stuff/master
Browse files Browse the repository at this point in the history
Fixes to media keys connect and disconnect.
  • Loading branch information
T-vK authored Feb 27, 2020
2 parents 5d6b157 + b64348d commit e43fdd6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions BleConnectionStatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ 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)
{
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);

}
1 change: 1 addition & 0 deletions BleConnectionStatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class BleConnectionStatus : public BLEServerCallbacks
void onDisconnect(BLEServer* pServer);
BLECharacteristic* inputKeyboard;
BLECharacteristic* outputKeyboard;
BLECharacteristic* inputMediaKeys;
};

#endif // CONFIG_BT_ENABLED
Expand Down
1 change: 1 addition & 0 deletions BleKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down

0 comments on commit e43fdd6

Please sign in to comment.