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

Fork of BLE_API by Bluetooth Low Energy

Revision:
188:9020a5ac80c8
Parent:
187:057c547facd2
Child:
189:a23091b54ab5
diff -r 057c547facd2 -r 9020a5ac80c8 services/URIBeacon2Service.h
--- a/services/URIBeacon2Service.h	Fri Nov 28 14:11:24 2014 +0000
+++ b/services/URIBeacon2Service.h	Fri Nov 28 14:11:24 2014 +0000
@@ -58,12 +58,12 @@
      * @return
      *     Pointer to the singleton uribeacon service if the initialization goes well; else NULL.
      */
-    static URIBeacon2Service *setup(BLEDevice &bleIn, const char *urlDataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) {
-        if ((urlDataIn == NULL) || (strlen(urlDataIn) == 0)) {
+    static URIBeacon2Service *setup(BLEDevice &bleIn, const char *uriDataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) {
+        if ((uriDataIn == NULL) || (strlen(uriDataIn) == 0)) {
             return NULL;
         }
 
-        static URIBeacon2Service service(bleIn, urlDataIn, flagsIn, effectiveTxPowerIn, beaconPeriodIn);
+        static URIBeacon2Service service(bleIn, uriDataIn, flagsIn, effectiveTxPowerIn, beaconPeriodIn);
         if (!service.failedToAccomodate) {
             return &service;
         }
@@ -127,13 +127,13 @@
     /**
      * Private constructor. We want a singleton.
      */
-    URIBeacon2Service(BLEDevice &bleIn, const char *urldataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) :
+    URIBeacon2Service(BLEDevice &bleIn, const char *uriDataIn, uint8_t flagsIn = 0, int8_t effectiveTxPowerIn = 0, uint16_t beaconPeriodIn = 1000) :
         ble(bleIn),
         payloadIndex(0),
         serviceDataPayload(),
         failedToAccomodate(false),
         lockedState(false),
-        uriDataLength(strlen(urldataIn)),
+        uriDataLength(strlen(uriDataIn)),
         uriData(),
         flags(flagsIn),
         effectivePower(effectiveTxPowerIn),
@@ -154,9 +154,16 @@
         beaconPeriodChar(beaconPeriodCharUUID, reinterpret_cast<uint8_t *>(&beaconPeriod), 2, 2,
                          GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE)
     {
-        strncpy(reinterpret_cast<char *>(uriData), urldataIn, MAX_SIZE_URI_DATA_CHAR_VALUE);
+        strncpy(reinterpret_cast<char *>(uriData), uriDataIn, MAX_SIZE_URI_DATA_CHAR_VALUE);
 
         configure();
+        if (!failedToAccomodate) {
+            /* Preserve the originals to be able to reset() upon request. */
+            // memcpy(service.originalURIData, urlDataIn, MAX_SIZE_URI_DATA_CHAR_VALUE);
+            // service.originalFlags            = flagsIn;
+            // service.originalEffectiveTxPower = effectiveTxPowerIn;
+            // service.originalBeaconPeriod     = beaconPeriodIn;
+        }
 
         GattCharacteristic *charTable[] = {&lockedStateChar, &uriDataChar, &flagsChar, &txPowerLevelsChar, &beaconPeriodChar};
         GattService         beaconControlService(URIBeacon2ControlServiceUUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
@@ -347,6 +354,10 @@
     int8_t   powerLevels[NUM_POWER_MODES];
     uint16_t beaconPeriod;
 
+    uint8_t  originalURIData[MAX_SIZE_URI_DATA_CHAR_VALUE];
+    uint8_t  originalFlags;
+    int8_t   originalEffectivePower;
+
     GattCharacteristic lockedStateChar;
     GattCharacteristic uriDataChar;
     GattCharacteristic flagsChar;