
Button initiated config service
Dependencies: BLE_API_EddystoneConfigService_2 mbed nRF51822
Fork of BLE_EddystoneBeaconConfigService_3 by
Revision 19:f7c33fa88ca5, committed 2015-07-23
- Comitter:
- mbedAustin
- Date:
- Thu Jul 23 06:30:35 2015 +0000
- Parent:
- 18:91c36071aafb
- Child:
- 20:3b133cfafc39
- Commit message:
- [[Fix]] Fixed issue with UID where it would allow power outside the specified ranges. Added explicit enforcement to both the set function and the create payload function to enforce -20 to 100 as valid power levels.
Changed in this revision
ZipBeaconConfigService.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/ZipBeaconConfigService.h Thu Jul 23 06:02:45 2015 +0000 +++ b/ZipBeaconConfigService.h Thu Jul 23 06:30:35 2015 +0000 @@ -228,6 +228,8 @@ * */ void setUIDFrameData(int8_t power, UIDNamespaceID_t namespaceID, UIDInstanceID_t instanceID, uint16_t RFU = 0x0000) { + if(power > 20){power = 20;} + if(power < -100){power = -100;} defaultUidPower = power; memcpy(defaultUidNamespaceID, namespaceID, UID_NAMESPACEID_SIZE); memcpy(defaultUidInstanceID, instanceID, UID_INSTANCEID_SIZE); @@ -245,6 +247,8 @@ int index = 0; Data[index++] = FRAME_TYPE_UID; // 1B Type + if(defaultUidPower > 20){defaultUidPower = 20;} // enforce range of vaild values. + if(defaultUidPower < -100){defaultUidPower = -100;} Data[index++] = defaultUidPower; // 1B Power @ 0meter for(int x = 0; x < UID_NAMESPACEID_SIZE; x++) { // 10B Namespce ID Data[index++] = defaultUidNamespaceID[x]; @@ -252,7 +256,7 @@ for(int x = 0; x< UID_INSTANCEID_SIZE; x++) { // 6B Instance ID Data[index++] = defaultUidInstanceID[x]; } - if(0x00 != uidRFU) { // 2B RFU, include if non-zero, otherwise ignore + if(0 != uidRFU) { // 2B RFU, include if non-zero, otherwise ignore Data[index++] = (uint8_t)(uidRFU >> 8); Data[index++] = (uint8_t)uidRFU; } @@ -476,7 +480,6 @@ ZipBeaconConfigService::UriData_t &uriData = params.uriData; ZipBeaconConfigService::PowerLevels_t &advPowerLevels = params.advPowerLevels; - uint8_t flags = params.flags; // Initialize Frame transition frameIndex = 2; @@ -494,8 +497,8 @@ saveURIBeaconConfigParams(¶ms); setTLMFrameData(0x00,0x2222,0x3333,0x01,0x02); // Initialize TLM Data, for testing, remove for release - updateTlmPduCount(0x11); - updateTlmTimeSinceBoot(0x22); + updateTlmPduCount(0); + updateTlmTimeSinceBoot(0); // Construct TLM Frame in initial advertising. serviceData[serviceDataLen++] = BEACON_EDDYSTONE[0];
--- a/main.cpp Thu Jul 23 06:02:45 2015 +0000 +++ b/main.cpp Thu Jul 23 06:30:35 2015 +0000 @@ -46,7 +46,7 @@ } /** - * Stop advertising the UriBeaconConfig Service after a delay; and switch to normal URIBeacon. + * Stop advertising the Config Service after a delay; and switch to a non-connectable advertising mode only beacon. */ void timeout(void) {