BLE Observer example for nucleo platform

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 mbed

Dependents:   BLE_NordicUART_IDB0XA1

Files at this revision

API Documentation at this revision

Comitter:
vcoubard
Date:
Fri Dec 04 12:48:00 2015 +0000
Commit message:
BLE_Observer example for NUCLEO platform

Changed in this revision

BLE_API.lib Show annotated file Show diff for this revision Revisions of this file
X_NUCLEO_IDB0XA1.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BLE_API.lib	Fri Dec 04 12:48:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#1a37289c954e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/X_NUCLEO_IDB0XA1.lib	Fri Dec 04 12:48:00 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ST/code/X_NUCLEO_IDB0XA1/#5b9c78101d45
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Dec 04 12:48:00 2015 +0000
@@ -0,0 +1,55 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2015 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mbed.h"
+#include "BLE.h"
+
+BLE        ble;
+DigitalOut led1(LED1);
+
+void periodicCallback(void)
+{
+    led1 = !led1; /* Do blinky on LED1 while we're waiting for BLE events */
+}
+
+void advertisementCallback(const Gap::AdvertisementCallbackParams_t *params) {
+
+    printf("Adv peerAddr: [%02x %02x %02x %02x %02x %02x] rssi %d, ScanResp: %u, AdvType: %u\r\n",
+           params->peerAddr[5], params->peerAddr[4], params->peerAddr[3], params->peerAddr[2], params->peerAddr[1], params->peerAddr[0],
+           params->rssi, params->isScanResponse, params->type);
+#if DUMP_ADV_DATA
+    for (unsigned index = 0; index < params->advertisingDataLen; index++) {
+        printf("%02x ", params->advertisingData[index]);
+    }
+    printf("\r\n");
+#endif /* DUMP_ADV_DATA */
+}
+
+int main(void)
+{
+    led1 = 1;
+    Ticker ticker;
+    ticker.attach(periodicCallback, 1);
+
+    ble.init();
+
+    ble.gap().setScanParams(500 /* scan interval */, 200 /* scan window */);
+    ble.gap().startScan(advertisementCallback);
+
+    while (true) {
+        ble.waitForEvent();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Dec 04 12:48:00 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file