-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathWIFI.ino
44 lines (36 loc) · 1.09 KB
/
WIFI.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// CaptivePortal from DNS-server example
#include <DNSServer.h>
const byte DNS_PORT = 53;
IPAddress apIP(10, 1, 1, 1);
DNSServer dnsServer;
void APsetup() {
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
WiFi.softAP("Commodore C64");
// if DNSServer is started with "*" for domain name, it will reply with
// provided IP to all DNS request
dnsServer.start(DNS_PORT, "*", apIP);
// replay to all requests with same HTML
server.onNotFound([]() {
Serial.println("Captive page...");
server.send_P ( 200, "text/html", gui);
//SerialNotFound(); // uncomment for request diagnostics
});
}
void APloop() {
dnsServer.processNextRequest();
}
void SerialNotFound() {
String message = "";
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";
}
Serial.println(message);
}