Simple beacon for nRF51822

Dependencies:   BLE_API mbed nRF51822Copy

Fork of BLE_iBeacon by Bluetooth Low Energy

This is the demo beacon for ARM TechCon 2014.

Based on the original library, this demo reads the onboard switches and temperature sensor and beacons them out as a BLE advertisment.

Files at this revision

API Documentation at this revision

Comitter:
wd5gnr
Date:
Wed Oct 01 22:06:43 2014 +0000
Parent:
44:6a5d976d6e61
Commit message:
Replace the mbed-src library with mbed

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-src.lib Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 6a5d976d6e61 -r e64d1e920cd1 main.cpp
--- a/main.cpp	Sun Sep 21 19:23:27 2014 +0000
+++ b/main.cpp	Wed Oct 01 22:06:43 2014 +0000
@@ -84,6 +84,19 @@
 };
 
 
+// Read temperature
+int temp_read()
+{
+    int t;
+    NRF_TEMP->TASKS_START=1;
+    while (NRF_TEMP->EVENTS_DATARDY==0);
+    NRF_TEMP->EVENTS_DATARDY=0;
+    t=nrf_temp_read();
+    NRF_TEMP->TASKS_STOP=1;
+    return t;
+}
+
+
 // Grab the sensors and put 55AA in major
 // Put minor data for temperature reading 
 // (which returns 0 on this board)
@@ -93,7 +106,7 @@
     int temp;
     beaconPayload[20]=0x55;
     beaconPayload[21]=0xAA;
-    temp=nrf_temp_read();  // always reads 0? (should read 0-1023)
+    temp=temp_read();  //  (should read 0-1023)
     if (!btn1) temp|=0x8000;   // switches are inverted sense (0=pressed)
     if (!btn2) temp|=0x4000;
         
@@ -123,6 +136,7 @@
     activity=errLED=0;
     nrf_temp_init();
     errTry(ble.init(),1);
+    NRF_TEMP->TASKS_START=1;
 
 // Build advert
     setupBLE();
diff -r 6a5d976d6e61 -r e64d1e920cd1 mbed-src.lib
--- a/mbed-src.lib	Sun Sep 21 19:23:27 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed-src/#1f0269907d8b
diff -r 6a5d976d6e61 -r e64d1e920cd1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Oct 01 22:06:43 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1
\ No newline at end of file