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.
Dependencies: BLE_API LIS3DH mbed nRF51822 BMC050 nRF51_LowPwr nRF51_Vdd
Fork of BLE_EddystoneBeacon_Service by
Revision 29:dfb7fb5a971b, committed 2015-07-24
- Comitter:
- mbedAustin
- Date:
- Fri Jul 24 03:36:45 2015 +0000
- Parent:
- 28:af37cebcb583
- Child:
- 30:6c2db8bf5b17
- Commit message:
- [[Working]] Eddystone beacon working with URI, UID and TLM packets being sent correctly.
Changed in this revision
| Eddystone.h | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Eddystone.h Fri Jul 24 03:12:21 2015 +0000
+++ b/Eddystone.h Fri Jul 24 03:36:45 2015 +0000
@@ -27,10 +27,12 @@
#define DBG(x, ...) printf("[EddyStone: DBG]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
#define WARN(x, ...) printf("[EddyStone: WARN]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
#define ERR(x, ...) printf("[EddyStone: ERR]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
+#define INFO(x, ...) printf("[EddyStone: INFO]"x" \t[%s,%d]\r\n", ##__VA_ARGS__,__FILE__,__LINE__);
#else
#define DBG(x, ...) //wait_us(10);
#define WARN(x, ...) //wait_us(10);
#define ERR(x, ...)
+#define INFO(x, ...)
#endif
/**
@@ -131,7 +133,7 @@
*/
bool setURLFrameData(int8_t power, const char * url) {
defaultUrlPower = power;
- encodeURI(url, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting
+ encodeURL(url, defaultUriData, defaultUriDataLength); // encode URL to URL Formatting
if (defaultUriDataLength > URI_DATA_MAX) {
return true; // error, URL is too big
}
@@ -252,11 +254,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");
+ printf("\r\n");
+ for(int x = 0; x<serviceDataLen; x++) {
+ printf("%2.2x:",serviceData[x]);
+ }
+ printf("\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));
@@ -282,6 +284,7 @@
switch(frameIndex) {
case 1:
// URL Frame
+ INFO("Swaping URL Frame: %d",urlIsSet);
if(urlIsSet) {
serviceDataLen += constructURLFrame(serviceData+serviceDataLen,20);
DBG("\t Swapping in URL Frame: len=%d ",serviceDataLen);
@@ -292,6 +295,7 @@
}
case 2:
// UID Frame
+ INFO("Swaping UID Frame: %d",uidIsSet);
if(uidIsSet) {
serviceDataLen += constructUIDFrame(serviceData+serviceDataLen,20);
DBG("\t Swapping in UID Frame: len=%d",serviceDataLen);
@@ -302,6 +306,7 @@
}
default:
// TLM frame
+ INFO("Swaping TLM Frame:");
serviceDataLen += constructTLMFrame(serviceData+serviceDataLen,20);
DBG("\t Swapping in TLM Frame: len=%d",serviceDataLen);
updateAdvPacket(serviceData,serviceDataLen);
@@ -459,7 +464,7 @@
/*
* Encode a human-readable URI into the binary format defined by URIBeacon spec (https://github.com/google/uribeacon/tree/master/specification).
*/
- static void encodeURI(const char *uriDataIn, UriData_t uriDataOut, size_t &sizeofURIDataOut) {
+ static void encodeURL(const char *uriDataIn, UriData_t uriDataOut, size_t &sizeofURIDataOut) {
const char *prefixes[] = {
"http://www.",
"https://www.",
--- a/main.cpp Fri Jul 24 03:12:21 2015 +0000
+++ b/main.cpp Fri Jul 24 03:36:45 2015 +0000
@@ -21,12 +21,12 @@
BLE ble;
uint8_t UIDnamespace[] = {0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xAA}; // 10Bytes for Namespace UUID
uint8_t UIDinstance[] = {0xbb,0xcc,0xdd,0xee,0xff,0x00}; // 6Bytes for Instance UUID
- char Url[] = "www.mbed.org";
+//char Url[] = "www.mbed.org";
int main(void)
{
printf("Starting Example\r\n");
- EddystoneService eddyBeacon(ble, 100, 10,UIDnamespace, UIDinstance, Url, sizeof(Url));
+ EddystoneService eddyBeacon(ble, 1000, 10,UIDnamespace, UIDinstance, "http://www.mbed.org", sizeof("http://www.mbed.org"));
printf("Running...\r\n");
while (true) {
ble.waitForEvent();
