41 lines
1009 B
C++
41 lines
1009 B
C++
#include "ESPAsyncTCP.h"
|
|
#include "ESPAsyncWebServer.h"
|
|
#include <ESP8266mDNS.h>
|
|
#include <LittleFS.h>
|
|
|
|
#include "AP_setup.h"
|
|
|
|
const char* domain_name = "prüfstand";
|
|
const char* AP_NamePrefix = "Prüfstand ";
|
|
|
|
void startMDNS() {
|
|
if (!MDNS.begin(domain_name, WiFi.softAPIP())) {
|
|
Serial.println("[ERROR] MDNS responder did not setup");
|
|
while (1) {
|
|
delay(1000);
|
|
}
|
|
} else {
|
|
Serial.println("[INFO] MDNS setup is successful!");
|
|
}
|
|
}
|
|
|
|
String getAPName() {
|
|
uint8_t mac[WL_MAC_ADDR_LENGTH];
|
|
WiFi.softAPmacAddress(mac);
|
|
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
|
|
String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
|
|
macID.toUpperCase();
|
|
return AP_NamePrefix + macID;
|
|
}
|
|
|
|
void initAccessPoint() {
|
|
Serial.println("\n[INFO] Configuring access point");
|
|
WiFi.mode(WIFI_AP);
|
|
|
|
WiFi.softAP(getAPName().c_str(), NULL);
|
|
|
|
startMDNS();
|
|
MDNS.addService("http", "tcp", 80);
|
|
Serial.print("[INFO] Started access point at IP ");
|
|
Serial.println(WiFi.softAPIP());
|
|
} |