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

Files at this revision

API Documentation at this revision

Comitter:
djmannion
Date:
Fri Jan 02 15:15:54 2015 +0000
Parent:
14:8ff3bfb6b19d
Commit message:
Line 85: was edited to include:
; ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED| GapAdvertisingData::LE_GENERAL_DISCOVERABLE);
;
; This allowed the UART app to connect to the board successfully.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Dec 17 22:47:39 2014 +0000
+++ b/main.cpp	Fri Jan 02 15:15:54 2015 +0000
@@ -82,7 +82,7 @@
     ble.onDataWritten(onDataWritten);                                                      // Define callback function for BLE Data received event
 
     /* setup advertising */
-    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);             // Indicate that Legacy Bluetooth in not supported
+    ble.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED| GapAdvertisingData::LE_GENERAL_DISCOVERABLE);             // Indicate that Legacy Bluetooth in not supported
     ble.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
     ble.accumulateAdvertisingPayload(GapAdvertisingData::SHORTENED_LOCAL_NAME,
                                      (const uint8_t *)"BLE UART", sizeof("BLE UART") - 1);