Button initiated config service

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Revision:
67:345bc62c748d
Parent:
23:05e9bb3b13af
--- a/nrfConfigParamsPersistence.cpp	Thu Sep 24 00:19:02 2015 +0000
+++ b/nrfConfigParamsPersistence.cpp	Sun Oct 11 22:46:57 2015 +0000
@@ -41,6 +41,10 @@
 static PersistentParams_t persistentParams;
 
 static pstorage_handle_t pstorageHandle;
+extern int reboot;
+extern int dirty;
+extern void ledRebootAnimation();
+
 
 /**
  * Dummy callback handler needed by Nordic's pstorage module. This is called
@@ -52,23 +56,30 @@
                                          uint8_t           *p_data,
                                          uint32_t           data_len)
 {
+    if (dirty) {
+        ledRebootAnimation();
+        NVIC_SystemReset();
+    }
     /* APP_ERROR_CHECK(result); */
 }
 
+// ScottJ Routine Rohit asked to setup to reset storage callback after going into advertising mode
+void pstorageSetup() {
+    pstorage_init();
+    static pstorage_module_param_t pstorageParams = {
+        .cb          = pstorageNotificationCallback,
+        .block_size  = sizeof(PersistentParams_t),
+        .block_count = 1
+    };
+    pstorage_register(&pstorageParams, &pstorageHandle);
+}
 /* Platform-specific implementation for persistence on the nRF5x. Based on the
  * pstorage module provided by the Nordic SDK. */
 bool loadURIBeaconConfigParams(EddystoneConfigService::Params_t *paramsP)
 {
     static bool pstorageInitied = false;
     if (!pstorageInitied) {
-        pstorage_init();
-
-        static pstorage_module_param_t pstorageParams = {
-            .cb          = pstorageNotificationCallback,
-            .block_size  = sizeof(PersistentParams_t),
-            .block_count = 1
-        };
-        pstorage_register(&pstorageParams, &pstorageHandle);
+        pstorageSetup();
         pstorageInitied = true;
     }
 
@@ -87,7 +98,7 @@
  * pstorage module provided by the Nordic SDK. */
 void saveURIBeaconConfigParams(const EddystoneConfigService::Params_t *paramsP)
 {
-    memcpy(&persistentParams.params, paramsP, sizeof(EddystoneConfigService::Params_t));
+   memcpy(&persistentParams.params, paramsP, sizeof(EddystoneConfigService::Params_t));
     if (persistentParams.persistenceSignature != PersistentParams_t::MAGIC) {
         persistentParams.persistenceSignature = PersistentParams_t::MAGIC;
         pstorage_store(&pstorageHandle,