Button initiated config service

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Revision:
24:8edfe6730cc2
Parent:
23:05e9bb3b13af
Child:
26:2896fbdd0450
Child:
31:11e7a505a4be
diff -r 05e9bb3b13af -r 8edfe6730cc2 main.cpp
--- a/main.cpp	Thu Jul 23 20:17:11 2015 +0000
+++ b/main.cpp	Thu Jul 23 20:38:20 2015 +0000
@@ -22,7 +22,7 @@
 #include "ConfigParamsPersistence.h"
 
 BLE ble;
-EddystoneConfigService *zipBeaconConfig;
+EddystoneConfigService *EddystoneBeaconConfig;
 Ticker test;
 //InterruptIn button(p17);
 
@@ -36,7 +36,7 @@
  * The following help with this switch.
  */
 static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 5;  // Duration after power-on that config service is available.
-Ticker configAdvertisementTimeoutTicker;
+Ticker configAdvertisementTimeout;
 
 /**
  * Stop advertising the Config Service after a delay; and switch to a non-connectable advertising mode only beacon.
@@ -46,12 +46,9 @@
     Gap::GapState_t state;
     state = ble.getGapState();
     if (!state.connected) { /* don't switch if we're in a connected state. */
-        zipBeaconConfig->setupEddystoneAdvertisements();
-        ble.gap().startAdvertising();
-
-        configAdvertisementTimeoutTicker.detach(); /* disable the callback from the timeout Ticker. */
+        EddystoneBeaconConfig->setupEddystoneAdvertisements();
+        configAdvertisementTimeout.detach(); /* disable the callback from the timeout Ticker. */
         printf("removing config service\r\n");
-        //test.attach(stupidWrapperFn,1);
     }
 }
 
@@ -80,19 +77,19 @@
     EddystoneConfigService::Params_t params;
     bool fetchedFromPersistentStorage = loadURIBeaconConfigParams(&params);
 
-    /* Initialize a zipBeaconConfig service providing config params, default URI, and power levels. */
+    /* Initialize a EddystoneBeaconConfig service providing config params, default URI, and power levels. */
     static EddystoneConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels
-    zipBeaconConfig = new EddystoneConfigService(ble, params, !fetchedFromPersistentStorage, "http://mbed.org", defaultAdvPowerLevels);
-    if (!zipBeaconConfig->configuredSuccessfully()) {
+    EddystoneBeaconConfig = new EddystoneConfigService(ble, params, !fetchedFromPersistentStorage, "http://mbed.org", defaultAdvPowerLevels);
+    if (!EddystoneBeaconConfig->configuredSuccessfully()) {
         error("failed to accommodate URI");
     }
-    configAdvertisementTimeoutTicker.attach(timeout, CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS);
+    configAdvertisementTimeout.attach(timeout, CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS);
 
     // Setup auxiliary services to allow over-the-air firmware updates, etc
     DFUService dfu(ble);
     DeviceInformationService deviceInfo(ble, "ARM", "UriBeacon", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
 
-    ble.gap().startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the zipBeaconConfig
+    ble.gap().startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the EddystoneBeaconConfig
                                    * service. This can then be switched to the normal URIBeacon functionality after a timeout. */
     printf("Running...\r\n");
     while (true) {