Hello I've been using the ESP8266 for home automation and i run a website on it to control everything i want. I want to have a button on the website that takes me to the ip of another ESP8266 but i cant because of a bug on the Arduino IDE(Or at least i think it's a bug). I use
char webpage[] PROGMEM = R"=====(
)=====";
to store the webpage now the thing is that i have a button that i want it to send to this ip : "//192.168.1.6" but every time i use double slash even though its text it gives me a weird error.
Error:
Arduino: 1.8.5 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, ck, 26 MHz, 40MHz, QIO, 512K (no SPIFFS), v2 Prebuilt (MSS=536), Disabled, None, 115200"
C:\Users\Aggelos\Desktop\Web_UI\Web_UI_Second_ESP.ino\Web_UI_Second_ESP.ino.ino: In function 'void loop()':
Web_UI_Second_ESP.ino:182: error: 'webthings' was not declared in this scope
webthings();
^
exit status 1
'webthings' was not declared in this scope
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
This is my Whole code:
#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266WebServer.h>
#include <WebSocketsServer.h>
ESP8266WebServer server;
WebSocketsServer webSocket = WebSocketsServer(81);
//char server[]= "www.google.com";
int port = 443;
WiFiClientSecure client;
char* ssid = "AGGELOS SSID";
char* password = "12345678900";
char webpage[] PROGMEM = R"=====(
a:link{
color: white;
text-decoration: none;
}
a:visited{
color: white;
text-decoration: none;
}
a:hover{
color: red;
text-decoration: underline;
}
a:active{
color: grey;
text-decoration: underline;
}
.active{
background-color: black;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
padding: 14px 16px;
text-align: center;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
.grid-container {
display: grid;
grid-row-gap: 20px;
padding: 10px;
}
.grid-item{
text-align: center;
}
Second Esp
This Is A Test
This Is A Test
This Is A Test
)=====";
void handleRoot()
{
server.send_P(200, "text/html", webpage);
}
void handleNotFound()
{
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);
}
void setup()
{
WiFi.begin(ssid,password);
IPAddress ip(192,168,1,5);
IPAddress gateway(192,168,1,254);
IPAddress subnet(255,255,255,0);
WiFi.config(ip, gateway, subnet);
Serial.begin(115200);
while(WiFi.status()!=WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/",{
server.send_P(200, "text/html", webpage);
});
server.on("/home",{
server.send_P(200, "text/html", webpage);
});
server.begin();
webSocket.begin();
//webSocket.onEvent(webSocketEvent);
}
void loop()
{
webthings();
}
void webthings(){
webSocket.loop();
server.handleClient();
if(Serial.available() > 0){
char c[] = {(char)Serial.read()};
webSocket.broadcastTXT(c, sizeof(c));
}
}