For switch science magazine

Dependencies:   BLE_API mbed nRF51822

Fork of mbed_EddystoneURL_Beacon by Roy Want

Revision:
1:0ad7573b5918
Parent:
0:094734b4e8bd
Child:
2:420532c6dd54
--- a/main.cpp	Mon Aug 17 04:41:01 2015 +0000
+++ b/main.cpp	Tue Aug 18 00:45:39 2015 +0000
@@ -16,35 +16,35 @@
 
 #include "mbed.h"
 #include "ble/BLE.h"
-#include "ble/services/URIBeaconConfigService.h"
+#include "ble/services/EddystoneURLConfigService.h"
 #include "ble/services/DFUService.h"
 #include "ble/services/DeviceInformationService.h"
 #include "ConfigParamsPersistence.h"
 
 BLE ble;
-URIBeaconConfigService *uriBeaconConfig;
+EddystoneURLConfigService *eddystoneUrlConfig;
 
 /**
- * URIBeaconConfig service can operate in two modes: a configuration mode which
- * allows a user to update settings over a connection; and normal URIBeacon mode
- * which involves advertising a URI. Constructing an object from URIBeaconConfig
- * service sets up advertisements for the configuration mode. It is then up to
- * the application to switch to URIBeacon mode based on some timeout.
+ * Eddystone-URL beacons can operate in two modes: a configuration mode which
+ * allows a user to update settings over a connection; and normal Eddystone URL Beacon mode
+ * which involves advertising a URI. Constructing an object from the EddystoneURLConfigService
+ * sets up advertisements for the configuration mode. It is then up to
+ * the application to switch to the Eddystone-URL beacon mode based on some timeout.
  *
  * The following help with this switch.
  */
-static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 60;  // Duration after power-on that config service is available.
+static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 15;  // Duration after power-on that config service is available.
 Ticker configAdvertisementTimeoutTicker;
 
 /**
- * Stop advertising the UriBeaconConfig Service after a delay; and switch to normal URIBeacon.
+ * Stop advertising the Eddystone URL Config Service after a delay; and switch to normal Eddystone-URL advertisements.
  */
 void timeout(void)
 {
     Gap::GapState_t state;
     state = ble.getGapState();
     if (!state.connected) { /* don't switch if we're in a connected state. */
-        uriBeaconConfig->setupURIBeaconAdvertisements();
+        eddystoneUrlConfig->setupEddystoneURLAdvertisements();
         ble.startAdvertising();
 
         configAdvertisementTimeoutTicker.detach(); /* disable the callback from the timeout Ticker. */
@@ -66,28 +66,28 @@
 
     /*
      * Load parameters from (platform specific) persistent storage. Parameters
-     * can be set to non-default values while the URIBeacon is in configuration
+     * can be set to non-default values while the Eddystone-URL beacon is in configuration
      * mode (within the first 60 seconds of power-up). Thereafter, parameters
-     * get copied out to persistent storage before switching to normal URIBeacon
+     * get copied out to persistent storage before switching to normal EddystoneURL
      * operation.
      */
-    URIBeaconConfigService::Params_t params;
-    bool fetchedFromPersistentStorage = loadURIBeaconConfigParams(&params);
+    EddystoneURLConfigService::Params_t params;
+    bool fetchedFromPersistentStorage = loadEddystoneURLConfigParams(&params);
 
-    /* Initialize a URIBeaconConfig service providing config params, default URI, and power levels. */
-    static URIBeaconConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels
-    uriBeaconConfig = new URIBeaconConfigService(ble, params, !fetchedFromPersistentStorage, "http://uribeacon.org", defaultAdvPowerLevels);
-    if (!uriBeaconConfig->configuredSuccessfully()) {
+    /* Initialize a Eddystone URL Config service providing config params, default URI, and power levels. */
+    static EddystoneURLConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels
+    eddystoneUrlConfig= new EddystoneURLConfigService(ble, params, !fetchedFromPersistentStorage, "http://physical-web.org", defaultAdvPowerLevels);
+    if (!eddystoneUrlConfig->configuredSuccessfully()) {
         error("failed to accommodate URI");
     }
     configAdvertisementTimeoutTicker.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");
+    DeviceInformationService deviceInfo(ble, "ARM", "Eddystone-URL", "SN1", "hw-rev1", "fw-rev1", "soft-rev1");
 
-    ble.startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the URIBeaconConfig
-                             * service. This can then be switched to the normal URIBeacon functionality after a timeout. */
+    ble.startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the EddystoneURLConfig
+                             * service. This can then be switched to the normal Eddystone-URL beacon functionality after a timeout. */
 
     while (true) {
         ble.waitForEvent();