Andriy Makukha / Mbed 2 deprecated football_project_wo_output

Dependencies:   mbed

Fork of football_project by MZJ

Revision:
19:afcbb425b3cf
Parent:
11:d3aa5fca2330
Child:
75:1b357bee1839
--- a/PhoneAppIO.cpp	Sun Nov 29 13:52:53 2015 +0000
+++ b/PhoneAppIO.cpp	Tue Dec 01 16:03:15 2015 +0000
@@ -61,6 +61,26 @@
     return  bytesRead;
 }
 
+uint16_t PhoneAppIO::injectHandleRead( char *buf, int len )  // Inject data from elsewhere simulating BLE-in.
+{                                                            //  also writes to txPayload
+    int bytesRead = 0;
+
+    if( (NULL != buf) && (0 < len) )
+    {
+        bytesRead = MIN( len, TXRX_BUF_LEN );
+
+        // Copy data to accessible location for others and handleRead().
+        memset( txPayload, 0, TXRX_BUF_LEN );
+        memcpy( txPayload, buf, bytesRead );
+
+        // Buffer the data.
+        data = (char *)txPayload;
+        handleRead();
+    }
+
+    return  bytesRead;
+}
+
 // Maybe write to RX characteristic (From cone to phone.)
 uint16_t PhoneAppIO::maybeHandleWrite()  // Called by toPhoneChk() from main loop.
 {