mbed and BLEmate / Mbed 2 deprecated mbed_serial_test

Dependencies:   mbed

Fork of mbed_serial_test by An Nguyen

Revision:
1:5c5cd69a3cf8
Parent:
0:47c7262c17ac
--- a/main.cpp	Tue Sep 01 02:06:26 2015 +0000
+++ b/main.cpp	Tue Sep 01 02:36:31 2015 +0000
@@ -9,18 +9,23 @@
 void BLEmateready();
  
 int main() {
-    BLEmate.attach(&BLEmateready);
+    char pcin;
+    char BLEin;
     pc.printf("Something from mbed to PC\n\r");
     while (1) {
-        led1 = !led1;
-        wait(0.5);
+        if ( pc.readable() ) {
+            BLEmate.printf("SND ");
+            while ( pcin != '\n' && pcin != '\r' )
+                BLEmate.putc(pcin = pc.getc());
+            pcin = 0;
+        }
+        
+        if ( BLEmate.readable() ) {
+            pc.printf("phone sends: ");
+            while ( BLEmate.readable() || BLEin != '\r')
+                pc.putc(BLEin = BLEmate.getc());
+            pc.printf("\n\r");
+            BLEin = 0;
+        }
     }
-}
-
-void BLEmateready() {
-    pc.printf("phone sends: ");
-    while ( BLEmate.readable() ) {
-        pc.putc(BLEmate.getc());
-    }
-    pc.printf("\n\r");
 }
\ No newline at end of file