Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: master.cpp
- 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()); } } }