BLE_API_Tiny_BLE
Fork of BLE_API by
Revision 256:a6e651374060, committed 2015-01-21
- Comitter:
- rgrover1
- Date:
- Wed Jan 21 09:32:48 2015 +0000
- Parent:
- 255:cdb7231f83df
- Child:
- 257:7a50601356cc
- Commit message:
- Synchronized with git rev 22a54fcc
Author: Rohit Grover
Adds a check to ensure power mode gets updated safely.
fixes #8
Changed in this revision
services/URIBeaconConfigService.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/services/URIBeaconConfigService.h Wed Jan 21 09:32:47 2015 +0000 +++ b/services/URIBeaconConfigService.h Wed Jan 21 09:32:48 2015 +0000 @@ -109,7 +109,7 @@ 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 @@ } } + void powerModeAuthorizationCallback(GattCharacteristicWriteAuthCBParams *params) { + if (lockedState || (*(params->data) >= NUM_POWER_MODES)) { + params->authorizationReply = false; + } + } + void denyGATTWritesIfLocked(GattCharacteristicWriteAuthCBParams *params) { if (lockedState) { params->authorizationReply = false;