Provide BLE API to parse the iBeacon packet and print the message. Leverage the BLE scan_start, scan_stop API to get iBeacon.

Dependents:   BLE_iBeaconScan BLE_iBeaconScan

Use the following API to complete the iBeacon parser:

iBeaconInit() - Use BLE API to initialize the BLE stack

iBeaconStartScan() - Use BLE API to start BLE scan

iBeaconStopScan() - Use BLE API to stop BLE scan

AdvertisementReportCallback - Parse the iBeacon to uuid, major number, minor number, tx power field

Files at this revision

API Documentation at this revision

Comitter:
marcusC
Date:
Thu Nov 26 05:55:06 2015 +0000
Commit message:
First Commit, provide the start_scan, stop_scan, parse iBeacon packet API

Changed in this revision

iBeaconScan.cpp Show annotated file Show diff for this revision Revisions of this file
iBeaconScan.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 2c8c5bd785f4 iBeaconScan.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/iBeaconScan.cpp	Thu Nov 26 05:55:06 2015 +0000
@@ -0,0 +1,20 @@
+#include "BLE.h"
+#include "iBeaconScan.h"
+
+BLE bleIBeacon;
+extern void AdvertisementReportCallback(const Gap::AdvertisementCallbackParams_t *params);
+
+void iBeaconInit(void)
+{
+    bleIBeacon.init();
+}
+
+void iBeaconStartScan(void)
+{
+    bleIBeacon.startScan(AdvertisementReportCallback); 
+}
+
+void iBeaconStopScan(void)
+{
+    bleIBeacon.stopScan();
+}
diff -r 000000000000 -r 2c8c5bd785f4 iBeaconScan.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/iBeaconScan.h	Thu Nov 26 05:55:06 2015 +0000
@@ -0,0 +1,18 @@
+struct iBeaconPayload {
+    uint8_t prefix[9];
+    uint8_t uuid[16];
+    uint8_t majorNumber[2];
+    uint8_t minorNumber[2];
+    uint8_t txPower;
+};
+
+union unionType {
+    struct iBeaconPayload iBeaconPayload_m;
+    uint8_t rawData[30];
+};
+
+const uint8_t iBeaconPrefix[] = {0x02,0x01,0x06,0x1a,0xff,0x4c,0x00,0x02,0x15};
+
+void iBeaconInit(void);
+void iBeaconStartScan(void);
+void iBeaconStopScan(void);