I was experimenting with the nrf modules and wrote the following code of a client.But the code isn’s compiling and the progress gets stuck.I am using Arduino 1.6.4
/** RF24Mesh_Example.ino by TMRh20
*
* This example sketch shows how to manually configure a node via RF24Mesh, and send data to the
* master node.
* The nodes will refresh their network address as soon as a single write fails. This allows the
* nodes to change position in relation to each other and the master node.
*/
#include "RF24.h"
#include "RF24Network.h"
#include "RF24Mesh.h"
#include <SPI.h>
#include <EEPROM.h>
//#include <printf.h>
/**** Configure the nrf24l01 CE and CS pins ****/
RF24 radio(9, 10);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
/**
* User Configuration: nodeID - A unique identifier for each radio. Allows addressing
* to change dynamically with physical changes to the mesh.
*
* In this example, configuration takes place below, prior to uploading the sketch to the device
* A unique value from 1-255 must be configured for each node.
* This will be stored in EEPROM on AVR devices, so remains persistent between further uploads, loss of power, etc.
*
**/
#define nodeID 1
uint32_t displayTimer = 0;
String switch_status="";
String relay_status="0000";
const uint8_t analogpins[] = {A0,A1,A2,A3};
int SC = 0;
struct server_payload
{
char command;
}
void setup() {
Serial.begin(57200);
//printf_begin();
// Set the nodeID manually
mesh.setNodeID(nodeID);
// Connect to the mesh
Serial.println(F("Connecting to the mesh..."));
mesh.begin();
pinMode(A0,OUTPUT);
pinMode(A1,OUTPUT);
pinMode(A2,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(4,INPUT);
pinMode(5,INPUT);
pinMode(6,INPUT);
pinMode(7,INPUT);
digitalWrite(A0,LOW);
digitalWrite(A1,LOW);
digitalWrite(A2,LOW);
digitalWrite(A3,LOW);
}
void loop() {
for(int i=0;i<=3;i++)
switch_status += String(digitalRead(i+4));
mesh.update();
if (millis() - displayTimer >= 1000)
{
displayTimer = millis();
// Send an 'M' type message containing the current millis()
for(int i =0;i<= 3;i++)
{
if (!mesh.write(&switch_status, 'M', sizeof(switch_status)))
{
if ( ! mesh.checkConnection() )
{
Serial.println("Renewing Address");
mesh.renewAddress();
break;
}
else
{
Serial.println("Send fail, Test OK");
}
}
else
{
Serial.print("Send OK: "); Serial.print(switch_status,sizeof(switch_status));
}
}
Serial.println("");
while (network.available())
{
RF24NetworkHeader header;
server_payload payload;
network.read(header, &payload, sizeof(payload));
if(header.from_node == 0)
{
write_pins(payload);
}
}
}
}
void write_pins(server_payload payload) //used to toggle analog pins.
{
if (payload.command)
{
for(int i=0;i<=3;i++)
{
digitalWrite(analogpins[i],int(switch_status[i]);
}
relay_status = switch_status
}
else if (payload.command == 0)
{
return;
}
else
{
for(int i=0;i<=3;i++)
{
digitalWrite(analogpins[i],int(relay_status[i]);
}
}
}
Thanks in advance.