Adds a check to ensure power mode gets updated safely.

fixes #8
This commit is contained in:
Rohit Grover 2014-12-12 15:58:59 +00:00
parent 3baef00b9b
commit 22a54fcced

View file

@ -109,7 +109,7 @@ public:
uriDataChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::uriDataWriteAuthorizationCallback);
flagsChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::flagsAuthorizationCallback);
txPowerLevelsChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::denyGATTWritesIfLocked);
txPowerModeChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::denyGATTWritesIfLocked);
txPowerModeChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::powerModeAuthorizationCallback);
beaconPeriodChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::denyGATTWritesIfLocked);
resetChar.setWriteAuthorizationCallback(this, &URIBeaconConfigService::denyGATTWritesIfLocked);
@ -395,6 +395,12 @@ private:
}
}
void powerModeAuthorizationCallback(GattCharacteristicWriteAuthCBParams *params) {
if (lockedState || (*(params->data) >= NUM_POWER_MODES)) {
params->authorizationReply = false;
}
}
void denyGATTWritesIfLocked(GattCharacteristicWriteAuthCBParams *params) {
if (lockedState) {
params->authorizationReply = false;