URIBeaconConfigService: re-map incoming beacon advertisement interval within permissing bounds.
This commit is contained in:
parent
dcc18e3d18
commit
d1d6299841
1 changed files with 15 additions and 0 deletions
|
@ -260,6 +260,21 @@ class URIBeaconConfigService {
|
|||
params.txPowerMode = *(writeParams->data);
|
||||
} else if (handle == beaconPeriodChar.getValueHandle()) {
|
||||
params.beaconPeriod = *((uint16_t *)(writeParams->data));
|
||||
|
||||
/* Re-map beaconPeriod to within permissible bounds if necessary. */
|
||||
if (params.beaconPeriod != 0) {
|
||||
bool paramsUpdated = false;
|
||||
if (params.beaconPeriod < ble.getMinAdvertisingInterval()) {
|
||||
params.beaconPeriod = ble.getMinAdvertisingInterval();
|
||||
paramsUpdated = true;
|
||||
} else if (params.beaconPeriod > ble.getMaxAdvertisingInterval()) {
|
||||
params.beaconPeriod = ble.getMaxAdvertisingInterval();
|
||||
paramsUpdated = true;
|
||||
}
|
||||
if (paramsUpdated) {
|
||||
ble.updateCharacteristicValue(beaconPeriodChar.getValueHandle(), reinterpret_cast<uint8_t *>(¶ms.beaconPeriod), sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
} else if (handle == resetChar.getValueHandle()) {
|
||||
resetToDefaults();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue