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.
Fork of BLE_API by
Revision 149:6a7666d72a83, committed 2014-11-28
- Comitter:
- rgrover1
- Date:
- Fri Nov 28 14:11:19 2014 +0000
- Parent:
- 148:0072d73e966f
- Child:
- 150:aa2d70369df0
- Commit message:
- Synchronized with git rev 3ea0f708
Author: Rohit Grover
add encodePrefix()
Changed in this revision
| services/URIBeacon2Service.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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),
