Как мне исправить этот код так что бы при подключении к модулю с устройства я поподал на сервер заранее спасибо server.send(200, "text/html", " <body bgcolor=\"black\"> <a href=\"/spin\"> <img src=\" https://lh3.googleusercontent.com/-...bS4vGCgEhgHUn1az6wZPgCLcB/w426-h637/spin.png\" width = \"100%\
Вот код
[HASHTAG]#include[/HASHTAG] <ESP8266WiFi.h>
[HASHTAG]#include[/HASHTAG] <WiFiClient.h>
[HASHTAG]#include[/HASHTAG] <ESP8266WebServer.h>
[HASHTAG]#include[/HASHTAG] <ESP8266mDNS.h>
const char* ssid = "LadyaZ";
const char* password = "123qwezxc";
ESP8266WebServer server(80);
void handleRoot() {
server.send(200, "text/html", " <body bgcolor=\"black\"> <a href=\"/spin\"> <img src=\" https://lh3.googleusercontent.com/-...bS4vGCgEhgHUn1az6wZPgCLcB/w426-h637/spin.png\" width = \"100%\"> </a> " );
}
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(void){
pinMode (2, OUTPUT);
digitalWrite(2,0);
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/spin", [](){
server.send (200, "text/html", " <body bgcolor=\"black\"> <a href=\"/spin\"> <img src=\" https://lh3.googleusercontent.com/-...bS4vGCgEhgHUn1az6wZPgCLcB/w426-h637/spin.png\" width = \"100%\"> </a> " );
m = server.uri();
Serial.println(m);
digitalWrite(2,1);
delay(200);
digitalWrite(2,0);
});
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}
Вот код
[HASHTAG]#include[/HASHTAG] <ESP8266WiFi.h>
[HASHTAG]#include[/HASHTAG] <WiFiClient.h>
[HASHTAG]#include[/HASHTAG] <ESP8266WebServer.h>
[HASHTAG]#include[/HASHTAG] <ESP8266mDNS.h>
const char* ssid = "LadyaZ";
const char* password = "123qwezxc";
ESP8266WebServer server(80);
void handleRoot() {
server.send(200, "text/html", " <body bgcolor=\"black\"> <a href=\"/spin\"> <img src=\" https://lh3.googleusercontent.com/-...bS4vGCgEhgHUn1az6wZPgCLcB/w426-h637/spin.png\" width = \"100%\"> </a> " );
}
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(void){
pinMode (2, OUTPUT);
digitalWrite(2,0);
Serial.begin(115200);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
if (MDNS.begin("esp8266")) {
Serial.println("MDNS responder started");
}
server.on("/", handleRoot);
server.on("/spin", [](){
server.send (200, "text/html", " <body bgcolor=\"black\"> <a href=\"/spin\"> <img src=\" https://lh3.googleusercontent.com/-...bS4vGCgEhgHUn1az6wZPgCLcB/w426-h637/spin.png\" width = \"100%\"> </a> " );
m = server.uri();
Serial.println(m);
digitalWrite(2,1);
delay(200);
digitalWrite(2,0);
});
server.onNotFound(handleNotFound);
server.begin();
Serial.println("HTTP server started");
}
void loop(void){
server.handleClient();
}