![](/media/cache/group/V2.png.50x50_q85.png)
FN
Dependencies: mbed RF24Network RF24
main.cpp
- Committer:
- akashvibhute
- Date:
- 2015-07-06
- Revision:
- 2:608cf8c5c55e
- Parent:
- 1:5be48a9550c3
- Child:
- 3:e9c4d66da50c
File content as of revision 2:608cf8c5c55e:
#include "mbed.h" #include <RF24Network.h> #include <RF24.h> Serial pc(USBTX, USBRX); #define nrf_CE D9 #define nrf_CSN D10 #define spi_SCK D3 #define spi_MOSI D4 #define spi_MISO D5 RF24 radio(spi_MOSI, spi_MISO, spi_SCK, nrf_CSN, nrf_CE); // Network uses that radio RF24Network network(radio); // Address of our node const uint16_t this_node = 1; // Address of the other node const uint16_t other_node = 0; // When did we last send? unsigned long last_sent; // How many have we sent already unsigned long packets_sent; // Structure of our payload struct payload_t { unsigned long ms; unsigned long counter; float vector_4d[4]; }; int main() { pc.baud(921600); wait_ms(1000); pc.printf("mBed RF24Network node\n"); radio.begin(); network.begin(/*channel*/ 90, /*node address*/ this_node); wait_ms(2000); while(1) { // Pump the network regularly network.update(); // Is there anything ready for us? while ( network.available() ) { // If so, grab it and print it out RF24NetworkHeader header_rx; payload_t payload_rx; network.read(header_rx,&payload_rx,sizeof(payload_rx)); pc.printf("Received packet # %d at %d ms, message: V4 %f, %f, %f, %f \n",payload_rx.counter,payload_rx.ms, payload_rx.vector_4d[0],payload_rx.vector_4d[1],payload_rx.vector_4d[2],payload_rx.vector_4d[3]); } } }