There is a maximum String length approximately 3000. To get a webpage to show off a non-local LAN. My internal LAN 192.168.1.x viewing the webpage locally is fine remotely anything over 3000 characters is blocked.
What I’m trying to do is split a webpage into two chunks, I tried a number of methods that cannot seem to get it to work it just displays the first part and forgets about the second part.
Could anyone give me a pointer to some code that can join the two halves of the webpage together.
Much appreciated for all your help.
Line 46-48 is the problem. I am doing something wrong again.
¬¬¬cpp
#include <ArduinoOTA.h>
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
const char* ssid = “BTHub5-RKSM”;
const char* password = “”;
ESP8266WebServer server(80);
const int led = LED_BUILTIN;
IPAddress ip(192, 168, 1, 202); // ip of Client
IPAddress gateway(192,168,1,254); // gateway of your network
IPAddress subnet(255,255,255,0);
IPAddress dns(192, 168, 1, 254);
unsigned long delays=2000;
String theme = “darkly”;
long Day=0;
int Hour =0;
int Minute=0;
int Second=0;
int HighMillis=0;
int Rollover=0;
String bmp_stv1,bmp_spv1,bmp_sav1; //BMP sensor string values
float bmp_tv1,bmp_tpv1,bmp_tlv1,bmp_thv1; //BMP temperature sensors float values
float bmp_hv1,bmp_hpv1,bmp_hlv1,bmp_hhv1; //BMP humidity sensor float values
float bmp_av1,bmp_apv1,bmp_alv1,bmp_ahv1; //BMP atmospheric sensor float values
String dht_stv1,dht_shv1; //DHT22 sensor string values
float dht_tv1,dht_tpv1,dht_tlv1,dht_thv1; //DHT22 temperature sensor float values
float dht_hv1,dht_hpv1,dht_hlv1,dht_hhv1; //DHT22 humidity sensor float values
String lightsv1,lightsv2,lightsv3,lightsv4,lightsv5;
int lightv1,lightv2,lightv3,lightv4,lightv5;
int lightpv1,lightpv2,lightpv3,lightpv4,lightpv5;
String etatGpio[5] = {“HOME”,“Page2”,“Page3”,“Page4”,“Page5”};
const uint8_t GPIOPIN[5] = {1,2,3,4,5};
WiFiClient client;
String getwebPage1();
String getwebPage1b();
void handleRoot() {
digitalWrite(led, 1);
server.send ( 200, “text/html”, getwebPage1() );
server.sendContent(getwebPage1b() );
server.sendContent(“”);
//server.sendContent(getwebPage1b() );
digitalWrite(led, 0);
}
void handleNotFound(){
digitalWrite(led, 1);
String message = “File Not Found\n\n”;
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET)?“GET”:“POST”;
message += "\nArguments: ";
message += server.args();
message += “\n”;
for (uint8_t i=0; i<server.args(); i++){
message += " " + server.argName(i) + ": " + server.arg(i) + “\n”;
}
server.send(404, “text/plain”, message);
digitalWrite(led, 0);
}
void setup(void){
pinMode(led, OUTPUT);
digitalWrite(led, 0);
Serial.begin(115200);
Serial.println(“Booting”);
WiFi.config(ip, dns, gateway, subnet);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println(“Connection Failed! Rebooting…”);
delay(5000);
ESP.restart();
}
if (MDNS.begin(“esp8266”)) {
Serial.println(“MDNS responder started”);
}
server.on(“/”, handleRoot);
server.on(“/inline”, {
server.send(200, “text/plain”, “this works as well”);
});
server.onNotFound(handleNotFound);
ArduinoOTA.onStart( {
String type;
if (ArduinoOTA.getCommand() == U_FLASH)
type = “sketch”;
else // U_SPIFFS
type = “filesystem”;
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
Serial.println("Start updating " + type);
});
ArduinoOTA.onEnd( {
Serial.println(“\nEnd”);
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf(“Progress: %u%%\r”, (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println(“Auth Failed”);
else if (error == OTA_BEGIN_ERROR) Serial.println(“Begin Failed”);
else if (error == OTA_CONNECT_ERROR) Serial.println(“Connect Failed”);
else if (error == OTA_RECEIVE_ERROR) Serial.println(“Receive Failed”);
else if (error == OTA_END_ERROR) Serial.println(“End Failed”);
});
ArduinoOTA.begin();
Serial.println(“Ready”);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
server.begin();
Serial.println(“HTTP server started”);
pinMode(2,OUTPUT);
}
void loop(void){
ArduinoOTA.handle();
server.handleClient();
digitalWrite(led,0);
digitalWrite(2,1);
for (int i=0; i <=10; i++) {
ArduinoOTA.handle();
server.handleClient();
delay(20);}
digitalWrite(led,1);
digitalWrite(2,0);
for (int i=0; i <=10; i++) {
ArduinoOTA.handle();
server.handleClient();
delay(20);}
}
String getwebPage1(){
// Return a string containing the HTML code of the page
String page = “”;
page += “”;
page += “”;
page += “ESP8266 Demo ”;
page += “
page += “
page += “
page += "
Monitoring Service ESP8266 ";
page += " ";
page += "Up Time: ";
page += Day;
page += " Days ";
page += Hour;
page += " Hours ";
page += Minute;
page += " Minutes ";
page += Second;
page += " Seconds ";
page += “
”;page += “
Mini station Conservatory
”;page += “
- ”;
- ”;
page += “ ”;
page += dht_tv1;page += “ Temperature”;
page += “ - ”;
page += “ - ”;
page += “ - ”;
page += “ ”;
page += dht_hv1;
page += “ Humidity”;
page += “ - ”;
page += “ - ”;
page += “ ”;
page += bmp_hv1;
page += “ Atmospheric Pressure”;//*************
page += “ - ”;
page += “ - ”;
page += “ ”;
page += lightv1;
page += “ Light Value ”;
page += “
page += “
page += “”; // Chart of readings
page += “”;
page += “”; // Table content
page += “”;
page += “
page += dht_hv1;
page += “%”;
page += “”;
page += “”;
page += “
Sensor | Measurement | Value | PV | Low | High |
---|---|---|---|---|---|
DHT22 | Temperature | ”; // First line : temperature page += dht_tv1; page += “°C |
”; page += dht_tpv1; page += “ |
”; page += dht_tlv1; page += “ |
”; page += dht_thv1; page += “ |
DHT22 | Humidity | ”; // 2nd line : humidity ************************* | |||
”; page += dht_hpv1; page += “ |
”; page += dht_hlv1; page += “ |
”; page += dht_hhv1; page+= “ |
|||
BMP280 | Temperature | ”; // 3th line : atmospheric pressure page += bmp_tv1; page += “°C |
”; page += bmp_tpv1; page += “ |
”; page += bmp_tlv1; page += “ |
”; page += bmp_thv1; page += “ |
BMP280 | Atmospheric Pressure | ”; // 3th line : atmospheric pressure page += bmp_hv1; page += “mbar |
”; page += bmp_hpv1; page += “ |
”; page += bmp_hlv1; page += “ |
”; page += bmp_hhv1; return page; } String getwebPage1b(){ String page = “ |
Photoresistor | Light | ”; // 4th line : Light page += lightv1; page += “% |
”; page += lightpv1; page += " % |
"; page += “ |
page += “
page += “
page += “”;
page += “<button type='button submit’name=‘1’ value=‘HOME’ class=‘btn btn-info’>”;
page += etatGpio[0];
page += “”;
page += “<button type='button submit’name=‘2’ value=‘Page2’ class=‘btn btn-primary’> ”;
page += etatGpio[1];
page += “”;
page += “<button type='button submit’name=‘3’ value=‘Page3’ class=‘btn btn-success’>”;
page += etatGpio[2];
page += “”;
page += “<button type='button submit’name=‘4’ value=‘Page4’ class=‘btn btn-warning’>”;
page += etatGpio[3];
page += “”;
page += “<button type='button submit’name=‘5’ value=‘Page5’ class=‘btn btn-danger’>”;
page += etatGpio[4];
page += “”;
page += “
return page;
}
¬¬¬