123456789101112131415161718192021222324252627282930313233343536373839 |
- #include <ESP8266WiFi.h>
- #include <ESPAsyncTCP.h>
- #include <ESPAsyncWebServer.h>
- #include <AsyncElegantOTA.h>
- const char* ssid = "........";
- const char* password = "........";
- AsyncWebServer server(80);
- void setup(void) {
- Serial.begin(115200);
- WiFi.mode(WIFI_STA);
- 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());
- server.on("/", HTTP_GET, [](AsyncWebServerRequest *request) {
- request->send(200, "text/plain", "Hi! I am ESP8266.");
- });
- AsyncElegantOTA.begin(&server); // Start ElegantOTA
- server.begin();
- Serial.println("HTTP server started");
- }
- void loop(void) {
- }
|