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.
Fork of BLE_API by
Revision 167:8057dc59ac08, committed 2014-11-28
- Comitter:
- rgrover1
- Date:
- Fri Nov 28 14:11:22 2014 +0000
- Parent:
- 166:a03959283d48
- Child:
- 168:585a7ed020e1
- Commit message:
- Synchronized with git rev 178df43c
Author: Rohit Grover
add beaconPeriodCharacteristic
Changed in this revision
| services/URIBeacon2Service.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/services/URIBeacon2Service.h Fri Nov 28 14:11:21 2014 +0000
+++ b/services/URIBeacon2Service.h Fri Nov 28 14:11:22 2014 +0000
@@ -46,8 +46,10 @@
MAX_SIZE_URI_DATA_CHAR_VALUE,
MAX_SIZE_URI_DATA_CHAR_VALUE,
GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE_WITHOUT_RESPONSE),
- flagsChar(flagsCharUUID, &flags, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)
+ flagsChar(flagsCharUUID, &flags, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE),
// txPowerChar(txPowerCharUUID, &power, 1, 1, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)
+ beaconPeriodChar(beaconPeriodCharUUID, (uint8_t *)&beaconPeriod, 2, 2,
+ GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)
{
if ((urldata == NULL) || ((uriDataLength = strlen(urldata)) == 0)) {
return;
@@ -61,7 +63,7 @@
return;
}
- GattCharacteristic *charTable[] = {&lockedStateChar, &uriDataChar, &flagsChar};
+ GattCharacteristic *charTable[] = {&lockedStateChar, &uriDataChar, &flagsChar, &beaconPeriodChar};
GattService beaconControlService(URIBeacon2ControlServiceUUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
ble.addService(beaconControlService);
@@ -98,6 +100,14 @@
} else {
flags = *(params->data);
}
+ } else if (params->charHandle == beaconPeriodChar.getValueAttribute().getHandle()) {
+ if (lockedState) { /* When locked, the device isn't allowed to update the flags characteristic. */
+ /* Restore GATT database with previous value. */
+ ble.updateCharacteristicValue(beaconPeriodChar.getValueAttribute().getHandle(), (uint8_t *)&beaconPeriod, 2 /* size */);
+ return;
+ } else {
+ beaconPeriod = *((uint16_t *)(params->data));
+ }
}
setup();
ble.setAdvertisingPayload();
@@ -231,6 +241,7 @@
GattCharacteristic uriDataChar;
GattCharacteristic flagsChar;
// GattCharacteristic txPowerChar;
+ GattCharacteristic beaconPeriodChar;
};
#endif /* #ifndef __BLE_URI_BEACON_2_SERVICE_H__*/
\ No newline at end of file
