Button initiated config service

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Files at this revision

API Documentation at this revision

Comitter:
scottjenson
Date:
Mon Oct 12 21:18:21 2015 +0000
Parent:
67:345bc62c748d
Commit message:
support for button initiated config (for nRFgo usb board and Seeed)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Oct 11 22:46:57 2015 +0000
+++ b/main.cpp	Mon Oct 12 21:18:21 2015 +0000
@@ -26,7 +26,7 @@
 EddystoneConfigService *EddystoneBeaconConfig;
 EddystoneConfigService::Params_t params;
 
-Serial pc(USBTX,USBRX);   // uncomment to use printf(...)
+//Serial pc(USBTX,USBRX);   // uncomment to use printf(...)
 
 #define TINYBLE false
 #define SEEEDARCH true
@@ -45,11 +45,10 @@
 int ledOn = 1;
 int ledOff = 0;
 
-InterruptIn button1(P0_17);
-InterruptIn mysw1(P0_18);
-DigitalOut ledRed(P0_12);
-DigitalOut ledGreen(P0_15);
-DigitalOut ledBlue(P0_16);
+InterruptIn button1(P0_18);
+DigitalOut ledRed(P0_16);
+DigitalOut ledGreen(P0_12);
+DigitalOut ledBlue(P0_15);
 #endif
 
 // Make sure to turn off before and after animation
@@ -80,7 +79,7 @@
  *
  * The following help with this switch.
  */
-static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 10;  // Duration after power-on that config service is available.
+static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 30;  // Duration after power-on that config service is available.
 
 Ticker configAdvertisementTimeout;
 
@@ -117,7 +116,6 @@
 int dirty = false;  // global used to mark params is dirty and needs to be saved
 
 void handle_button1() {
-    printf("handle_button1\n\r");
     ble.gap().stopAdvertising();
     params.deepSleep = !params.deepSleep;
     dirty = true;
@@ -127,7 +125,6 @@
 
 int main(void)
 {
-    printf("main\n\r");
     ledRed = ledOff;
     ledGreen = ledOff;
     ledBlue = ledOff;
@@ -155,10 +152,10 @@
     //uint8_t tlmVersion = 0x00;
     
     /* Initialize a EddystoneBeaconConfig service providing config params, default URI, and power levels. */
-    static EddystoneConfigService::PowerLevels_t defaultAdvPowerLevels = {-47, -33, -21, -13}; // Values for ADV packets related to firmware levels, calibrated based on measured values at 1m
-    static EddystoneConfigService::PowerLevels_t radioPowerLevels =      {-30, -16, -4, 4};    // Values for radio power levels, provided by manufacturer.
+    static EddystoneConfigService::PowerLevels_t defaultAdvPowerLevels = {-48, -41, -35, -26}; // Values for ADV packets related to firmware levels, calibrated based on measured values at 1m
+    static EddystoneConfigService::PowerLevels_t radioPowerLevels =      {-20, -12, -4, 4};    // Values for radio power levels, provided by manufacturer.
     EddystoneBeaconConfig = new EddystoneConfigService(ble, params, defaultAdvPowerLevels, radioPowerLevels);
-    EddystoneBeaconConfig->setDefaultURIFrameData("http://mbed.org",2);
+    EddystoneBeaconConfig->setDefaultURIFrameData("http://physical-web.org",2);
     //EddystoneBeaconConfig->setDefaultUIDFrameData(&uidNamespaceID, &uidInstanceID,5);
     //EddystoneBeaconConfig->setDefaultTLMFrameData(tlmVersion,10);
     EddystoneBeaconConfig->start(!fetchedFromPersistentStorage);
@@ -167,7 +164,6 @@
         error("failed to accommodate URI");
     }
     if (!params.deepSleep) {
-        printf("deepSleep is false\n\r");
         ledRed = ledOn;
         configAdvertisementTimeout.attach(timeout, CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS);
         ble.gap().startAdvertising(); /* Set the whole thing in motion. After this call a GAP central can scan the EddystoneBeaconConfig
@@ -175,7 +171,6 @@
         void pstorageSetup();
     }
     else {
-        printf("deepSleep is true\n\r");
         ledRed = ledOff;
     }