IoT - Kubus / Mbed 2 deprecated Kubus

Dependencies:   mbed nRF24L01P

Revision:
10:869163c7929d
Parent:
7:e51d0fbb1a25
Child:
27:27cffdb2e9d3
--- a/master.cpp	Thu Jan 05 13:23:49 2017 +0100
+++ b/master.cpp	Thu Jan 05 13:56:25 2017 +0000
@@ -1,6 +1,8 @@
 #include "common.h"
 #include "master.h"
 
+#include <sstream>
+
 int master_loop() {
     Serial pc(USBTX, USBRX); // tx, rx
     nRF24L01P radio(PB_15, PB_14, PB_13, PB_12, PB_1, PB_2);    // mosi, miso, sck, csn, ce, irq
@@ -23,11 +25,14 @@
     pc.printf( "nRF24L01+ RX1 Address   : 0x%010llX\r\n", radio.getRxAddress(NRF24L01P_PIPE_P1) );
 
     while (1) {
-        int rx_bytes = 0;
         if(radio.readable(NRF24L01P_PIPE_P1)){
-
-            rx_bytes = radio.read(NRF24L01P_PIPE_P1, rxData, sizeof(rxData));
-            pc.printf(rxData);
+            int rx_bytes = radio.read(NRF24L01P_PIPE_P1, rxData, sizeof(rxData));
+            std::stringstream ss;
+            
+            for (int i = 0; i < rx_bytes; ++i) {
+                ss << std::hex << rxData[i] / 16 << rxData[i] % 16; // ugly!
+            }
+            pc.printf("received: %s\r\n", ss.str().c_str());
         }
     }
 }