Demonstration code showing how to control an LED over Bluetooth Low Energy using the UARTService

Dependencies:   BLE_API mbed nRF51822

Fork of BLE_LoopbackUART by Bluetooth Low Energy

This programme demonstrates the use of the UARTService to send command strings over Bluetooth Low Energy (BLE) to control devices attached to the nRF51822 board.

In this example you can use a BLE connection from smart phone to turn on and off LED2 on the board.

Sending the character string "led2 on" will turn the LED on and "led2 off" will turn it off.

The command that is received is also echoed back via BLE to the sending device.

You can use the nRF UART App on and Android or iOS smart phone with BLE to test this out https://www.nordicsemi.com/eng/Products/nRFready-Demo-APPS

I have also ported the source code for the Android app into Android studio which should be a good starting point for developing your own custom App https://github.com/bennthomsen/nRF_UART. If you want to start using this within Android Studio create for own fork in GitHub and then from within Android Studio VCS>Checkout from Version Control>GitHub

Revision:
12:36a9f01cfa0a
Parent:
10:633cec718bf4
Child:
13:291a8f177400
--- a/main.cpp	Tue Dec 09 08:55:59 2014 +0000
+++ b/main.cpp	Wed Dec 17 19:46:22 2014 +0000
@@ -49,16 +49,17 @@
     }
 }
 
+/* Periodic Ticker callback */
 void periodicCallback(void)
 {
-    led1 = !led1;
+    led1 = !led1;                             // Toggle LED 1
 }
 
 int main(void)
 {
     led1 = 1;
-    Ticker ticker;
-    ticker.attach(periodicCallback, 1);
+    Ticker ticker;                            // Create period timer
+    ticker.attach(periodicCallback, 1);       // Attach ticker callback function with a period of 1 second
 
     DEBUG("Initialising the nRF51822\n\r");
     ble.init();