#include #include #include #include #include //RF24 radio(RPI_V2_GPIO_P1_15, BCM2835_SPI_CS0, BCM2835_SPI_SPEED_8MHZ); //RF24 radio(22,0); int radio_chipenable = 23; int radio_chipselect = 1; int loadconfig() { cfg_opt_t opts[] { CFG_SIMPLE_INT("radio-chip-enable", &radio_chipenable), CFG_SIMPLE_INT("radio-chip-select", &radio_chipselect), CFG_END() }; cfg_t *cfg = cfg_init(opts, CFGF_NOCASE); cfg_parse(cfg, "gateway.conf"); cfg_free(cfg); return 0; } int init(int argc, char** argv) { loadconfig(); RF24 radio(radio_chipenable, radio_chipselect); RF24Network network(radio); RF24Mesh mesh(radio, network); RF24Gateway gw(radio, network, mesh); return 0; } int main(int argc, char** argv) { init(argc, argv); //Config for use with RF24Mesh as Master Node //uint8_t nodeID=0; gw.begin(); //Config for use with RF24Mesh as child Node // uint8_t nodeID = 1; // gw.begin(nodeID); //Config for use without RF24Mesh // uint16_t RF24NetworkAddress = 0; // gw.begin(RF24NetworkAddress); //Set this to your chosen IP/Subnet char ip[] = "10.30.0.1"; char subnet[] = "255.255.255.0"; gw.setIP(ip, subnet); while (true) { // The gateway handles all IP traffic (marked as EXTERNAL_DATA_TYPE) and passes it to the associated network interface // RF24Network user payloads are loaded into the user cache gw.update(); if (network.available()) { RF24NetworkHeader header; size_t size = network.peek(header); uint8_t buf[size]; network.read(header, &buf, size); printf("Received Network Message, type: %d id %d \n", header.type, header.id); } } return 0; }