-
Notifications
You must be signed in to change notification settings - Fork 0
/
SoftAP.cpp
35 lines (27 loc) · 854 Bytes
/
SoftAP.cpp
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
#include "SoftAP.h"
#include "ClockWebServer.h"
void SoftAP::init() {
startAp();
/* Setup the DNS server redirecting all the domains to the apIP */
_dnsServer = new DNSServer();
_dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
_dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
}
void SoftAP::run() {
_display->clear();
_display->setBits(MINUTE1, 0, 255, 0, 0b01011111); // A
_display->setBits(MINUTE2, 0, 255, 0, 0b00011111, true); // P
while(1) {
_dnsServer->processNextRequest();
yield();
}
}
void SoftAP::startAp() {
IPAddress apIP(192, 168, 4, 1);
IPAddress netMask(255, 255, 255, 0);
WiFi.softAPConfig(apIP, apIP, netMask);
WiFi.softAP(_ssid, _passphrase);
delay(500); // Without delay I've seen the IP address blank
Serial.print(F("AP IP address: "));
Serial.println(WiFi.softAPIP());
}