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:
mbedAustin
Date:
Thu Sep 17 20:23:46 2015 +0000
Parent:
54:4418b24f2506
Child:
56:f95c72f9c504
Commit message:
Added radioPowerLevels array so you can set the radio power and advertisement frame tx power level field separately.

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
EddystoneConfigService.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/BLE_API.lib	Wed Sep 16 17:29:51 2015 +0000
+++ b/BLE_API.lib	Thu Sep 17 20:23:46 2015 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/teams/URIBeacon/code/BLE_API_eddystoneConfig/#417c5b9f6cb7
+https://developer.mbed.org/teams/URIBeacon/code/BLE_API_eddystoneConfig/#f06e4d6bbcdc
--- a/EddystoneConfigService.h	Wed Sep 16 17:29:51 2015 +0000
+++ b/EddystoneConfigService.h	Thu Sep 17 20:23:46 2015 +0000
@@ -123,7 +123,8 @@
      */
     EddystoneConfigService(BLEDevice     &bleIn,
                            Params_t      &paramsIn,
-                           PowerLevels_t &defaultAdvPowerLevelsIn) :
+                           PowerLevels_t &defaultAdvPowerLevelsIn,
+                           PowerLevels_t &radioPowerLevelsIn) :
         ble(bleIn),
         params(paramsIn),       // Initialize URL Data
         defaultUriDataLength(0),
@@ -133,6 +134,7 @@
         defaultUrlPower(defaultAdvPowerLevelsIn[params.txPowerMode]),
         defaultUidPower(defaultAdvPowerLevelsIn[params.txPowerMode]),
         defaultAdvPowerLevels(defaultAdvPowerLevelsIn),
+        radioPowerLevels(radioPowerLevelsIn),
         initSucceeded(false),
         resetFlag(),
         tlmIsSet(false),
@@ -284,7 +286,7 @@
             reinterpret_cast<uint8_t *>(&defaultAdvPowerLevels[EddystoneConfigService::TX_POWER_MODE_LOW]),
             sizeof(uint8_t));
 
-        ble.setTxPower(params.advPowerLevels[params.txPowerMode]);
+        ble.setTxPower(radioPowerLevels[params.txPowerMode]);
         ble.setDeviceName(reinterpret_cast<const uint8_t *>(&DEVICE_NAME));
         ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
         ble.setAdvertisingInterval(GapAdvertisingParams::MSEC_TO_ADVERTISEMENT_DURATION_UNITS(ADVERTISING_INTERVAL_MSEC));
@@ -301,7 +303,7 @@
         extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
         saveURIBeaconConfigParams(&params);
         // Setup Eddystone Service 
-        static EddystoneService eddyServ(ble,params.beaconPeriod,params.advPowerLevels[params.txPowerMode]);
+        static EddystoneService eddyServ(ble,params.beaconPeriod,radioPowerLevels[params.txPowerMode]);
         // Set configured frames (TLM,UID,URI...etc)
         if(params.tlmEnabled){
             eddyServ.setTLMFrameData(params.tlmVersion,params.tlmBeaconPeriod);
@@ -495,7 +497,8 @@
     Ticker              timeSinceBootTick;
     Timeout             switchFrame;
 // Default value that is restored on reset
-    PowerLevels_t       &defaultAdvPowerLevels;
+    PowerLevels_t       &defaultAdvPowerLevels; // this goes into the advertising frames (radio power measured at 1m from device)
+    PowerLevels_t       &radioPowerLevels;   // this configures the power levels of the radio
     uint8_t             lockedState;
     bool                initSucceeded;
     uint8_t             resetFlag;
--- a/main.cpp	Wed Sep 16 17:29:51 2015 +0000
+++ b/main.cpp	Thu Sep 17 20:23:46 2015 +0000
@@ -34,6 +34,7 @@
  * The following help with this switch.
  */
 static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 30;  // Duration after power-on that config service is available.
+
 Ticker configAdvertisementTimeout;
 
 /**
@@ -84,8 +85,9 @@
     uint8_t tlmVersion = 0x00;
     
     /* 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
-    EddystoneBeaconConfig = new EddystoneConfigService(ble, params, defaultAdvPowerLevels);
+    static EddystoneConfigService::PowerLevels_t defaultAdvPowerLevels = {-20, -4, 0, 10}; // Values for ADV packets related to firmware levels, calibrated based on measured values at 1m
+    static EddystoneConfigService::PowerLevels_t radioPowerLevels =      {-20, -4, 0, 10}; // Values for radio power levels, provided by manufacturer.
+    EddystoneBeaconConfig = new EddystoneConfigService(ble, params, defaultAdvPowerLevels, radioPowerLevels);
     EddystoneBeaconConfig->setDefaultURIFrameData("http://mbed.org",1000);
     EddystoneBeaconConfig->setDefaultUIDFrameData(&uidNamespaceID, &uidInstanceID,10);
     EddystoneBeaconConfig->setDefaultTLMFrameData(tlmVersion,1);