I don't know why this is happening.

Fork of BLE_API by Bluetooth Low Energy

Revision:
211:f181effe5de3
Parent:
210:0c14030d1bd0
Child:
212:852d45a52016
diff -r 0c14030d1bd0 -r f181effe5de3 services/URIBeaconConfigService.h
--- a/services/URIBeaconConfigService.h	Mon Dec 01 14:31:18 2014 +0000
+++ b/services/URIBeaconConfigService.h	Mon Dec 01 14:31:18 2014 +0000
@@ -130,6 +130,7 @@
     void setFlags(uint8_t flagsIn) {
         flags = flagsIn;
         configureGAP();
+        updateFlagsCharacteristic();
     }
 
     /**
@@ -155,6 +156,7 @@
     void setBeaconPeriod(uint16_t beaconPeriodIn) {
         beaconPeriod = beaconPeriodIn;
         configureGAP();
+        updateBeaconPeriodCharacteristic();
     }
 
 private:
@@ -264,7 +266,7 @@
         if (params->charHandle == uriDataChar.getValueAttribute().getHandle()) {
             if (lockedState) { /* When locked, the device isn't allowed to update the uriData characteristic. */
                 /* Restore GATT database with previous value. */
-                ble.updateCharacteristicValue(uriDataChar.getValueAttribute().getHandle(), uriData, uriDataLength);
+                updateURIDataCharacteristic();
                 return;
             }
 
@@ -278,7 +280,7 @@
         } else if (params->charHandle == flagsChar.getValueAttribute().getHandle()) {
             if (lockedState) { /* When locked, the device isn't allowed to update the characteristic. */
                 /* Restore GATT database with previous value. */
-                ble.updateCharacteristicValue(flagsChar.getValueAttribute().getHandle(), &flags, 1 /* size */);
+                updateFlagsCharacteristic();
                 return;
             } else {
                 flags = *(params->data);
@@ -294,7 +296,7 @@
         } else if (params->charHandle == beaconPeriodChar.getValueAttribute().getHandle()) {
             if (lockedState) { /* When locked, the device isn't allowed to update the characteristic. */
                 /* Restore GATT database with previous value. */
-                ble.updateCharacteristicValue(beaconPeriodChar.getValueAttribute().getHandle(), reinterpret_cast<uint8_t *>(&beaconPeriod), sizeof(uint16_t));
+                updateBeaconPeriodCharacteristic();
                 return;
             } else {
                 beaconPeriod = *((uint16_t *)(params->data));
@@ -321,8 +323,24 @@
         effectiveTxPower = defaultEffectiveTxPower;
         beaconPeriod     = defaultBeaconPeriod;
 
+        updateGATT();
+    }
+
+    void updateGATT(void) {
+        updateURIDataCharacteristic();
+        updateFlagsCharacteristic();
+        updateBeaconPeriodCharacteristic();
+    }
+
+    void updateURIDataCharacteristic(void) {
         ble.updateCharacteristicValue(uriDataChar.getValueAttribute().getHandle(), uriData, uriDataLength);
+    }
+
+    void updateFlagsCharacteristic(void) {
         ble.updateCharacteristicValue(flagsChar.getValueAttribute().getHandle(), &flags, 1 /* size */);
+    }
+
+    void updateBeaconPeriodCharacteristic(void) {
         ble.updateCharacteristicValue(beaconPeriodChar.getValueAttribute().getHandle(), reinterpret_cast<uint8_t *>(&beaconPeriod), sizeof(uint16_t));
     }