From 576c2fa65eae7889b88e86244ee5330ca4a39728 Mon Sep 17 00:00:00 2001 From: Rohit Grover Date: Fri, 28 Nov 2014 09:41:23 +0000 Subject: [PATCH] add failed to accommodate. --- services/URIBeacon2Service.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/services/URIBeacon2Service.h b/services/URIBeacon2Service.h index 1c63930..aea66e7 100644 --- a/services/URIBeacon2Service.h +++ b/services/URIBeacon2Service.h @@ -64,7 +64,11 @@ public: } static URIBeacon2Service service(ble_, urldata, flagsIn, effectiveTxPowerIn, beaconPeriodIn); - return &service; + if (!service.failedToAccomodate) { + return &service; + } + + return NULL; /* Oops. Failed to accommodate uridata within the advertising payload. */ } /** @@ -113,6 +117,7 @@ private: ble(ble_), payloadIndex(0), serviceDataPayload(), + failedToAccomodate(false), lockedState(false), uriDataLength(strlen(urldata)), uriDataValue(), @@ -300,6 +305,9 @@ private: --sizeofURLData; } } + if ((payloadIndex == MAX_SIZEOF_SERVICE_DATA_PAYLOAD) && (sizeofURLData != 0)) { + failedToAccomodate = true; + } return encodedBytes; } @@ -313,6 +321,8 @@ private: size_t payloadIndex; uint8_t serviceDataPayload[MAX_SIZEOF_SERVICE_DATA_PAYLOAD]; + bool failedToAccomodate; + bool lockedState; uint16_t uriDataLength; uint8_t uriDataValue[MAX_SIZE_URI_DATA_CHAR_VALUE];