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:
roywant
Date:
Wed Sep 09 22:00:54 2015 +0000
Parent:
37:22175faa76be
Child:
39:2c73bc1ff4f5
Commit message:
1) Updated characteristic values after internal params have been set - and now passes lock tests.; 2) Removed unused code associated with the previous zero lock representing the unlock state

Changed in this revision

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/EddystoneConfigService.h	Thu Sep 03 02:55:49 2015 +0000
+++ b/EddystoneConfigService.h	Wed Sep 09 22:00:54 2015 +0000
@@ -179,8 +179,6 @@
             updateCharacteristicValues();
         }
 
-        lockedState = isLocked();
-
         lockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::lockAuthorizationCallback);
         unlockChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::unlockAuthorizationCallback);
         uriDataChar.setWriteAuthorizationCallback(this, &EddystoneConfigService::uriDataWriteAuthorizationCallback);
@@ -283,12 +281,6 @@
     }
 
 private:
-// True if the lock bits are non-zero
-    bool isLocked() {
-        Lock_t testLock;
-        memset(testLock, 0, sizeof(Lock_t));
-        return memcmp(params.lock, testLock, sizeof(Lock_t));
-    }
 
     /*
      * This callback is invoked when a GATT client attempts to modify any of the
@@ -301,11 +293,10 @@
         if (handle == lockChar.getValueHandle()) {
             // Validated earlier
             memcpy(params.lock, writeParams->data, sizeof(Lock_t));
-            // use isLocked() in case bits are being set to all 0's
+            // Set the state to be locked by the lock code (note: zeros are a valid lock)
             params.lockedState = true;
         } else if (handle == unlockChar.getValueHandle()) {
             // Validated earlier
-            memset(params.lock, 0, sizeof(Lock_t));
             params.lockedState = false;
         } else if (handle == uriDataChar.getValueHandle()) {
             params.uriDataLength = writeParams->len;
@@ -342,6 +333,7 @@
         } else if (handle == resetChar.getValueHandle()) {
             resetToDefaults();
         }
+        updateCharacteristicValues();
     }
 
     /*
--- a/main.cpp	Thu Sep 03 02:55:49 2015 +0000
+++ b/main.cpp	Wed Sep 09 22:00:54 2015 +0000
@@ -32,7 +32,7 @@
  *
  * The following help with this switch.
  */
-static const int CONFIG_ADVERTISEMENT_TIMEOUT_SECONDS = 5;  // 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;
 
 /**