Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: microbit-dal microbit-dal microbit-ble-open microbit-dal ... more
Fork of BLE_API by
Diff: services/URIBeacon2Service.h
- Revision:
- 149:6a7666d72a83
- Parent:
- 148:0072d73e966f
- Child:
- 150:aa2d70369df0
diff -r 0072d73e966f -r 6a7666d72a83 services/URIBeacon2Service.h
--- 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),
