Lightly modified version of the BLE stack, that doesn't bring up a DFUService by default... as we have our own.
Fork of BLE_API by
Diff: services/URIBeacon2Service.h
- Revision:
- 149:6a7666d72a83
- Parent:
- 148:0072d73e966f
- Child:
- 150:aa2d70369df0
--- a/services/URIBeacon2Service.h Fri Nov 28 14:11:19 2014 +0000 +++ b/services/URIBeacon2Service.h Fri Nov 28 14:11:19 2014 +0000 @@ -47,6 +47,15 @@ return 0; } + size_t encodedBytes = encodePrefix(urldata, sizeofURLData); + + /* memcpy the rest for now. */ + memcpy(&payload[payloadIndex], urldata, sizeofURLData); + encodedBytes += sizeofURLData; + return encodedBytes; + } + + size_t encodePrefix(const char *&urldata, size_t &sizeofURLData) { const char *prefixes[] = { "http://www.", "https://www.", @@ -54,14 +63,14 @@ "https://", "urn:uuid:" }; + size_t encodedBytes = 0; - const size_t NUM_PREFIXES = sizeof(prefixes) / sizeof(char *); for (unsigned i = 0; i < NUM_PREFIXES; i++) { size_t prefixLen = strlen(prefixes[i]); if (strncmp(urldata, prefixes[i], prefixLen) == 0) { payload[payloadIndex++] = i; - ++encodedBytes; + encodedBytes = 1; urldata += prefixLen; sizeofURLData -= prefixLen; @@ -69,14 +78,9 @@ } } - memcpy(&payload[payloadIndex], urldata, sizeofURLData); - encodedBytes += sizeofURLData; - return encodedBytes; } - // size_t encodePrefix(const char *&urldata, ) - // URIBeacon2Service(BLEDevice &_ble, uint8_t level = 100) : // ble(_ble), // batteryLevel(level),