Example program for BLE devices using updated Puck library.

Dependencies:   Puck mbed

Fork of location-puck by Nordic Pucks

Files at this revision

API Documentation at this revision

Comitter:
cristea
Date:
Thu Jun 19 10:14:27 2014 +0000
Parent:
3:4cb285fb29e7
Child:
5:8ccb1cd6694d
Commit message:
Add Bluetooth skeleton

Changed in this revision

BLE_API.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
nRF51822.lib 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	Thu Jun 19 10:14:27 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Bluetooth-Low-Energy/code/BLE_API/#5d2102351bf4
--- a/main.cpp	Thu Jun 19 11:17:30 2014 +0200
+++ b/main.cpp	Thu Jun 19 10:14:27 2014 +0000
@@ -1,9 +1,9 @@
 #include <mbed.h>
-#include <nRF51822.h>
-
+#include <nRF51822n.h>
 #define DEBUG 1
 
 #ifdef DEBUG
+    Serial pc(USBTX, USBRX);
     #define LOG(args...)    pc.printf(args)
 #else
     #define LOG(args...)
@@ -11,28 +11,13 @@
 
 nRF51822n nrf;
 DigitalOut led1(p1);
-DigitalOut advertisiingStateLed(p30);
+DigitalOut advertisingStateLed(p30);
 
 GapAdvertisingData advData;
 GapAdvertisingData scanResponse;
-GapAdvertisingParams advParams(GapAdvertisingOParams::ADV_CONNECTABLE_UNDIRECTED);
-
-class GapEventHandler : public GapEvents {
-    virtual void onConnected(void) {
-        advertisingStateLed = 0;
-        LOG("Connected!\n\r");
-    }
+GapAdvertisingParams advParams(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
 
-    virtual void onDisconnected(void) {
-        nrf.getGap().startAdvertising(advParams);
-        advertisingStateLed = 1;
-        LOG("Disconnected!\n\r");
-        LOG("Restarting the advertising process\n\r");
-    }
-}
-
-int main() {
-    nrf.getGap().setEventHandler(new GapEventHandler());
+int main(void) {
 
     nrf.init();
     nrf.reset();
@@ -41,7 +26,7 @@
     advData.addData(GapAdvertisingData::SHORTENED_LOCAL_NAME,
                     (uint8_t*)"phlemz", sizeof("phlemz") - 1);
     advData.addAppearance(GapAdvertisingData::UNKNOWN);
-    nrf.getGap().setAdvertisingData(advData. scanResponse);
+    nrf.getGap().setAdvertisingData(advData, scanResponse);
 
     nrf.getGap().startAdvertising(advParams);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/nRF51822.lib	Thu Jun 19 10:14:27 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/teams/Nordic-Semiconductor/code/nRF51822/#c3ce6ee5d300