testing

Dependencies:   mbed nRF24L01P

Fork of nRF24L01P_Hello_World by Owen Edwards

Files at this revision

API Documentation at this revision

Comitter:
sksarm
Date:
Tue Mar 31 01:38:31 2015 +0000
Parent:
1:5be2682710c6
Commit message:
initial step

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
mbed.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jan 19 23:53:19 2011 +0000
+++ b/main.cpp	Tue Mar 31 01:38:31 2015 +0000
@@ -8,6 +8,8 @@
 DigitalOut myled1(LED1);
 DigitalOut myled2(LED2);
 
+Timer t;
+
 int main() {
 
 // The nRF24L01+ supports transfers from 1 to 32 bytes, but Sparkfun's
@@ -18,6 +20,8 @@
     char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE];
     int txDataCnt = 0;
     int rxDataCnt = 0;
+    int tmpDataCnt = 0;
+    char tmpData[TRANSFER_SIZE+1];
 
     my_nrf24l01p.powerUp();
 
@@ -46,9 +50,11 @@
             // If the transmit buffer is full
             if ( txDataCnt >= sizeof( txData ) ) {
 
+                t.start();
+                
                 // Send the transmitbuffer via the nRF24L01+
                 my_nrf24l01p.write( NRF24L01P_PIPE_P0, txData, txDataCnt );
-
+                
                 txDataCnt = 0;
             }
 
@@ -58,14 +64,38 @@
 
         // If we've received anything in the nRF24L01+...
         if ( my_nrf24l01p.readable() ) {
-
+                
             // ...read the data into the receive buffer
             rxDataCnt = my_nrf24l01p.read( NRF24L01P_PIPE_P0, rxData, sizeof( rxData ) );
 
             // Display the receive buffer contents via the host serial link
             for ( int i = 0; rxDataCnt > 0; rxDataCnt--, i++ ) {
-
+            
                 pc.putc( rxData[i] );
+                tmpData[tmpDataCnt++] = rxData[i]; 
+            }
+            
+            if ( tmpDataCnt >= TRANSFER_SIZE ) {
+                tmpData[TRANSFER_SIZE] = '\0';
+                //pc.printf( "Received data : %s \r\n", tmpData);
+                if (strcmp(tmpData, "ackn"))
+                {
+                    tmpData[0] = 'a';
+                    tmpData[1] = 'c';
+                    tmpData[2] = 'k';
+                    tmpData[3] = 'n';
+                    //pc.printf( "Sending data : %s \r\n", "ackn");
+                    my_nrf24l01p.write( NRF24L01P_PIPE_P0, tmpData, tmpDataCnt );  
+                }
+                else
+                {
+                    t.stop();
+                    pc.printf("\r\nThe time taken was %f seconds \r\n", t.read());
+                    t.reset();
+                }
+                
+                 
+                tmpDataCnt = 0;   
             }
 
             // Toggle LED2 (to help debug nRF24L01+ -> Host communication)
--- a/mbed.bld	Wed Jan 19 23:53:19 2011 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Tue Mar 31 01:38:31 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#9ad691361fac