12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- #if defined(ARDUINO_ARCH_ESP8266)
- #include <ESP8266WiFi.h>
- #include <ESP8266WebServer.h>
- typedef ESP8266WebServer WiFiWebServer;
- #elif defined(ARDUINO_ARCH_ESP32)
- #include <WiFi.h>
- #include <WebServer.h>
- typedef WebServer WiFiWebServer;
- #endif
- #include <AutoConnect.h>
- WiFiWebServer server;
- AutoConnect portal(server);
- AutoConnectConfig config;
- void setup() {
- delay(1000);
- Serial.begin(115200);
- Serial.println();
-
- server.on("/", []() {
- String content = R"(
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1">
- </head>
- <body>
- Place the root page with the sketch application. 
- __AC_LINK__
- </body>
- </html>
- )";
- content.replace("__AC_LINK__", String(AUTOCONNECT_LINK(COG_16)));
- server.send(200, "text/html", content);
- });
- config.ota = AC_OTA_BUILTIN;
- portal.config(config);
- portal.begin();
- }
- void loop() {
- portal.handleClient();
- }
|