nRF24L01P Hello World example for mbed 6

Dependencies:   nRF24L01P

Revision:
4:6ec07c83786b
Parent:
3:c3afd479d9d8
Child:
6:18ce87bf9df0
--- a/main.cpp	Wed Apr 14 17:25:45 2021 +0000
+++ b/main.cpp	Wed Apr 14 17:30:22 2021 +0000
@@ -11,11 +11,7 @@
 }
 
 int main() {
-
-// The nRF24L01+ supports transfers from 1 to 32 bytes, but Sparkfun's
-//  "Nordic Serial Interface Board" (http://www.sparkfun.com/products/9019)
-//  only handles 4 byte transfers in the ATMega code.
-#define TRANSFER_SIZE   4
+    enum { TRANSFER_SIZE };
 
     char txData[TRANSFER_SIZE], rxData[TRANSFER_SIZE];
     int txDataCnt = 0;
@@ -30,7 +26,7 @@
     printf( "nRF24L01+ TX Address   : 0x%010llX\r\n", my_nrf24l01p.getTxAddress() );
     printf( "nRF24L01+ RX Address   : 0x%010llX\r\n", my_nrf24l01p.getRxAddress() );
 
-    printf( "Type keys to test transfers:\r\n  (transfers are grouped into %d characters)\r\n", TRANSFER_SIZE );
+    printf( "Type keys to test transfers:\r\n");
 
     my_nrf24l01p.setTransferSize( TRANSFER_SIZE );
 
@@ -43,7 +39,7 @@
         if ( pc.readable() ) {
 
             // ...add it to the transmit buffer
-            pc.read(&txData[txDataCnt], sizeof(char));
+            pc.read(&txData[txDataCnt], TRANSFER_SIZE);
             txDataCnt++;
 
             // If the transmit buffer is full
@@ -65,7 +61,7 @@
             // Display the receive buffer contents via the host serial link
             for ( int i = 0; rxDataCnt > 0; rxDataCnt--, i++ ) {
 
-                pc.write(&rxData[i], sizeof(char));
+                pc.write(&rxData[i], sizeof( rxData ));
             }
         }
     }