Mam do was pytanie jak przekazac
na strone www poprzez
Cały Kod
Kod:
Serial.read()
na strone www poprzez
Kod:
server.on("/serial_read", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", "");
});
Cały Kod
Kod:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "pages.h"
#include <SoftwareSerial.h>
SoftwareSerial ESPserial(2, 3); // RX | TX
#ifndef APSSID
#define APSSID "ESPap"
#define APPSK "thereisnospoon"
#endif
/* Set these to your desired credentials. */
const char *ssid = APSSID;
const char *password = APPSK;
String readString;
AsyncWebServer server(80);
void setup() {
delay(1000);
Serial.begin(115200);
// Start the software serial for communication with the ESP8266
ESPserial.begin(9600);
Serial.println("");
Serial.println("Remember to to set Both NL & CR in the serial monitor.");
Serial.println("Ready");
Serial.println("");
Serial.println();
Serial.print("Configuring access point...");
/* You can remove the password parameter if you want the AP to be open. */
WiFi.softAP(ssid, password);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ESP_HTML_HOMEPAGE, ESP_HTML_SIZE);
response->addHeader("Content-Encoding","gzip");
request->send(response);
});
server.on("/serial", HTTP_GET, [](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/html", ESP_HTML_SERIAL, ESP_HTML_SIZE);
response->addHeader("Content-Encoding","gzip");
request->send(response);
});
server.on("/serial_read", HTTP_GET, [](AsyncWebServerRequest *request){
request->send_P(200, "text/plain", "NARAZIE NIC");
});
server.begin();
Serial.println("HTTP server started");
}
void loop() {
// listen for communication from the ESP8266 and then write it to the serial monitor
if ( ESPserial.available() ) { Serial.write( ESPserial.read() ); }
// listen for user input and send it to the ESP8266
if ( Serial.available() ) { ESPserial.write( Serial.read() ); }
}