Updated: TMRh20 2014
This is an example of how to use the RF24Ethernet class to create a web server which will allow you to connect via any device with a web-browser. The url is http://your_chosen_IP:1000
#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>
#include "RF24Mesh.h"
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
void setup() {
Serial.begin(115200);
Serial.println(F("start"));
IPAddress myIP(10, 10, 2, 4);
mesh.begin();
IPAddress gwIP(10, 10, 2, 2);
server.begin();
server.setTimeout(30000);
}
uint32_t mesh_timer = 0;
void loop() {
if (millis() - mesh_timer > 30000) {
mesh_timer = millis();
if (!mesh.checkConnection()) {
Serial.println("*** RENEW ***");
if (mesh.renewAddress() == MESH_DEFAULT_ADDRESS) {
mesh.begin();
}
} else {
Serial.println("*** MESH OK ***");
}
}
while (client.waitAvailable() > 0) {
Serial.print((char)client.read());
}
client.print("HTTP/1.1 200 OK\r\n Content-Type: text/html\r\n Connection: close \r\nRefresh: 5 \r\n\n");
client.print("<!DOCTYPE HTML>\n <html> HELLO FROM ARDUINO!</html>");
client.stop();
Serial.println(F("********"));
}
}
RF24EthernetClass RF24Ethernet