Button initiated config service

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Revision:
31:11e7a505a4be
Parent:
25:e20bed9e466f
Child:
32:985642364cf5
--- a/EddystoneConfigService.h	Fri Jul 24 02:06:57 2015 +0000
+++ b/EddystoneConfigService.h	Mon Jul 27 18:15:14 2015 +0000
@@ -102,12 +102,9 @@
         PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels
         uint8_t       txPowerMode;    // Firmware power levels used with setTxPower()
         uint16_t      beaconPeriod;
-        uint8_t       tlmVersion;     // version of TLM packet
-        UIDNamespaceID_t uidNamespaceID; // UUID type, Namespace ID, 10B
-        UIDInstanceID_t  uidInstanceID;  // UUID type, Instance ID,  6B
-        int(*tlmGetBatt(void)); // Function Pointers for user provided functions that return the Temp and Battery Voltage data for the TLM field.
-        int(*tlmGetTemp(void)); // ^^
-
+        //uint8_t       tlmVersion;     // version of TLM packet
+        //UIDNamespaceID_t uidNamespaceID; // UUID type, Namespace ID, 10B
+        //UIDInstanceID_t  uidInstanceID;  // UUID type, Instance ID,  6B
     };
 
     /**
@@ -130,14 +127,28 @@
                            Params_t      &paramsIn,
                            bool          resetToDefaultsFlag,
                            const char   *defaultURIDataIn,
+                           UIDNamespaceID_t uidNamespaceID,
+                           UIDInstanceID_t  uidInstanceID,
+                           uint8_t tlmVersion,
                            PowerLevels_t &defaultAdvPowerLevelsIn) :
         ble(bleIn),
-        params(paramsIn),
+        params(paramsIn),       // Initialize URL Data
         defaultUriDataLength(),
         defaultUriData(),
+        //defaultUidNamespaceID(uidNamespaceID), // Initialize UID Data
+        //defaultUidInstanceID(uidInstanceID),
+        defaultUrlPower(params.advPowerLevels[params.txPowerMode]),
+        defaultUidPower(params.advPowerLevels[params.txPowerMode]),
+        uidIsSet(true),
+        urlIsSet(true),
         defaultAdvPowerLevels(defaultAdvPowerLevelsIn),
         initSucceeded(false),
         resetFlag(),
+        TlmVersion(tlmVersion), // Initialize TLM Data
+        TlmBatteryVoltage(0),
+        TlmBeaconTemp(0),
+        TlmPduCount(0),
+        TlmTimeSinceBoot(0),
         lockedStateChar(UUID_LOCK_STATE_CHAR, &lockedState),
         lockChar(UUID_LOCK_CHAR, &params.lock),
         uriDataChar(UUID_URI_DATA_CHAR, params.uriData, 0, URI_DATA_MAX,
@@ -147,8 +158,13 @@
         advPowerLevelsChar(UUID_ADV_POWER_LEVELS_CHAR, &params.advPowerLevels),
         txPowerModeChar(UUID_TX_POWER_MODE_CHAR, &params.txPowerMode),
         beaconPeriodChar(UUID_BEACON_PERIOD_CHAR, &params.beaconPeriod),
-        resetChar(UUID_RESET_CHAR, &resetFlag) {
-
+        resetChar(UUID_RESET_CHAR, &resetFlag) 
+        {
+        //Set UID frame
+        memcpy(defaultUidNamespaceID,uidNamespaceID,UID_NAMESPACEID_SIZE);
+        memcpy(defaultUidInstanceID,uidInstanceID,UID_INSTANCEID_SIZE);
+        
+        // Set URL Frame
         encodeURI(defaultURIDataIn, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting
         if (defaultUriDataLength > URI_DATA_MAX) {
             return;
@@ -513,7 +529,7 @@
 
     /*
     *   This function explicityly sets the parameters used by the Eddystone beacon.
-    *   this function should be used in leu of the config service.
+    *   this function can be used in leu of the config service.
     *
     *   @param bleIn ble object used to broadcast eddystone information
     *   @oaram beaconPeriodus is how often ble broadcasts are mde, in mili seconds
@@ -525,16 +541,16 @@
     *   @param tlmVersion version of telemetry data field to use (default to 0x00)
     *
     */
-    void setupEddystoneAdvertisements(  BLEDevice       &bleIn,
+    void setupEddystoneAdvertisements(  //BLEDevice       &bleIn,
                                         uint16_t        beaconPeriodus,
                                         uint8_t         txPowerLevel,
                                         uint8_t *       uidNamespaceID = NULL,
                                         uint8_t *       uidInstanceID = NULL,
                                         const char *    url = NULL,
                                         uint8_t         urlLen = 0,
-                                        uint8_t         tlmVersion = 0x00) :
-                                         ble(bleIn)
+                                        uint8_t         tlmVersion = 0x00)
      {
+       // ble = bleIn; // TODO, need to set the BLE variable to make this function standalone
         uint8_t serviceData[SERVICE_DATA_MAX];
         unsigned serviceDataLen = 0;
         ERR("This function is not fully implemented yet, dont use it!!");
@@ -549,7 +565,7 @@
             urlIsSet = true;
             setURLFrameData(txPowerLevel,url);
         } else {
-            uidIsSet = false;
+            urlIsSet = false;
         }
         // Default TLM frame to version 0x00, start all values at zero to be spec compliant.
         setTLMFrameData(tlmVersion, 0x00,0x00);
@@ -591,7 +607,7 @@
         DBG("Switching Config -> adv");
         uint8_t serviceData[SERVICE_DATA_MAX];
         unsigned serviceDataLen = 0;
-        unsigned beaconPeriod                                 = params.beaconPeriod;
+        unsigned beaconPeriod = params.beaconPeriod;
 
         // Initialize Frame transition
         frameIndex = 0;
@@ -691,9 +707,9 @@
         memcpy(params.advPowerLevels, defaultAdvPowerLevels, sizeof(PowerLevels_t));
         params.txPowerMode      = TX_POWER_MODE_LOW;
         params.beaconPeriod     = 1000;
-        memcpy(params.uidNamespaceID, defaultUidNamespaceID, UID_NAMESPACEID_SIZE);
-        memcpy(params.uidInstanceID,  defaultUidInstanceID,  UID_INSTANCEID_SIZE);
-        params.tlmVersion = 0;
+        //memcpy(params.uidNamespaceID, defaultUidNamespaceID, UID_NAMESPACEID_SIZE);
+        //memcpy(params.uidInstanceID,  defaultUidInstanceID,  UID_INSTANCEID_SIZE);
+        //params.tlmVersion = 0;
         updateCharacteristicValues();
     }
 
@@ -796,7 +812,7 @@
     uint8_t             lockedState;
     bool                initSucceeded;
     uint8_t             resetFlag;
-    bool switchFlag;
+    bool                switchFlag;
 
 // Private Variables for Telemetry Data
     uint8_t                      TlmVersion;