diff --git a/examples/Getting_Started_SimpleServer_Mesh/Getting_Started_SimpleServer_Mesh.ino b/examples/Getting_Started_SimpleServer_Mesh/Getting_Started_SimpleServer_Mesh.ino
index f670e8d..d2c5ed8 100644
--- a/examples/Getting_Started_SimpleServer_Mesh/Getting_Started_SimpleServer_Mesh.ino
+++ b/examples/Getting_Started_SimpleServer_Mesh/Getting_Started_SimpleServer_Mesh.ino
@@ -132,7 +132,9 @@ void loop() {
if ( ! mesh.checkConnection() ) {
Serial.println("*** RENEW ***");
//refresh the network address
- mesh.renewAddress();
+ if ( ! mesh.renewAddress() ){
+ mesh.begin();
+ }
} else {
@@ -146,8 +148,8 @@ void loop() {
Serial.print((char)client.read());
}
// Send an HTML response to the client. Default max size/characters per write is 90
- client.write( "HTTP/1.1 200 OK\n Content-Type: text/html\n Connection: close \nRefresh: 5 \n\n");
- client.write( "\n HELLO FROM ARDUINO!");
+ client.print( "HTTP/1.1 200 OK\n Content-Type: text/html\n Connection: close \nRefresh: 5 \n\n");
+ client.print( "\n HELLO FROM ARDUINO!");
client.stop();
Serial.println(F("********"));
diff --git a/examples/InteractiveServer_Mesh/HTML.h b/examples/InteractiveServer_Mesh/HTML.h
index 8501bb8..ce9a528 100644
--- a/examples/InteractiveServer_Mesh/HTML.h
+++ b/examples/InteractiveServer_Mesh/HTML.h
@@ -96,8 +96,7 @@ static const PROGMEM char credits_html[] =
*/
void sendPage(EthernetClient& _client, const char* _pointer, size_t size ) {
for (uint16_t i = 0; i < size; i++) {
- char c = pgm_read_byte(_pointer++);
- _client.write(&c, 1);
+ _client.print((char)pgm_read_byte(_pointer++));
}
}
@@ -122,14 +121,14 @@ void main_page(EthernetClient& _client) {
if (!led_state) {
sprintf_P(bf, PSTR("
\n"), lColor);
- _client.write(bf);
+ _client.print(bf);
sprintf_P(bf, PSTR("LED is %s |
\n"), lState);
} else {
sprintf_P(bf, PSTR(" | \n"), lColor);
- _client.write(bf);
+ _client.print(bf);
sprintf_P(bf, PSTR("LED is %s |
\n"), lState);
}
- _client.write(bf);
+ _client.print(bf);
// Send the 2nd half of the page
static const char* html_pointer2 = main_html_p2;
@@ -165,27 +164,27 @@ void stats_page(EthernetClient& _client) {
char buffer[45];
strncpy_P(buffer, PSTR("HTTP/1.1 200 OK\nContent-Type: text/html\n"), 45);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR("Connection: close\n\n\n\n"), 45);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR("\n"), 45);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR(" Uptime | \n"), 45);
- _client.write( buffer );
+ _client.print( buffer );
sprintf_P(buffer, PSTR("%u days, %lu hours %lu minutes %lu"), days, hours, minutes, seconds);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR("seconds |
UIP Buffer Size"), 45);
- _client.write( buffer );
+ _client.print( buffer );
sprintf_P(buffer, PSTR(" | %u bytes |
User "), UIP_BUFSIZE);
- _client.write( buffer );
+ _client.print( buffer );
sprintf_P(buffer, PSTR("Output Buffer Size | %u bytes"), OUTPUT_BUFFER_SIZE);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR(" |
"), 45);
- _client.write( buffer );
+ _client.print( buffer );
strncpy_P(buffer, PSTR("Home"), 45);
- _client.write( buffer );
+ _client.print( buffer );
}
diff --git a/examples/InteractiveServer_Mesh/InteractiveServer_Mesh.ino b/examples/InteractiveServer_Mesh/InteractiveServer_Mesh.ino
index 21a732f..6e404c8 100644
--- a/examples/InteractiveServer_Mesh/InteractiveServer_Mesh.ino
+++ b/examples/InteractiveServer_Mesh/InteractiveServer_Mesh.ino
@@ -78,7 +78,9 @@ void loop() {
mesh_timer = millis();
if ( ! mesh.checkConnection() ) {
//refresh the network address
- mesh.renewAddress();
+ if ( ! mesh.renewAddress() ) {
+ mesh.begin();
+ }
}
}
@@ -93,6 +95,7 @@ void loop() {
// If a request is received with enough characters, search for the / character
if (size >= 7) {
char slash[] = {"/"};
+ client.setTimeout(10000);
client.findUntil(slash, slash);
char buf[3] = {" "};
if (client.available() >= 2) {
@@ -121,9 +124,7 @@ void loop() {
}
}
// Empty the rest of the data from the client
- //while (client.waitAvailable()) {
client.flush();
- //}
}
/**
diff --git a/examples/InteractiveServer_Mesh_ESPWifi/InteractiveServer_Mesh_ESPWifi.ino b/examples/InteractiveServer_Mesh_ESPWifi/InteractiveServer_Mesh_ESPWifi.ino
index bd33d6d..8165b88 100644
--- a/examples/InteractiveServer_Mesh_ESPWifi/InteractiveServer_Mesh_ESPWifi.ino
+++ b/examples/InteractiveServer_Mesh_ESPWifi/InteractiveServer_Mesh_ESPWifi.ino
@@ -100,7 +100,9 @@ void loop() {
mesh_timer = millis();
if ( ! mesh.checkConnection() ) {
//refresh the network address
- mesh.renewAddress();
+ if ( ! mesh.renewAddress() ) {
+ mesh.begin();
+ }
}
}
diff --git a/examples/SLIP_InteractiveServer/SLIP_InteractiveServer.ino b/examples/SLIP_InteractiveServer/SLIP_InteractiveServer.ino
index 4921d86..0a8e962 100644
--- a/examples/SLIP_InteractiveServer/SLIP_InteractiveServer.ino
+++ b/examples/SLIP_InteractiveServer/SLIP_InteractiveServer.ino
@@ -94,7 +94,9 @@ void loop() {
mesh_timer = millis();
if ( ! mesh.checkConnection() ) {
//refresh the network address
- mesh.renewAddress();
+ if ( ! mesh.renewAddress() ) {
+ mesh.begin();
+ }
}
}
diff --git a/examples/SimpleClient_Mesh/SimpleClient_Mesh.ino b/examples/SimpleClient_Mesh/SimpleClient_Mesh.ino
index 5defd5e..9649d4a 100644
--- a/examples/SimpleClient_Mesh/SimpleClient_Mesh.ino
+++ b/examples/SimpleClient_Mesh/SimpleClient_Mesh.ino
@@ -71,7 +71,9 @@ void loop() {
if (millis() - mesh_timer > 30000) { //Every 30 seconds, test mesh connectivity
mesh_timer = millis();
if ( ! mesh.checkConnection() ) {
- mesh.renewAddress();
+ if ( ! mesh.renewAddress() ) {
+ mesh.begin();
+ }
}
}