Button initiated config service
Dependencies: BLE_API_EddystoneConfigService_2 mbed nRF51822
Fork of BLE_EddystoneBeaconConfigService_3 by
Diff: EddystoneConfigService.h
- Revision:
- 33:8c65879e7d52
- Parent:
- 32:985642364cf5
- Child:
- 34:5876fbb1aa62
--- a/EddystoneConfigService.h Mon Jul 27 21:00:35 2015 +0000 +++ b/EddystoneConfigService.h Mon Jul 27 21:44:07 2015 +0000 @@ -14,12 +14,15 @@ * limitations under the License. */ -#ifndef SERVICES_ZIPBEACONCONFIGSERVICE_H_ -#define SERVICES_ZIPBEACONCONFIGSERVICE_H_ +#ifndef SERVICES_EDDYSTONEBEACONCONFIGSERVICE_H_ +#define SERVICES_EDDYSTONEBEACONCONFIGSERVICE_H_ #include "mbed.h" #include "ble/BLE.h" +#define EDDYSTONE_NUM_UID_FRAMES 10 +#define EDDYSTONE_NUM_URL_FRAMES 50 + #define UUID_URI_BEACON(FIRST, SECOND) { \ 0xee, 0x0c, FIRST, SECOND, 0x87, 0x86, 0x40, 0xba, \ @@ -98,7 +101,7 @@ struct Params_t { Lock_t lock; - uint8_t uriDataLength; + size_t uriDataLength; UriData_t uriData; uint8_t flags; PowerLevels_t advPowerLevels; // Current value of AdvertisedPowerLevels @@ -301,8 +304,8 @@ */ bool setURLFrameData(int8_t power, const char * url) { defaultUrlPower = power; - encodeURI(url, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting - if (defaultUriDataLength > URI_DATA_MAX) { + encodeURI(url, params.uriData, params.uriDataLength); // encode URL to URL Formatting + if (params.uriDataLength > URI_DATA_MAX) { return true; // error, URL is too big } return false; @@ -318,8 +321,8 @@ int index = 0; Data[index++] = FRAME_TYPE_URL; // 1B Type Data[index++] = defaultUrlPower; // 1B TX Power - for(int x = 0; x < defaultUriDataLength; x++) { // 18B of URL Prefix + encoded URL - Data[index++] = defaultUriData[x]; + for(int x = 0; x < params.uriDataLength; x++) { // 18B of URL Prefix + encoded URL + Data[index++] = params.uriData[x]; } DBG("constructURLFrame: %d, %d",maxSize,index); return index; @@ -422,11 +425,11 @@ bool updateAdvPacket(uint8_t serviceData[], unsigned serviceDataLen) { // Fields from the Service DBG("Updating AdvFrame: %d", serviceDataLen); -// printf("\r\n"); -// for(int x = 0; x<serviceDataLen; x++) { -// printf("%2.2x:",serviceData[x]); -// } -// printf("\r\n"); + INFO("\r\n"); + for(int x = 0; x<serviceDataLen; x++) { + INFO("%2.2x:",serviceData[x]); + } + INFO("\r\n"); ble.clearAdvertisingPayload(); ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED | GapAdvertisingData::LE_GENERAL_DISCOVERABLE); ble.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_16BIT_SERVICE_IDS, BEACON_EDDYSTONE, sizeof(BEACON_EDDYSTONE)); @@ -507,7 +510,7 @@ switchFrame.attach_us(this, &EddystoneConfigService::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS); switchFlag = false; } else { - if((TlmPduCount % 10) == 0) { // every 10 adv packets switch the frame + if((TlmPduCount % EDDYSTONE_NUM_URL_FRAMES) == 0) { // every 10 adv packets switch the frame switchFlag = true; } } @@ -518,7 +521,7 @@ switchFrame.attach_us(this, &EddystoneConfigService::swapOutFrames, EDDYSTONE_SWAPFRAME_DELAYMS); switchFlag = false; } else { - if((TlmPduCount % 10) == 0) { // every 10 adv packets switch the frame + if((TlmPduCount % EDDYSTONE_NUM_UID_FRAMES) == 0) { // every 10 adv packets switch the frame switchFlag = true; } } @@ -914,4 +917,4 @@ } }; -#endif // SERVICES_ZIPBEACONCONFIGSERVICE_H_ +#endif // SERVICES_EDDYSTONEBEACONCONFIGSERVICE_H_