Fixes to BLE_API for mbedOS Alpha1 release. Mostly relating to doxygen fixes.

Fork of BLE_API by Bluetooth Low Energy

Revision:
185:7cd70497aec8
Parent:
184:ec211f2288ef
Child:
186:ce34008cea95
diff -r ec211f2288ef -r 7cd70497aec8 services/URIBeacon2Service.h
--- a/services/URIBeacon2Service.h	Fri Nov 28 14:11:23 2014 +0000
+++ b/services/URIBeacon2Service.h	Fri Nov 28 14:11:24 2014 +0000
@@ -165,68 +165,6 @@
         ble.onDataWritten(this, &URIBeacon2Service::onDataWritten);
     }
 
-protected:
-    /**
-     * This callback allows the DFU service to receive the initial trigger to
-     * handover control to the bootloader; but first the application is given a
-     * chance to clean up.
-     */
-    virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
-        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(), uriDataValue, uriDataLength);
-                return;
-            }
-
-            /* We don't handle very large writes at the moment. */
-            if ((params->offset != 0) || (params->len > MAX_SIZE_URI_DATA_CHAR_VALUE)) {
-                return;
-            }
-
-            uriDataLength = params->len;
-            memcpy(uriDataValue, params->data, uriDataLength);
-        } 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 */);
-                return;
-            } else {
-                flags = *(params->data);
-            }
-        } else if (params->charHandle == txPowerLevelsChar.getValueAttribute().getHandle()) {
-            if (lockedState) { /* When locked, the device isn't allowed to update the characteristic. */
-                /* Restore GATT database with previous value. */
-                ble.updateCharacteristicValue(txPowerLevelsChar.getValueAttribute().getHandle(), reinterpret_cast<uint8_t *>(powerLevels), NUM_POWER_MODES * sizeof(int8_t));
-                return;
-            } else {
-                memcpy(powerLevels, params->data, NUM_POWER_MODES * sizeof(int8_t));
-            }
-        } 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(), (uint8_t *)&beaconPeriod, 2 /* size */);
-                return;
-            } else {
-                beaconPeriod = *((uint16_t *)(params->data));
-            }
-        }
-        configure();
-        ble.setAdvertisingPayload();
-    }
-
-    /**
-     * For debugging only.
-     */
-    void dumpEncodedSeviceData() const {
-        printf("encoded: '");
-        for (unsigned i = 0; i < payloadIndex; i++) {
-            printf(" %02x", serviceDataPayload[i]);
-        }
-        printf("'\r\n");
-    }
-
-private:
     void configure(void) {
         const uint8_t BEACON_UUID[] = {0xD8, 0xFE};
 
@@ -326,6 +264,67 @@
         return encodedBytes;
     }
 
+    /**
+     * This callback allows the DFU service to receive the initial trigger to
+     * handover control to the bootloader; but first the application is given a
+     * chance to clean up.
+     */
+    virtual void onDataWritten(const GattCharacteristicWriteCBParams *params) {
+        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(), uriDataValue, uriDataLength);
+                return;
+            }
+
+            /* We don't handle very large writes at the moment. */
+            if ((params->offset != 0) || (params->len > MAX_SIZE_URI_DATA_CHAR_VALUE)) {
+                return;
+            }
+
+            uriDataLength = params->len;
+            memcpy(uriDataValue, params->data, uriDataLength);
+        } 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 */);
+                return;
+            } else {
+                flags = *(params->data);
+            }
+        } else if (params->charHandle == txPowerLevelsChar.getValueAttribute().getHandle()) {
+            if (lockedState) { /* When locked, the device isn't allowed to update the characteristic. */
+                /* Restore GATT database with previous value. */
+                ble.updateCharacteristicValue(txPowerLevelsChar.getValueAttribute().getHandle(), reinterpret_cast<uint8_t *>(powerLevels), NUM_POWER_MODES * sizeof(int8_t));
+                return;
+            } else {
+                memcpy(powerLevels, params->data, NUM_POWER_MODES * sizeof(int8_t));
+            }
+        } 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(), (uint8_t *)&beaconPeriod, 2 /* size */);
+                return;
+            } else {
+                beaconPeriod = *((uint16_t *)(params->data));
+            }
+        }
+        configure();
+        ble.setAdvertisingPayload();
+    }
+
+private:
+    /**
+     * For debugging only.
+     */
+    void dumpEncodedSeviceData() const {
+        printf("encoded: '");
+        for (unsigned i = 0; i < payloadIndex; i++) {
+            printf(" %02x", serviceDataPayload[i]);
+        }
+        printf("'\r\n");
+    }
+
 private:
     static const size_t MAX_SIZEOF_SERVICE_DATA_PAYLOAD = 27;
     static const size_t MAX_SIZE_URI_DATA_CHAR_VALUE    = 48;