Button initiated config service

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Revision:
32:985642364cf5
Parent:
31:11e7a505a4be
Child:
33:8c65879e7d52
--- a/EddystoneConfigService.h	Mon Jul 27 18:15:14 2015 +0000
+++ b/EddystoneConfigService.h	Mon Jul 27 21:00:35 2015 +0000
@@ -39,14 +39,16 @@
 static const uint8_t BEACON_EDDYSTONE[] = {0xAA, 0xFE};
 
 //Debug is disabled by default
-#if 0
+#if 1
 #define DBG(x, ...)  printf("[EddyStone: DBG]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
 #define WARN(x, ...) printf("[EddyStone: WARN]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
 #define ERR(x, ...)  printf("[EddyStone: ERR]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
+#define INFO(x, ...) printf(x, ##__VA_ARGS__) 
 #else
 #define DBG(x, ...) //wait_us(10);
 #define WARN(x, ...) //wait_us(10);
 #define ERR(x, ...)
+#define INFO(x, ...)
 #endif
 
 /**
@@ -608,6 +610,9 @@
         uint8_t serviceData[SERVICE_DATA_MAX];
         unsigned serviceDataLen = 0;
         unsigned beaconPeriod = params.beaconPeriod;
+        
+        setUIDFrameData(params.txPowerMode,defaultUidNamespaceID, defaultUidInstanceID);
+        //setURLFrameData(params.txPowerMode,(char *)params.uriData);
 
         // Initialize Frame transition
         frameIndex = 0;
@@ -618,20 +623,20 @@
         /* Reinitialize the BLE stack. This will clear away the existing services and advertising state. */
         ble.shutdown();
         ble.init();
-        ble.setTxPower(params.advPowerLevels[params.txPowerMode]);
+        ble.setTxPower(params.txPowerMode);
         ble.setAdvertisingType(GapAdvertisingParams::ADV_NON_CONNECTABLE_UNDIRECTED);
         ble.setAdvertisingInterval(beaconPeriod);
         extern void saveURIBeaconConfigParams(const Params_t *paramsP); /* forward declaration; necessary to avoid a circular dependency. */
         saveURIBeaconConfigParams(&params);
 
-        setTLMFrameData(0x00,0x2222,0x3333,0x01,0x02); // Initialize TLM Data, for testing, remove for release
+        //setTLMFrameData(0x00,0x2222,0x3333,0x01,0x02); // Initialize TLM Data, for testing, remove for release
         updateTlmPduCount(0);
         updateTlmTimeSinceBoot(0);
 
         // Construct TLM Frame in initial advertising.
         serviceData[serviceDataLen++] = BEACON_EDDYSTONE[0];
         serviceData[serviceDataLen++] = BEACON_EDDYSTONE[1];
-        serviceDataLen += constructURLFrame(serviceData+serviceDataLen,SERVICE_DATA_MAX);
+        serviceDataLen += constructTLMFrame(serviceData+serviceDataLen,SERVICE_DATA_MAX);
 
         updateAdvPacket(serviceData, serviceDataLen);
         ble.gap().startAdvertising();
@@ -667,12 +672,18 @@
         } else if (handle == uriDataChar.getValueHandle()) {
             params.uriDataLength = writeParams->len;
             memcpy(params.uriData, writeParams->data, params.uriDataLength);
+            //memcpy(defaultUriData, writeParams->data, params.uriDataLength);
+            //defaultUriDataLength = params.uriDataLength;
+            DBG("URI = %s, URILen = %d", writeParams->data, writeParams->len);
         } else if (handle == flagsChar.getValueHandle()) {
             params.flags = *(writeParams->data);
+            DBG("flagsChar = 0x%x",params.flags);
         } else if (handle == advPowerLevelsChar.getValueHandle()) {
             memcpy(params.advPowerLevels, writeParams->data, sizeof(PowerLevels_t));
+            DBG("PowerLevelsChar = %4x",writeParams->data);
         } else if (handle == txPowerModeChar.getValueHandle()) {
             params.txPowerMode = *(writeParams->data);
+            DBG("TxPowerModeChar = %d",params.txPowerMode);
         } else if (handle == beaconPeriodChar.getValueHandle()) {
             params.beaconPeriod = *((uint16_t *)(writeParams->data));