Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.

Fork of BLE_API by Bluetooth Low Energy

Revision:
312:e2e52a7477bf
Parent:
311:11417b970b12
Child:
313:c4599a1aba23
diff -r 11417b970b12 -r e2e52a7477bf services/URIBeaconConfigService.h
--- a/services/URIBeaconConfigService.h	Mon Mar 09 16:23:55 2015 +0000
+++ b/services/URIBeaconConfigService.h	Mon Mar 09 16:23:55 2015 +0000
@@ -51,7 +51,7 @@
     static const uint8_t TX_POWER_MODE_HIGH   = 3; /*!< High TX power mode */
     static const unsigned int NUM_POWER_MODES = 4; /*!< Number of Power Modes defined */
 
-    static const int ADVERTISING_TIMEOUT_SECONDS = 60;  // Seconds after power-on that config service is available.
+    static const int CONFIG_ADVERTISING_TIMEOUT_SECONDS = 60;  // Seconds after power-on that config service is available.
     static const int ADVERTISING_INTERVAL_MSEC = 1000;  // Advertising interval for config service.
     static const int SERVICE_DATA_MAX = 31;             // Maximum size of service data in ADV packets
 
@@ -69,6 +69,9 @@
         PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels
         uint8_t       txPowerMode;    // Firmware power levels used with setTxPower()
         uint16_t      beaconPeriod;
+        uint32_t      persistenceSignature; /* This isn't really a parameter, but having the expected magic value in
+                                             * this field indicates persistence. */
+        static const uint32_t MAGIC = 0x1BEAC000; // Magic that identifies persistence
     };
 
     /**
@@ -77,8 +80,6 @@
      * @param[in/out] paramsIn
      *                    Reference to application-visible beacon state, loaded
      *                    from persistent storage at startup.
-     * @param[in]     resetToDefaultsFlag
-     *                    reset params state to the defaults.
      * @param[in]     defaultUriDataIn
      *                    Default un-encoded URI; applies only if the resetToDefaultsFlag is true.
      * @param[in]     defaultAdvPowerLevelsIn
@@ -86,7 +87,6 @@
      */
     URIBeaconConfigService(BLEDevice     &bleIn,
                            Params_t      &paramsIn,
-                           bool          resetToDefaultsFlag,
                            const char   *defaultURIDataIn,
                            PowerLevels_t &defaultAdvPowerLevelsIn) :
         ble(bleIn),
@@ -113,7 +113,8 @@
             return;
         }
 
-        if (params.uriDataLength > URI_DATA_MAX) {
+        bool resetToDefaultsFlag = params.persistenceSignature != Params_t::MAGIC;
+        if (!resetToDefaultsFlag && (params.uriDataLength > URI_DATA_MAX)) {
             resetToDefaultsFlag = true;
         }
 
@@ -166,7 +167,7 @@
         ble.clearAdvertisingPayload();
 
         // Stops advertising the UriBeacon Config Service after a delay
-        configAdvertisementTimeoutTicker.attach(this, &URIBeaconConfigService::timeout, ADVERTISING_TIMEOUT_SECONDS);
+        configAdvertisementTimeoutTicker.attach(this, &URIBeaconConfigService::timeout, CONFIG_ADVERTISING_TIMEOUT_SECONDS);
 
         ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE);