Refactored wifi.h into module
This commit is contained in:
parent
74067f0f87
commit
401d5c17c4
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <LittleFS.h>
|
||||
#include "settings.h"
|
||||
#include "wifi.h"
|
||||
|
||||
/*
|
||||
Shitty code used less resources so I will keep this clusterfuck as it is,
|
||||
|
@ -869,7 +870,7 @@ void CLI::runCommand(String input) {
|
|||
prnt(int(f.size()));
|
||||
prntln(str(CLI_BYTES));
|
||||
}
|
||||
printWifiStatus();
|
||||
wifi::printStatus();
|
||||
prntln(CLI_SYSTEM_FOOTER);
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1094,7 @@ void CLI::runCommand(String input) {
|
|||
// ------- loop function ----- //
|
||||
currentTime = millis();
|
||||
|
||||
wifiUpdate(); // manage access point
|
||||
wifi::update(); // manage access point
|
||||
scan.update(); // run scan
|
||||
attack.update(); // run attacks
|
||||
ssids.update(); // run random mode, if enabled
|
||||
|
@ -1217,12 +1218,12 @@ void CLI::runCommand(String input) {
|
|||
}
|
||||
}
|
||||
|
||||
startAP(path, ssid, password, ch, hidden, captivePortal);
|
||||
wifi::startNewAP(path, ssid, password, ch, hidden, captivePortal);
|
||||
}
|
||||
|
||||
// stopap
|
||||
else if (eqlsCMD(0, CLI_STOPAP)) {
|
||||
stopAP();
|
||||
wifi::stopAP();
|
||||
}
|
||||
|
||||
// ===== SCREEN ===== //
|
||||
|
|
|
@ -41,9 +41,6 @@ extern bool appendFile(String path, String& buf);
|
|||
extern bool removeLines(String path, int lineFrom, int lineTo);
|
||||
extern bool replaceLine(String path, int line, String& buf);
|
||||
extern bool equalsKeyword(const char* str, const char* keyword);
|
||||
extern void printWifiStatus();
|
||||
extern void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
|
||||
extern void wifiUpdate();
|
||||
|
||||
class CLI {
|
||||
public:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "Scan.h"
|
||||
|
||||
#include "settings.h"
|
||||
#include "wifi.h"
|
||||
|
||||
Scan::Scan() {
|
||||
list = new SimpleList<uint16_t>;
|
||||
|
@ -104,7 +105,7 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
|||
prntln();
|
||||
|
||||
// enable sniffer
|
||||
stopAP();
|
||||
wifi::stopAP();
|
||||
wifi_promiscuous_enable(true);
|
||||
}
|
||||
|
||||
|
@ -120,7 +121,7 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
|||
prntln(channelHop ? str(SC_ONE_TO) + (String)14 : (String)wifi_channel);
|
||||
|
||||
// enable sniffer
|
||||
stopAP();
|
||||
wifi::stopAP();
|
||||
wifi_promiscuous_enable(true);
|
||||
}
|
||||
|
||||
|
@ -128,7 +129,7 @@ void Scan::start(uint8_t mode, uint32_t time, uint8_t nextmode, uint32_t continu
|
|||
else if (mode == SCAN_MODE_OFF) {
|
||||
wifi_promiscuous_enable(false);
|
||||
|
||||
if (settings::getWebSettings().enabled) resumeAP();
|
||||
if (settings::getWebSettings().enabled) wifi::resumeAP();
|
||||
prntln(SC_STOPPED);
|
||||
save(true);
|
||||
|
||||
|
|
|
@ -29,8 +29,6 @@ extern void setWifiChannel(uint8_t ch);
|
|||
extern bool appendFile(String path, String& buf);
|
||||
extern bool writeFile(String path, String& buf);
|
||||
extern void readFileToSerial(const String path);
|
||||
extern void resumeAP();
|
||||
extern void stopAP();
|
||||
extern String escape(String str);
|
||||
|
||||
class Scan {
|
||||
|
|
|
@ -33,7 +33,6 @@ extern "C" {
|
|||
#include "CLI.h"
|
||||
#include "DisplayUI.h"
|
||||
#include "A_config.h"
|
||||
#include "webfiles.h"
|
||||
|
||||
#include "LED.h"
|
||||
|
||||
|
@ -108,13 +107,7 @@ void setup() {
|
|||
settings::save();
|
||||
#endif // ifndef RESET_SETTINGS
|
||||
|
||||
// set mac address
|
||||
wifi_set_macaddr(STATION_IF, (uint8_t*)settings::getWifiSettings().mac_st);
|
||||
wifi_set_macaddr(SOFTAP_IF, (uint8_t*)settings::getWifiSettings().mac_ap);
|
||||
|
||||
// start WiFi
|
||||
WiFi.mode(WIFI_OFF);
|
||||
wifi_set_opmode(STATION_MODE);
|
||||
wifi::begin();
|
||||
wifi_set_promiscuous_rx_cb([](uint8_t* buf, uint16_t len) {
|
||||
scan.sniffer(buf, len);
|
||||
});
|
||||
|
@ -126,7 +119,7 @@ void setup() {
|
|||
}
|
||||
|
||||
// copy web files to SPIFFS
|
||||
copyWebFiles(false);
|
||||
//copyWebFiles(false);
|
||||
|
||||
// load everything else
|
||||
names.load();
|
||||
|
@ -139,9 +132,6 @@ void setup() {
|
|||
// set channel
|
||||
setWifiChannel(settings::getWifiSettings().channel);
|
||||
|
||||
// load Wifi settings: SSID, password,...
|
||||
loadWifiConfigDefaults();
|
||||
|
||||
// dis/enable serial command interface
|
||||
if (settings::getCLISettings().enabled) {
|
||||
cli.enable();
|
||||
|
@ -152,7 +142,7 @@ void setup() {
|
|||
}
|
||||
|
||||
// start access point/web interface
|
||||
if (settings::getWebSettings().enabled) startAP();
|
||||
if (settings::getWebSettings().enabled) wifi::startAP();
|
||||
|
||||
// STARTED
|
||||
prntln(SETUP_STARTED);
|
||||
|
@ -168,7 +158,7 @@ void loop() {
|
|||
currentTime = millis();
|
||||
|
||||
led.update(); // update LED color
|
||||
wifiUpdate(); // manage access point
|
||||
wifi::update(); // manage access point
|
||||
attack.update(); // run attacks
|
||||
displayUI.update();
|
||||
cli.update(); // read and run serial input
|
||||
|
|
|
@ -541,6 +541,36 @@ const char W_BAD_ARGS[] PROGMEM = "BAD ARGS";
|
|||
const char W_BAD_PATH[] PROGMEM = "BAD PATH";
|
||||
const char W_FILE_NOT_FOUND[] PROGMEM = "ERROR 404 File Not Found";
|
||||
const char W_STARTED_AP[] PROGMEM = "Started AP";
|
||||
const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files
|
||||
const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
|
||||
|
||||
const char W_HTML[] PROGMEM = "text/html";
|
||||
const char W_CSS[] PROGMEM = "text/css";
|
||||
const char W_JS[] PROGMEM = "application/javascript";
|
||||
const char W_PNG[] PROGMEM = "image/png";
|
||||
const char W_GIF[] PROGMEM = "image/gif";
|
||||
const char W_JPG[] PROGMEM = "image/jpeg";
|
||||
const char W_ICON[] PROGMEM = "image/x-icon";
|
||||
const char W_XML[] PROGMEM = "text/xml";
|
||||
const char W_XPDF[] PROGMEM = "application/x-pdf";
|
||||
const char W_XZIP[] PROGMEM = "application/x-zip";
|
||||
const char W_GZIP[] PROGMEM = "application/x-gzip";
|
||||
const char W_JSON[] PROGMEM = "application/json";
|
||||
const char W_TXT[] PROGMEM = "text/plain";
|
||||
|
||||
const char W_DOT_HTM[] PROGMEM = ".htm";
|
||||
const char W_DOT_HTML[] PROGMEM = ".html";
|
||||
const char W_DOT_CSS[] PROGMEM = ".css";
|
||||
const char W_DOT_JS[] PROGMEM = ".js";
|
||||
const char W_DOT_PNG[] PROGMEM = ".png";
|
||||
const char W_DOT_GIF[] PROGMEM = ".gif";
|
||||
const char W_DOT_JPG[] PROGMEM = ".jpg";
|
||||
const char W_DOT_ICON[] PROGMEM = ".ico";
|
||||
const char W_DOT_XML[] PROGMEM = ".xml";
|
||||
const char W_DOT_PDF[] PROGMEM = ".pdf";
|
||||
const char W_DOT_ZIP[] PROGMEM = ".zip";
|
||||
const char W_DOT_GZIP[] PROGMEM = ".gz";
|
||||
const char W_DOT_JSON[] PROGMEM = ".json";
|
||||
|
||||
// ===== SETTINGS ====== //
|
||||
// Version
|
||||
|
|
|
@ -0,0 +1,423 @@
|
|||
/*
|
||||
Copyright (c) 2020 Stefan Kremser (@Spacehuhn)
|
||||
This software is licensed under the MIT License. See the license file for details.
|
||||
Source: github.com/spacehuhn/esp8266_deauther
|
||||
*/
|
||||
|
||||
#include "wifi.h"
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
#include "language.h"
|
||||
#include "debug.h"
|
||||
#include "settings.h"
|
||||
#include "cli.h"
|
||||
#include "attack.h"
|
||||
#include "scan.h"
|
||||
|
||||
extern bool progmemToSpiffs(const char* adr, int len, String path);
|
||||
|
||||
#include "webfiles.h"
|
||||
|
||||
extern Scan scan;
|
||||
extern CLI cli;
|
||||
extern Attack attack;
|
||||
|
||||
typedef enum wifi_mode_t {
|
||||
off = 0,
|
||||
ap = 1,
|
||||
st = 2
|
||||
} wifi_mode_t;
|
||||
|
||||
typedef struct ap_settings_t {
|
||||
char path[33];
|
||||
char ssid[33];
|
||||
char password[65];
|
||||
uint8_t channel;
|
||||
bool hidden;
|
||||
bool captive_portal;
|
||||
} ap_settings_t;
|
||||
|
||||
namespace wifi {
|
||||
// ===== PRIVATE ===== //
|
||||
wifi_mode_t mode;
|
||||
ap_settings_t ap_settings;
|
||||
|
||||
// Server and other global objects
|
||||
ESP8266WebServer server(80);
|
||||
DNSServer dns;
|
||||
IPAddress ip(192, 168, 4, 1);
|
||||
IPAddress netmask(255, 255, 255, 0);
|
||||
|
||||
void setPath(String path) {
|
||||
if (path.charAt(0) != '/') {
|
||||
path = '/' + path;
|
||||
}
|
||||
|
||||
if(path.length() > 32) {
|
||||
debuglnF("ERROR: Path longer than 32 characters");
|
||||
} else {
|
||||
strncpy(ap_settings.path, path.c_str(), 32);
|
||||
}
|
||||
}
|
||||
|
||||
void setSSID(String ssid) {
|
||||
if(ssid.length() > 32) {
|
||||
debuglnF("ERROR: SSID longer than 32 characters");
|
||||
} else {
|
||||
strncpy(ap_settings.ssid, ssid.c_str(), 32);
|
||||
}
|
||||
}
|
||||
|
||||
void setPassword(String password) {
|
||||
if(password.length() > 64) {
|
||||
debuglnF("ERROR: Password longer than 64 characters");
|
||||
} else if (password.length() < 8) {
|
||||
debuglnF("ERROR: Password must be at least 8 characters long");
|
||||
} else {
|
||||
strncpy(ap_settings.password, password.c_str(), 64);
|
||||
}
|
||||
}
|
||||
|
||||
void setChannel(uint8_t ch) {
|
||||
if(ch < 1 && ch > 14) {
|
||||
debuglnF("ERROR: Channel must be withing the range of 1-14");
|
||||
} else {
|
||||
ap_settings.channel = ch;
|
||||
}
|
||||
}
|
||||
|
||||
void setHidden(bool hidden) {
|
||||
ap_settings.hidden = hidden;
|
||||
}
|
||||
|
||||
void setCaptivePortal(bool captivePortal) {
|
||||
ap_settings.captive_portal = captivePortal;
|
||||
}
|
||||
|
||||
void handleFileList() {
|
||||
if (!server.hasArg("dir")) {
|
||||
server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||
return;
|
||||
}
|
||||
|
||||
String path = server.arg("dir");
|
||||
// debugF("handleFileList: ");
|
||||
// debugln(path);
|
||||
|
||||
Dir dir = LittleFS.openDir(path);
|
||||
|
||||
String output = String('{'); // {
|
||||
File entry;
|
||||
bool first = true;
|
||||
|
||||
while (dir.next()) {
|
||||
entry = dir.openFile("r");
|
||||
|
||||
if (first) first = false;
|
||||
else output += ','; // ,
|
||||
|
||||
output += '['; // [
|
||||
output += '"' + entry.name() + '"'; // "filename"
|
||||
output += ']'; // ]
|
||||
|
||||
entry.close();
|
||||
}
|
||||
|
||||
output += CLOSE_BRACKET;
|
||||
server.send(200, str(W_JSON).c_str(), output);
|
||||
}
|
||||
|
||||
String getContentType(String filename) {
|
||||
if (server.hasArg("download")) return String(F("application/octet-stream"));
|
||||
else if (filename.endsWith(str(W_DOT_GZIP))) filename = filename.substring(0, filename.length() - 3);
|
||||
else if (filename.endsWith(str(W_DOT_HTM))) return str(W_HTML);
|
||||
else if (filename.endsWith(str(W_DOT_HTML))) return str(W_HTML);
|
||||
else if (filename.endsWith(str(W_DOT_CSS))) return str(W_CSS);
|
||||
else if (filename.endsWith(str(W_DOT_JS))) return str(W_JS);
|
||||
else if (filename.endsWith(str(W_DOT_PNG))) return str(W_PNG);
|
||||
else if (filename.endsWith(str(W_DOT_GIF))) return str(W_GIF);
|
||||
else if (filename.endsWith(str(W_DOT_JPG))) return str(W_JPG);
|
||||
else if (filename.endsWith(str(W_DOT_ICON))) return str(W_ICON);
|
||||
else if (filename.endsWith(str(W_DOT_XML))) return str(W_XML);
|
||||
else if (filename.endsWith(str(W_DOT_PDF))) return str(W_XPDF);
|
||||
else if (filename.endsWith(str(W_DOT_ZIP))) return str(W_XZIP);
|
||||
else if (filename.endsWith(str(W_DOT_JSON))) return str(W_JSON);
|
||||
else return str(W_TXT);
|
||||
}
|
||||
|
||||
bool handleFileRead(String path) {
|
||||
// prnt(W_AP_REQUEST);
|
||||
// prnt(path);
|
||||
|
||||
if (path.charAt(0) != '/') path = '/' + path;
|
||||
if (path.charAt(path.length() - 1) == '/') path += String(F("index.html"));
|
||||
|
||||
String contentType = getContentType(path);
|
||||
|
||||
if (!LittleFS.exists(path)) {
|
||||
if (LittleFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
|
||||
else if (LittleFS.exists(String(ap_settings.path) + path)) path = String(ap_settings.path) + path;
|
||||
else if (LittleFS.exists(String(ap_settings.path) + path + str(W_DOT_GZIP))) path = String(ap_settings.path) + path + str(W_DOT_GZIP);
|
||||
else {
|
||||
// prntln(W_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
File file = LittleFS.open(path, "r");
|
||||
server.streamFile(file, contentType);
|
||||
file.close();
|
||||
// prnt(SPACE);
|
||||
// prntln(W_OK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void sendProgmem(const char* ptr, size_t size, const char* type) {
|
||||
server.sendHeader("Content-Encoding", "gzip");
|
||||
server.sendHeader("Cache-Control", "max-age=86400");
|
||||
server.send_P(200, str(type).c_str(), ptr, size);
|
||||
}
|
||||
|
||||
// ===== PUBLIC ====== //
|
||||
void begin() {
|
||||
// Set settings
|
||||
setPath("/web");
|
||||
setSSID(settings::getAccessPointSettings().ssid);
|
||||
setPassword(settings::getAccessPointSettings().password);
|
||||
setChannel(1);
|
||||
setHidden(settings::getAccessPointSettings().hidden);
|
||||
setCaptivePortal(settings::getWebSettings().captive_portal);
|
||||
|
||||
// Set mode
|
||||
mode = wifi_mode_t::off;
|
||||
WiFi.mode(WIFI_OFF);
|
||||
wifi_set_opmode(STATION_MODE);
|
||||
|
||||
// Set mac address
|
||||
wifi_set_macaddr(STATION_IF, (uint8_t*)settings::getWifiSettings().mac_st);
|
||||
wifi_set_macaddr(SOFTAP_IF, (uint8_t*)settings::getWifiSettings().mac_ap);
|
||||
}
|
||||
|
||||
String getMode() {
|
||||
switch (mode) {
|
||||
case wifi_mode_t::off:
|
||||
return W_MODE_OFF;
|
||||
case wifi_mode_t::ap:
|
||||
return W_MODE_AP;
|
||||
case wifi_mode_t::st:
|
||||
return W_MODE_ST;
|
||||
default:
|
||||
return String();
|
||||
}
|
||||
}
|
||||
|
||||
void printStatus() {
|
||||
prnt(String(F("[WiFi] Path: '")));
|
||||
prnt(ap_settings.path);
|
||||
prnt(String(F("', Mode: '")));
|
||||
prnt(getMode());
|
||||
prnt(String(F("', SSID: '")));
|
||||
prnt(ap_settings.ssid);
|
||||
prnt(String(F("', password: '")));
|
||||
prnt(ap_settings.password);
|
||||
prnt(String(F("', channel: '")));
|
||||
prnt(ap_settings.channel);
|
||||
prnt(String(F("', hidden: ")));
|
||||
prnt(b2s(ap_settings.hidden));
|
||||
prnt(String(F(", captive-portal: ")));
|
||||
prntln(b2s(ap_settings.captive_portal));
|
||||
}
|
||||
|
||||
void startNewAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal) {
|
||||
setPath(path);
|
||||
setSSID(ssid);
|
||||
setPassword(password);
|
||||
setChannel(ch);
|
||||
setHidden(hidden);
|
||||
setCaptivePortal(captivePortal);
|
||||
|
||||
startAP();
|
||||
}
|
||||
/*
|
||||
void startAP(String path) {
|
||||
setPath(path):
|
||||
|
||||
startAP();
|
||||
}
|
||||
*/
|
||||
void startAP() {
|
||||
WiFi.softAPConfig(ip, ip, netmask);
|
||||
WiFi.softAP(ap_settings.ssid, ap_settings.password, ap_settings.channel, ap_settings.hidden);
|
||||
|
||||
dns.setErrorReplyCode(DNSReplyCode::NoError);
|
||||
dns.start(53, "*", ip);
|
||||
|
||||
MDNS.begin("deauth.me");
|
||||
|
||||
server.on("/list", HTTP_GET, handleFileList); // list directory
|
||||
|
||||
// ================================================================
|
||||
// post here the output of the webConverter.py
|
||||
#ifdef USE_PROGMEM_WEB_FILES
|
||||
if (!settings::getWebSettings().use_spiffs) {
|
||||
server.on("/", HTTP_GET, [] () {
|
||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
});
|
||||
server.on("/attack.html", HTTP_GET, [] () {
|
||||
sendProgmem(attackhtml, sizeof(attackhtml), W_HTML);
|
||||
});
|
||||
server.on("/index.html", HTTP_GET, [] () {
|
||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
});
|
||||
server.on("/info.html", HTTP_GET, [] () {
|
||||
sendProgmem(infohtml, sizeof(infohtml), W_HTML);
|
||||
});
|
||||
server.on("/scan.html", HTTP_GET, [] () {
|
||||
sendProgmem(scanhtml, sizeof(scanhtml), W_HTML);
|
||||
});
|
||||
server.on("/ap_settings.html", HTTP_GET, [] () {
|
||||
sendProgmem(settingshtml, sizeof(settingshtml), W_HTML);
|
||||
});
|
||||
server.on("/ssids.html", HTTP_GET, [] () {
|
||||
sendProgmem(ssidshtml, sizeof(ssidshtml), W_HTML);
|
||||
});
|
||||
server.on("/style.css", HTTP_GET, [] () {
|
||||
sendProgmem(stylecss, sizeof(stylecss), W_CSS);
|
||||
});
|
||||
server.on("/js/attack.js", HTTP_GET, [] () {
|
||||
sendProgmem(attackjs, sizeof(attackjs), W_JS);
|
||||
});
|
||||
server.on("/js/scan.js", HTTP_GET, [] () {
|
||||
sendProgmem(scanjs, sizeof(scanjs), W_JS);
|
||||
});
|
||||
server.on("/js/ap_settings.js", HTTP_GET, [] () {
|
||||
sendProgmem(settingsjs, sizeof(settingsjs), W_JS);
|
||||
});
|
||||
server.on("/js/site.js", HTTP_GET, [] () {
|
||||
sendProgmem(sitejs, sizeof(sitejs), W_JS);
|
||||
});
|
||||
server.on("/js/ssids.js", HTTP_GET, [] () {
|
||||
sendProgmem(ssidsjs, sizeof(ssidsjs), W_JS);
|
||||
});
|
||||
server.on("/lang/cn.lang", HTTP_GET, [] () {
|
||||
sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||
});
|
||||
server.on("/lang/cs.lang", HTTP_GET, [] () {
|
||||
sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||
});
|
||||
server.on("/lang/de.lang", HTTP_GET, [] () {
|
||||
sendProgmem(delang, sizeof(delang), W_JSON);
|
||||
});
|
||||
server.on("/lang/en.lang", HTTP_GET, [] () {
|
||||
sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||
});
|
||||
server.on("/lang/es.lang", HTTP_GET, [] () {
|
||||
sendProgmem(eslang, sizeof(eslang), W_JSON);
|
||||
});
|
||||
server.on("/lang/fi.lang", HTTP_GET, [] () {
|
||||
sendProgmem(filang, sizeof(filang), W_JSON);
|
||||
});
|
||||
server.on("/lang/fr.lang", HTTP_GET, [] () {
|
||||
sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||
});
|
||||
server.on("/lang/it.lang", HTTP_GET, [] () {
|
||||
sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||
});
|
||||
server.on("/lang/ru.lang", HTTP_GET, [] () {
|
||||
sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||
});
|
||||
server.on("/lang/tlh.lang", HTTP_GET, [] () {
|
||||
sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||
});
|
||||
}
|
||||
server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [] () {
|
||||
if (!settings::getWebSettings().use_spiffs) {
|
||||
if (String(settings::getWebSettings().lang) == String(F("cn"))) sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("de"))) sendProgmem(delang, sizeof(delang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("en"))) sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("es"))) sendProgmem(eslang, sizeof(eslang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("fi"))) sendProgmem(filang, sizeof(filang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("fr"))) sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("it"))) sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("ru"))) sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("tlh"))) sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||
|
||||
else handleFileRead(String(F("/web/lang/")) + String(settings::getWebSettings().lang) + String(F(".lang")));
|
||||
} else {
|
||||
handleFileRead(String(F("/web/lang/")) + String(settings::getWebSettings().lang) + String(F(".lang")));
|
||||
}
|
||||
});
|
||||
#endif /* ifdef USE_PROGMEM_WEB_FILES */
|
||||
// ================================================================
|
||||
|
||||
server.on("/run", HTTP_GET, [] () {
|
||||
server.send(200, str(W_TXT), str(W_OK).c_str());
|
||||
String input = server.arg("cmd");
|
||||
cli.exec(input);
|
||||
});
|
||||
|
||||
server.on("/attack.json", HTTP_GET, [] () {
|
||||
server.send(200, str(W_JSON), attack.getStatusJSON());
|
||||
});
|
||||
|
||||
// aggressively caching static assets
|
||||
server.serveStatic("/js", LittleFS, String(String(ap_settings.path) + "/js").c_str(), "max-age=86400");
|
||||
|
||||
// called when the url is not defined here
|
||||
// use it to load content from SPIFFS
|
||||
server.onNotFound([] () {
|
||||
if (!handleFileRead(server.uri())) {
|
||||
server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
||||
//server.send(200, "text/html", indexhtml);
|
||||
//sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
}
|
||||
});
|
||||
|
||||
server.begin();
|
||||
mode = wifi_mode_t::ap;
|
||||
|
||||
prntln(W_STARTED_AP);
|
||||
printStatus();
|
||||
}
|
||||
|
||||
void stopAP() {
|
||||
if (mode == wifi_mode_t::ap) {
|
||||
wifi_promiscuous_enable(0);
|
||||
WiFi.persistent(false);
|
||||
WiFi.disconnect(true);
|
||||
wifi_set_opmode(STATION_MODE);
|
||||
prntln(W_STOPPED_AP);
|
||||
mode = wifi_mode_t::st;
|
||||
}
|
||||
}
|
||||
|
||||
void resumeAP() {
|
||||
if (mode != wifi_mode_t::ap) {
|
||||
mode = wifi_mode_t::ap;
|
||||
wifi_promiscuous_enable(0);
|
||||
WiFi.softAPConfig(ip, ip, netmask);
|
||||
WiFi.softAP(ap_settings.ssid, ap_settings.password, ap_settings.channel, ap_settings.hidden);
|
||||
prntln(W_STARTED_AP);
|
||||
}
|
||||
}
|
||||
|
||||
void update() {
|
||||
if ((mode != wifi_mode_t::off) && !scan.isScanning()) {
|
||||
server.handleClient();
|
||||
dns.processNextRequest();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,413 +1,25 @@
|
|||
#ifndef WifiManager_h
|
||||
#define WifiManager_h
|
||||
|
||||
#include "Arduino.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <LittleFS.h>
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
#define WIFI_MODE_OFF 0
|
||||
#define WIFI_MODE_AP 1
|
||||
#define WIFI_MODE_STATION 2
|
||||
|
||||
/*
|
||||
This file contains all necessary functions for hosting and connecting to an access point.
|
||||
For compatibility and simplicity, all those functions are global.
|
||||
Copyright (c) 2020 Stefan Kremser (@Spacehuhn)
|
||||
This software is licensed under the MIT License. See the license file for details.
|
||||
Source: github.com/spacehuhn/esp8266_deauther
|
||||
*/
|
||||
|
||||
// Important strings
|
||||
const char W_DEAUTHER[] PROGMEM = "deauth.me"; // captive portal domain (alternative to 192.168.4.1)
|
||||
const char W_WEBINTERFACE[] PROGMEM = "/web"; // default folder containing the web files
|
||||
const char W_ERROR_PASSWORD[] PROGMEM = "ERROR: Password must have at least 8 characters!";
|
||||
const char W_DEFAULT_LANG[] PROGMEM = "/lang/default.lang";
|
||||
#pragma once
|
||||
|
||||
const char W_HTML[] PROGMEM = "text/html";
|
||||
const char W_CSS[] PROGMEM = "text/css";
|
||||
const char W_JS[] PROGMEM = "application/javascript";
|
||||
const char W_PNG[] PROGMEM = "image/png";
|
||||
const char W_GIF[] PROGMEM = "image/gif";
|
||||
const char W_JPG[] PROGMEM = "image/jpeg";
|
||||
const char W_ICON[] PROGMEM = "image/x-icon";
|
||||
const char W_XML[] PROGMEM = "text/xml";
|
||||
const char W_XPDF[] PROGMEM = "application/x-pdf";
|
||||
const char W_XZIP[] PROGMEM = "application/x-zip";
|
||||
const char W_GZIP[] PROGMEM = "application/x-gzip";
|
||||
const char W_JSON[] PROGMEM = "application/json";
|
||||
const char W_TXT[] PROGMEM = "text/plain";
|
||||
#include <Arduino.h>
|
||||
|
||||
const char W_DOT_HTM[] PROGMEM = ".htm";
|
||||
const char W_DOT_HTML[] PROGMEM = ".html";
|
||||
const char W_DOT_CSS[] PROGMEM = ".css";
|
||||
const char W_DOT_JS[] PROGMEM = ".js";
|
||||
const char W_DOT_PNG[] PROGMEM = ".png";
|
||||
const char W_DOT_GIF[] PROGMEM = ".gif";
|
||||
const char W_DOT_JPG[] PROGMEM = ".jpg";
|
||||
const char W_DOT_ICON[] PROGMEM = ".ico";
|
||||
const char W_DOT_XML[] PROGMEM = ".xml";
|
||||
const char W_DOT_PDF[] PROGMEM = ".pdf";
|
||||
const char W_DOT_ZIP[] PROGMEM = ".zip";
|
||||
const char W_DOT_GZIP[] PROGMEM = ".gz";
|
||||
const char W_DOT_JSON[] PROGMEM = ".json";
|
||||
namespace wifi {
|
||||
void begin();
|
||||
|
||||
// Server and other global objects
|
||||
ESP8266WebServer server(80);
|
||||
DNSServer dnsServer;
|
||||
IPAddress apIP(192, 168, 4, 1);
|
||||
IPAddress netMsk(255, 255, 255, 0);
|
||||
File fsUploadFile;
|
||||
String getMode();
|
||||
void printStatus();
|
||||
|
||||
void startNewAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal);
|
||||
//void startAP(String path);
|
||||
void startAP();
|
||||
|
||||
// current WiFi mode and config
|
||||
uint8_t wifiMode = WIFI_MODE_OFF;
|
||||
|
||||
bool wifi_config_hidden = false;
|
||||
bool wifi_config_captivePortal = false;
|
||||
String wifi_config_ssid;
|
||||
String wifi_config_password;
|
||||
String wifi_config_path;
|
||||
|
||||
void stopAP() {
|
||||
if (wifiMode == WIFI_MODE_AP) {
|
||||
wifi_promiscuous_enable(0);
|
||||
WiFi.persistent(false);
|
||||
WiFi.disconnect(true);
|
||||
wifi_set_opmode(STATION_MODE);
|
||||
prntln(W_STOPPED_AP);
|
||||
wifiMode = WIFI_MODE_STATION;
|
||||
}
|
||||
}
|
||||
|
||||
void wifiUpdate() {
|
||||
if ((wifiMode != WIFI_MODE_OFF) && !scan.isScanning()) {
|
||||
server.handleClient();
|
||||
dnsServer.processNextRequest();
|
||||
}
|
||||
}
|
||||
|
||||
String getWifiMode() {
|
||||
switch (wifiMode) {
|
||||
case WIFI_MODE_OFF:
|
||||
return W_MODE_OFF;
|
||||
|
||||
break;
|
||||
|
||||
case WIFI_MODE_AP:
|
||||
return W_MODE_AP;
|
||||
|
||||
break;
|
||||
|
||||
case WIFI_MODE_STATION:
|
||||
return W_MODE_ST;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
return String();
|
||||
}
|
||||
}
|
||||
|
||||
String getContentType(String filename) {
|
||||
if (server.hasArg("download")) return String(F("application/octet-stream"));
|
||||
else if (filename.endsWith(str(W_DOT_GZIP))) filename = filename.substring(0, filename.length() - 3);
|
||||
else if (filename.endsWith(str(W_DOT_HTM))) return str(W_HTML);
|
||||
else if (filename.endsWith(str(W_DOT_HTML))) return str(W_HTML);
|
||||
else if (filename.endsWith(str(W_DOT_CSS))) return str(W_CSS);
|
||||
else if (filename.endsWith(str(W_DOT_JS))) return str(W_JS);
|
||||
else if (filename.endsWith(str(W_DOT_PNG))) return str(W_PNG);
|
||||
else if (filename.endsWith(str(W_DOT_GIF))) return str(W_GIF);
|
||||
else if (filename.endsWith(str(W_DOT_JPG))) return str(W_JPG);
|
||||
else if (filename.endsWith(str(W_DOT_ICON))) return str(W_ICON);
|
||||
else if (filename.endsWith(str(W_DOT_XML))) return str(W_XML);
|
||||
else if (filename.endsWith(str(W_DOT_PDF))) return str(W_XPDF);
|
||||
else if (filename.endsWith(str(W_DOT_ZIP))) return str(W_XZIP);
|
||||
else if (filename.endsWith(str(W_DOT_JSON))) return str(W_JSON);
|
||||
else return str(W_TXT);
|
||||
}
|
||||
|
||||
bool handleFileRead(String path) {
|
||||
// prnt(W_AP_REQUEST);
|
||||
// prnt(path);
|
||||
|
||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||
|
||||
if (path.charAt(path.length() - 1) == SLASH) path += String(F("index.html"));
|
||||
|
||||
String contentType = getContentType(path);
|
||||
|
||||
if (!LittleFS.exists(path)) {
|
||||
if (LittleFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
|
||||
else if (LittleFS.exists(wifi_config_path + path)) path = wifi_config_path + path;
|
||||
else if (LittleFS.exists(wifi_config_path + path + str(W_DOT_GZIP))) path = wifi_config_path + path + str(
|
||||
W_DOT_GZIP);
|
||||
else {
|
||||
// prntln(W_NOT_FOUND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
File file = LittleFS.open(path, "r");
|
||||
server.streamFile(file, contentType);
|
||||
file.close();
|
||||
// prnt(SPACE);
|
||||
// prntln(W_OK);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void handleFileList() {
|
||||
if (!server.hasArg("dir")) {
|
||||
server.send(500, str(W_TXT), str(W_BAD_ARGS));
|
||||
return;
|
||||
}
|
||||
|
||||
String path = server.arg("dir");
|
||||
// Serial.println("handleFileList: " + path);
|
||||
Dir dir = LittleFS.openDir(path);
|
||||
|
||||
String output = String(OPEN_BRACKET); // {
|
||||
File entry;
|
||||
bool first = true;
|
||||
|
||||
while (dir.next()) {
|
||||
entry = dir.openFile("r");
|
||||
|
||||
if (first) first = false;
|
||||
else output += COMMA; // ,
|
||||
|
||||
output += OPEN_BRACKET; // [
|
||||
output += String(DOUBLEQUOTES) + entry.name() + String(DOUBLEQUOTES); // "filename"
|
||||
output += CLOSE_BRACKET; // ]
|
||||
|
||||
entry.close();
|
||||
}
|
||||
|
||||
output += CLOSE_BRACKET;
|
||||
server.send(200, str(W_JSON).c_str(), output);
|
||||
}
|
||||
|
||||
void sendProgmem(const char* ptr, size_t size, const char* type) {
|
||||
server.sendHeader("Content-Encoding", "gzip");
|
||||
server.sendHeader("Cache-Control", "max-age=86400");
|
||||
server.send_P(200, str(type).c_str(), ptr, size);
|
||||
}
|
||||
|
||||
// path = folder of web files, ssid = name of network, password = password ("0" => no password), hidden = if the network
|
||||
// is visible, captivePortal = enable a captive portal
|
||||
void startAP(String path, String ssid, String password, uint8_t ch, bool hidden, bool captivePortal) {
|
||||
if (password.length() < 8) {
|
||||
prntln(W_ERROR_PASSWORD);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!path.charAt(0) == SLASH) path = String(SLASH) + path;
|
||||
|
||||
if (password == String(ZERO)) password = String(NEWLINE);
|
||||
|
||||
wifi_config_path = path;
|
||||
wifi_config_ssid = ssid;
|
||||
wifi_config_password = password;
|
||||
setWifiChannel(ch);
|
||||
wifi_config_hidden = hidden;
|
||||
wifi_config_captivePortal = captivePortal;
|
||||
|
||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||
WiFi.softAP(ssid.c_str(), password.c_str(), wifi_channel, hidden);
|
||||
|
||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||
dnsServer.start(53, String(ASTERIX), apIP);
|
||||
|
||||
MDNS.begin(str(W_DEAUTHER).c_str());
|
||||
|
||||
server.on(String(F("/list")).c_str(), HTTP_GET, handleFileList); // list directory
|
||||
|
||||
|
||||
// ================================================================
|
||||
// post here the output of the webConverter.py
|
||||
#ifdef USE_PROGMEM_WEB_FILES
|
||||
if (!settings::getWebSettings().use_spiffs) {
|
||||
server.on(String(SLASH).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/attack.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(attackhtml, sizeof(attackhtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/index.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/info.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(infohtml, sizeof(infohtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/scan.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(scanhtml, sizeof(scanhtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/settings.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(settingshtml, sizeof(settingshtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/ssids.html")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(ssidshtml, sizeof(ssidshtml), W_HTML);
|
||||
});
|
||||
server.on(String(F("/style.css")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(stylecss, sizeof(stylecss), W_CSS);
|
||||
});
|
||||
server.on(String(F("/js/attack.js")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(attackjs, sizeof(attackjs), W_JS);
|
||||
});
|
||||
server.on(String(F("/js/scan.js")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(scanjs, sizeof(scanjs), W_JS);
|
||||
});
|
||||
server.on(String(F("/js/settings.js")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(settingsjs, sizeof(settingsjs), W_JS);
|
||||
});
|
||||
server.on(String(F("/js/site.js")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(sitejs, sizeof(sitejs), W_JS);
|
||||
});
|
||||
server.on(String(F("/js/ssids.js")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(ssidsjs, sizeof(ssidsjs), W_JS);
|
||||
});
|
||||
server.on(String(F("/lang/cn.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/cs.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/de.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(delang, sizeof(delang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/en.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/es.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(eslang, sizeof(eslang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/fi.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(filang, sizeof(filang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/fr.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/it.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/ru.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||
});
|
||||
server.on(String(F("/lang/tlh.lang")).c_str(), HTTP_GET, [] () {
|
||||
sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||
});
|
||||
}
|
||||
server.on(str(W_DEFAULT_LANG).c_str(), HTTP_GET, [] () {
|
||||
if (!settings::getWebSettings().use_spiffs) {
|
||||
if (String(settings::getWebSettings().lang) == String(F("cn"))) sendProgmem(cnlang, sizeof(cnlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("cs"))) sendProgmem(cslang, sizeof(cslang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("de"))) sendProgmem(delang, sizeof(delang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("en"))) sendProgmem(enlang, sizeof(enlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("es"))) sendProgmem(eslang, sizeof(eslang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("fi"))) sendProgmem(filang, sizeof(filang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("fr"))) sendProgmem(frlang, sizeof(frlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("it"))) sendProgmem(itlang, sizeof(itlang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("ru"))) sendProgmem(rulang, sizeof(rulang), W_JSON);
|
||||
else if (String(settings::getWebSettings().lang) == String(F("tlh"))) sendProgmem(tlhlang, sizeof(tlhlang), W_JSON);
|
||||
|
||||
else handleFileRead(String(F("/web/lang/")) + String(settings::getWebSettings().lang) + String(F(".lang")));
|
||||
} else {
|
||||
handleFileRead(String(F("/web/lang/")) + String(settings::getWebSettings().lang) + String(F(".lang")));
|
||||
}
|
||||
});
|
||||
#endif /* ifdef USE_PROGMEM_WEB_FILES */
|
||||
// ================================================================
|
||||
|
||||
server.on(String(F("/run")).c_str(), HTTP_GET, [] () {
|
||||
server.send(200, str(W_TXT), str(W_OK).c_str());
|
||||
String input = server.arg("cmd");
|
||||
cli.exec(input);
|
||||
});
|
||||
|
||||
server.on(String(F("/attack.json")).c_str(), HTTP_GET, [] () {
|
||||
server.send(200, str(W_JSON), attack.getStatusJSON());
|
||||
});
|
||||
|
||||
// aggressively caching static assets
|
||||
server.serveStatic("/js", LittleFS, String(wifi_config_path + "/js").c_str(), "max-age=86400");
|
||||
|
||||
// called when the url is not defined here
|
||||
// use it to load content from SPIFFS
|
||||
server.onNotFound([] () {
|
||||
if (!handleFileRead(server.uri())) {
|
||||
//server.send(404, str(W_TXT), str(W_FILE_NOT_FOUND));
|
||||
//server.send(200, "text/html", indexhtml);
|
||||
sendProgmem(indexhtml, sizeof(indexhtml), W_HTML);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
server.begin();
|
||||
wifiMode = WIFI_MODE_AP;
|
||||
|
||||
prntln(W_STARTED_AP);
|
||||
printWifiStatus();
|
||||
}
|
||||
|
||||
void printWifiStatus() {
|
||||
prnt(String(F("[WiFi] Path: '")));
|
||||
prnt(wifi_config_path);
|
||||
prnt(String(F("', Mode: '")));
|
||||
|
||||
switch (wifiMode) {
|
||||
case WIFI_MODE_OFF:
|
||||
prnt(W_MODE_OFF);
|
||||
break;
|
||||
|
||||
case WIFI_MODE_AP:
|
||||
prnt(W_AP);
|
||||
break;
|
||||
|
||||
case WIFI_MODE_STATION:
|
||||
prnt(W_STATION);
|
||||
break;
|
||||
}
|
||||
prnt(String(F("', SSID: '")));
|
||||
prnt(wifi_config_ssid);
|
||||
prnt(String(F("', password: '")));
|
||||
prnt(wifi_config_password);
|
||||
prnt(String(F("', channel: '")));
|
||||
prnt(wifi_channel);
|
||||
prnt(String(F("', hidden: ")));
|
||||
prnt(b2s(wifi_config_hidden));
|
||||
prnt(String(F(", captive-portal: ")));
|
||||
prntln(b2s(wifi_config_captivePortal));
|
||||
}
|
||||
|
||||
void startAP() {
|
||||
startAP(wifi_config_path.c_str(), wifi_config_ssid.c_str(),
|
||||
wifi_config_password.c_str(), wifi_channel, wifi_config_hidden, wifi_config_captivePortal);
|
||||
}
|
||||
|
||||
void startAP(String path) {
|
||||
wifi_config_path = path;
|
||||
startAP();
|
||||
}
|
||||
|
||||
void loadWifiConfigDefaults() {
|
||||
wifi_config_hidden = settings::getAccessPointSettings().hidden;
|
||||
wifi_config_ssid = settings::getAccessPointSettings().ssid;
|
||||
wifi_config_password = settings::getAccessPointSettings().password;
|
||||
wifi_config_captivePortal = settings::getWebSettings().captive_portal;
|
||||
wifi_config_path = str(W_WEBINTERFACE);
|
||||
}
|
||||
|
||||
void resumeAP() {
|
||||
if (wifiMode != WIFI_MODE_AP) {
|
||||
wifiMode = WIFI_MODE_AP;
|
||||
wifi_promiscuous_enable(0);
|
||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||
WiFi.softAP(wifi_config_ssid.c_str(), wifi_config_password.c_str(), wifi_channel, wifi_config_hidden);
|
||||
prntln(W_STARTED_AP);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ifndef WifiManager_h
|
||||
void stopAP();
|
||||
void resumeAP();
|
||||
|
||||
void update();
|
||||
}
|
Loading…
Reference in New Issue