BLE iBeacon Scan example for Nordic dongle
Dependencies: BLE_API BLE_iBeacon_Scan mbed-dev nRF51822
Fork of BLE_iBeaconScan by
Revision 1:cbb615126d2f, committed 2016-08-03
- Comitter:
- phamhuutin202
- Date:
- Wed Aug 03 06:34:48 2016 +0000
- Parent:
- 0:17c37c570285
- Commit message:
- ibeacon scan
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 17c37c570285 -r cbb615126d2f main.cpp --- a/main.cpp Thu Nov 26 06:05:32 2015 +0000 +++ b/main.cpp Wed Aug 03 06:34:48 2016 +0000 @@ -9,10 +9,13 @@ void AdvertisementReportCallback(const Gap::AdvertisementCallbackParams_t *params) { led1 = !led1; + pc.printf("Advertisement packet received.\r\n"); uint8_t i; - if (memcmp(params->advertisingData,iBeaconPrefix,sizeof(iBeaconPrefix)) != 0) + if (memcmp(params->advertisingData,iBeaconPrefix,sizeof(iBeaconPrefix)) != 0){ + pc.printf("Received packet is not ibeacon.\r\n"); return; + } memset(u.rawData, 0 , sizeof(u.rawData)); memcpy(u.rawData, params->advertisingData,params->advertisingDataLen); @@ -23,20 +26,31 @@ pc.printf("\r\n"); pc.printf("majorNumber:%02x %02x\r\n",u.iBeaconPayload_m.majorNumber[0], u.iBeaconPayload_m.majorNumber[1]); pc.printf("minorNumber:%02x %02x\r\n",u.iBeaconPayload_m.minorNumber[0], u.iBeaconPayload_m.minorNumber[1]); - pc.printf("txPower:%02x\r\n",u.iBeaconPayload_m.txPower); + pc.printf("txPower:%d\r\n",u.iBeaconPayload_m.txPower); + pc.printf("RSSI:%d\r\n",params->rssi); } int main(void) { led1 = 0; pc.baud(115200); - pc.printf("Hello\n"); + wait(10); + pc.printf("Hello\r\n"); + pc.printf("Start initialization\r\n"); iBeaconInit(); - iBeaconStartScan(); + pc.printf("Finish initialization\r\n"); wait(10); - iBeaconStopScan(); + pc.printf("Start Scan\r\n"); + iBeaconStartScan(); + pc.printf("Scanning..\r\n"); + //wait(10); + //iBeaconStopScan(); + //pc.printf("Scan stop.\r\n"); while(1) { + //pc.printf("Hello\r\n"); + //led1 = !led1; + //wait(1); } }