Use of nRF51822 to demonstrate usage of BLE-UART service provided by Nordic and the use of uLCD-144-G2. The demonstration uses the nRF Master Control Panel and nRF UART demo apps provided by Nordic and available on Google Play and Apple Store. The firmware receives data over the TX characteristic, increments it by 1 and sends it over RX characteristic. The notifications need to be enabled for the RX characteristic in the Master Control Panel to be able to receive the data. For more information check the notebook page: http://developer.mbed.org/users/garimagupta002/notebook/ble-uart-lcd-demo/

Dependencies:   4DGL-uLCD-SE BLE_API DFRobot_BLE_LoopbackUART mbed nRF51822

Fork of DFRobot_BLE_LoopbackUART by Angelo qiao

Revision:
9:7b3841a91548
Parent:
6:e0fc9072e853
Child:
10:c3eef6f3686a
--- a/main.cpp	Tue Sep 30 02:20:59 2014 +0000
+++ b/main.cpp	Fri Oct 31 07:55:37 2014 +0000
@@ -19,7 +19,7 @@
 
 #include "UARTService.h"
 
-#define NEED_CONSOLE_OUTPUT 0 /* Set this if you need debug messages on the console;
+#define NEED_CONSOLE_OUTPUT 1 /* Set this if you need debug messages on the console;
                                * it will have an impact on code-size and power consumption. */
 
 #if NEED_CONSOLE_OUTPUT
@@ -30,6 +30,8 @@
 
 BLEDevice  ble;
 DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+Timer timer;
 
 UARTService *uartServicePtr;
 
@@ -56,6 +58,10 @@
 
 int main(void)
 {
+    
+    
+    timer.start();
+    
     led1 = 1;
     Ticker ticker;
     ticker.attach(periodicCallback, 1);
@@ -79,7 +85,39 @@
     UARTService uartService(ble);
     uartServicePtr = &uartService;
 
+
     while (true) {
+        static unsigned long led2timer=timer.read_ms();
+        
+        if((unsigned long)timer.read_ms()-led2timer>1000UL)
+        {
+            led2timer=timer.read_ms();
+            led2=!led2;
+        }
+        
+        
+        
         ble.waitForEvent();
     }
 }
+
+//// Count the time to toggle a LED
+// 
+//#include "mbed.h"
+// 
+//Timer timer;
+//DigitalOut led(LED1);
+//int begin, end;
+// 
+//int main() {
+//    timer.start();
+//    
+//    while(true)
+//    {
+////    begin = timer.read_ms();
+//    led = !led;
+//    wait(1);
+////    end = timer.read_ms();
+////    printf("%d us\r\n", end - begin);
+//    }
+//}