This example demonstrates how to use RF24Mesh with RF24Ethernet when working with a SLIP or TUN interface.
This example uses HTML.h from the example's directory.
#include <RF24.h>
#include <RF24Network.h>
#include <RF24Mesh.h>
#include "HTML.h"
#include <printf.h>
RF24 radio(7, 8);
RF24Network network(radio);
RF24Mesh mesh(radio, network);
#define LED_PIN A3
void setup() {
Serial.begin(115200);
printf_begin();
Serial.println("start");
pinMode(LED_PIN, OUTPUT);
mesh.setNodeID(2);
mesh.begin();
radio.printDetails();
IPAddress myIP(10, 10, 3, 2);
IPAddress gwIP(10, 10, 3, 1);
server.begin();
}
uint32_t mesh_timer = 0;
void loop() {
if (millis() - mesh_timer > 30000) {
mesh_timer = millis();
if (!mesh.checkConnection()) {
if (mesh.renewAddress() == MESH_DEFAULT_ADDRESS) {
mesh.begin();
}
}
}
size_t size;
uint8_t pageReq = 0;
generate_tcp_stats();
while ((size = client.available()) > 0) {
if (size >= 7) {
char slash[] = { "/" };
client.findUntil(slash, slash);
char buf[3] = { " " };
buf[0] = client.read();
buf[1] = client.read();
if (strcmp(buf, "ON") == 0) {
pageReq = 1;
} else if (strcmp(buf, "OF") == 0) {
pageReq = 1;
} else if (strcmp(buf, "ST") == 0) {
pageReq = 2;
} else if (strcmp(buf, "CR") == 0) {
pageReq = 3;
} else if (buf[0] == ' ') {
pageReq = 4;
}
}
while (client.waitAvailable()) {
client.read();
}
}
switch (pageReq) {
case 2:
break;
case 3:
break;
case 4:
break;
case 1:
break;
default:
break;
}
client.stop();
Serial.println(F("********"));
}
}
static unsigned short generate_tcp_stats() {
struct uip_conn* conn;
conn = &uip_conns[i];
if (uip_stopped(conn)) {
Serial.print(F("Connection no "));
Serial.println(i);
Serial.print(F("Local Port "));
Serial.println(htons(conn->lport));
Serial.print(F("Remote IP/Port "));
Serial.print(htons(conn->ripaddr[0]) >> 8);
Serial.print(F("."));
Serial.print(htons(conn->ripaddr[0]) & 0xff);
Serial.print(F("."));
Serial.print(htons(conn->ripaddr[1]) >> 8);
Serial.print(F("."));
Serial.print(htons(conn->ripaddr[1]) & 0xff);
Serial.print(F(":"));
Serial.println(htons(conn->rport));
Serial.print(F("Outstanding "));
Serial.println((uip_outstanding(conn)) ? '*' : ' ');
}
}
return 1;
}
void main_page(EthernetClient &_client)
void stats_page(EthernetClient &_client)
void credits_page(EthernetClient &_client)
RF24EthernetClass RF24Ethernet
#define UIP_CONF_MAX_CONNECTIONS
Maximum number of TCP connections.