Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Diff: services/URIBeaconConfigService.h
- Revision:
- 403:f17326985627
- Parent:
- 325:501ad8b8bbe5
- Child:
- 404:ee77c39cda55
--- a/services/URIBeaconConfigService.h Wed May 13 08:51:10 2015 +0100
+++ b/services/URIBeaconConfigService.h Mon May 18 09:54:26 2015 +0100
@@ -260,6 +260,21 @@
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();
}
