Scott Jenson / Mbed 2 deprecated BLE_EddystoneBeaconConfigService_Button

Dependencies:   BLE_API_EddystoneConfigService_2 mbed nRF51822

Fork of BLE_EddystoneBeaconConfigService_3 by URIBeacon

Revision:
58:87afe537345b
Parent:
56:f95c72f9c504
Child:
60:e9d8348e7397
--- a/EddystoneConfigService.h	Thu Sep 17 20:50:07 2015 +0000
+++ b/EddystoneConfigService.h	Fri Sep 18 03:57:09 2015 +0000
@@ -127,7 +127,7 @@
                            PowerLevels_t &radioPowerLevelsIn) :
         ble(bleIn),
         params(paramsIn),       // Initialize URL Data
-        defaultUriDataLength(0),
+        defaultUriDataLength(),
         defaultUriData(),
         defaultUidNamespaceID(), // Initialize UID Data
         defaultUidInstanceID(),
@@ -172,9 +172,10 @@
         }
         if (resetToDefaultsFlag) {
             resetToDefaults();
+        } else {
+            updateCharacteristicValues();
         }
-        updateCharacteristicValues();
-        
+
         lockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::lockAuthorizationCallback);
         unlockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::unlockAuthorizationCallback);
         uriDataChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::uriDataWriteAuthorizationCallback);
@@ -239,7 +240,10 @@
 //        if (defaultUriDataLength > URI_DATA_MAX) {
 //            return;
 //        }
-                memcpy(defaultUriData,uriIn,URI_DATA_MAX);
+        defaultUriDataLength = strlen(uriIn);
+        memcpy(defaultUriData,uriIn,URI_DATA_MAX);
+        //defaultUriDataLength = strlen(uriIn);
+        INFO("\t default URI = %s : %d", uriIn, defaultUriDataLength);
 //              defaultUriData = (UriData_t *)uriIn;
         defaultUriAdvPeriod = advPeriod;
         urlIsSet = true; // flag to add this to eddystone service when config is done
@@ -339,7 +343,7 @@
             INFO("Device Unlocked");
         } else if (handle == uriDataChar.getValueHandle()) {
             params.uriDataLength = writeParams->len;
-                      memset(params.uriData,0x00,URI_DATA_MAX); // clear URI string
+            memset(params.uriData,0x00,URI_DATA_MAX); // clear URI string
             memcpy(params.uriData, writeParams->data, params.uriDataLength); // set URI string
             params.uriEnabled = true;
             INFO("URI = %s, URILen = %d", writeParams->data, writeParams->len);
@@ -418,6 +422,7 @@
     void updateCharacteristicValues(void) {
         ble.updateCharacteristicValue(lockedStateChar.getValueHandle(), &params.lockedState, 1);
         ble.updateCharacteristicValue(uriDataChar.getValueHandle(), params.uriData, params.uriDataLength);
+        INFO("updating URI, %s : %d",params.uriData, params.uriDataLength);
         ble.updateCharacteristicValue(flagsChar.getValueHandle(), &params.flags, 1);
         ble.updateCharacteristicValue(beaconPeriodChar.getValueHandle(),
                                       reinterpret_cast<uint8_t *>(&params.beaconPeriod), sizeof(uint16_t));