Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
6f845e1e45 | |||
170af78f28 | |||
dd4204c7a1 | |||
4cdce88ca5 | |||
6f1dd6a7ba | |||
11aaf8450f | |||
2353bfa617 | |||
7ea5b222ad | |||
f42c8a1bf3 |
@ -10,9 +10,9 @@
|
|||||||
"repository":
|
"repository":
|
||||||
{
|
{
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git"
|
"url": "https://git.xpablo.cz/pablo2048/WiFiConfig.git"
|
||||||
},
|
},
|
||||||
"version": "6.3.4",
|
"version": "6.4.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": ["espressif8266", "espressif32"],
|
"platforms": ["espressif8266", "espressif32"],
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
name=WiFiConfig
|
name=WiFiConfig
|
||||||
version=6.3.4
|
version=6.4.0
|
||||||
author=Pavel Brychta
|
author=Pavel Brychta
|
||||||
maintainer=Pavel Brychta <Pablo@xpablo.cz>
|
maintainer=Pavel Brychta <pablo@xpablo.cz>
|
||||||
sentence=Enables seamless module configuration.
|
sentence=Enables seamless module configuration.
|
||||||
paragraph=With this library you can enable your ESP8266 or ESP32 module to be configured over WiFi. Includes Captive Portal for easy configuration.
|
paragraph=With this library you can enable your ESP8266 or ESP32 module to be configured over WiFi. Includes Captive Portal for easy configuration.
|
||||||
category=Other
|
category=Other
|
||||||
url=http://www.xpablo.cz
|
url=https://www.xpablo.cz
|
||||||
architectures=esp8266,esp32
|
architectures=esp8266,esp32
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
|
* v6.4.0- 27.2.2021 - funkcni inicializace konfigurace
|
||||||
|
*
|
||||||
|
* v6.3.5-28.11.2020 - moznost nadefinovat titulek webove stranky a popisek okna v prohlizeci pomoci WIFICONFIG_TITLE a WIFICONFIG_WEBTITLE
|
||||||
|
*
|
||||||
* v6.3.4-23.3.2020 - staticka konfigurace v AP rezimu funkcni
|
* v6.3.4-23.3.2020 - staticka konfigurace v AP rezimu funkcni
|
||||||
*
|
*
|
||||||
* v6.3.3-27.10.2019 - volani WS_CONNECTED i v pripade, ze bezi AP
|
* v6.3.3-27.10.2019 - volani WS_CONNECTED i v pripade, ze bezi AP
|
||||||
@ -99,6 +103,14 @@
|
|||||||
#include <encipheredEEPROMStrings.h>
|
#include <encipheredEEPROMStrings.h>
|
||||||
#include "embHTML.h"
|
#include "embHTML.h"
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
// ESP8266
|
||||||
|
# define SETHOSTNAME(a) WiFi.hostname(a)
|
||||||
|
#else
|
||||||
|
// ESP32
|
||||||
|
# define SETHOSTNAME(a) WiFi.setHostname(a)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef DEBUG_ESP_PORT
|
#ifdef DEBUG_ESP_PORT
|
||||||
# define DEBUG_MSG(_1, ...) DEBUG_ESP_PORT.printf_P(PSTR(_1), ##__VA_ARGS__)
|
# define DEBUG_MSG(_1, ...) DEBUG_ESP_PORT.printf_P(PSTR(_1), ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
@ -119,17 +131,6 @@ extern "C" {
|
|||||||
|
|
||||||
extern char WiFiDeviceName[];
|
extern char WiFiDeviceName[];
|
||||||
|
|
||||||
enum {
|
|
||||||
WIFIMODE_AP = WIFI_AP, // rezim prace jako pristupovy bod (AP)
|
|
||||||
WIFIMODE_STA = WIFI_STA, // rezim prace jako klient
|
|
||||||
WIFIMODE_AP_STA = WIFI_AP_STA // rezim prace jako klient i pristupovy bod
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
IPCONFIG_DHCP = 0x55, // DHCP konfigurace ip adres (default)
|
|
||||||
IPCONFIG_STATIC = 0xaa // staticka konfigurace ip adres
|
|
||||||
};
|
|
||||||
|
|
||||||
static int configBase; // musi byt trvale ulozene, aby fungovaly metody pro ziskani retezcu z EEPROM
|
static int configBase; // musi byt trvale ulozene, aby fungovaly metody pro ziskani retezcu z EEPROM
|
||||||
|
|
||||||
static std::unique_ptr<DNSServer> dnsServer;
|
static std::unique_ptr<DNSServer> dnsServer;
|
||||||
@ -618,65 +619,7 @@ void WiFiConfig::_handleSetAP(void)
|
|||||||
server->send_P(200, TEXTHTML, PAGE_SAVED);
|
server->send_P(200, TEXTHTML, PAGE_SAVED);
|
||||||
delay(2000); // cekame na odeslani dat
|
delay(2000); // cekame na odeslani dat
|
||||||
// nakonfigurujeme ESP dle nove nastavenych parametru
|
// nakonfigurujeme ESP dle nove nastavenych parametru
|
||||||
WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci
|
_prepareWifi();
|
||||||
WiFi.disconnect(); // vsechno odpojime
|
|
||||||
|
|
||||||
String s = EES_readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
|
||||||
String pass = EES_readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
|
||||||
|
|
||||||
switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode))) {
|
|
||||||
case WIFIMODE_STA: {
|
|
||||||
DEBUG_MSG("STA mode.\r\n");
|
|
||||||
#if defined(ESP8266)
|
|
||||||
if (strlen(WiFiDeviceName)) {
|
|
||||||
WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
|
||||||
DEBUG_MSG("Static configuration.\r\n");
|
|
||||||
WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
|
||||||
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, dns))));
|
|
||||||
delay(100);
|
|
||||||
}
|
|
||||||
WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta
|
|
||||||
WiFi.begin(s.c_str(), pass.c_str());
|
|
||||||
#if !defined(ESP8266)
|
|
||||||
if (strlen(WiFiDeviceName)) {
|
|
||||||
WiFi.setHostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(ESP8266)
|
|
||||||
wifi_station_set_auto_connect(true);
|
|
||||||
#else
|
|
||||||
//esp_wifi_set_auto_connect(true);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WIFIMODE_AP:
|
|
||||||
DEBUG_MSG("AP mode.\r\n");
|
|
||||||
WiFi.mode(WIFI_AP); // startujeme AP
|
|
||||||
if (pass.length()) {
|
|
||||||
// je zadane heslo do AP
|
|
||||||
WiFi.softAP(s.c_str(), pass.c_str(), EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
|
||||||
} else {
|
|
||||||
// otevreny AP
|
|
||||||
WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
|
||||||
}
|
|
||||||
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
|
||||||
WiFi.softAPConfig(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
|
||||||
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: // jakykoliv neznamy rezim (mozna zavada na EEPROM???)
|
|
||||||
DEBUG_MSG("Mode Error!!\r\n");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
delay(1000); // cekame XX sekund na ulozeni atd...
|
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,6 +663,7 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb)
|
|||||||
ssid.replace(F("?"), String(lmac));
|
ssid.replace(F("?"), String(lmac));
|
||||||
}
|
}
|
||||||
WiFi.softAP(ssid.c_str(), NULL, SETUP_CHANNEL);
|
WiFi.softAP(ssid.c_str(), NULL, SETUP_CHANNEL);
|
||||||
|
delay(100); // kvuli ESP32 - cekame na start AP
|
||||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||||
#endif
|
#endif
|
||||||
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
dnsServer->setErrorReplyCode(DNSReplyCode::NoError);
|
||||||
@ -817,6 +761,12 @@ bool WiFiConfig::_testWifi(wificonfig_cb cb)
|
|||||||
|
|
||||||
case WIFIMODE_AP:
|
case WIFIMODE_AP:
|
||||||
DEBUG_MSG("AP mode.\r\n");
|
DEBUG_MSG("AP mode.\r\n");
|
||||||
|
if (s.endsWith(F("?"))) {
|
||||||
|
char lmac[16];
|
||||||
|
|
||||||
|
sprintf_P(lmac, PSTR("%06X"), ESP_getChipId());
|
||||||
|
s.replace(F("?"), String(lmac));
|
||||||
|
}
|
||||||
WiFi.mode(WIFI_AP); // startujeme AP
|
WiFi.mode(WIFI_AP); // startujeme AP
|
||||||
if (pass.length()) {
|
if (pass.length()) {
|
||||||
// je zadane heslo do AP
|
// je zadane heslo do AP
|
||||||
@ -826,6 +776,7 @@ bool WiFiConfig::_testWifi(wificonfig_cb cb)
|
|||||||
WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
||||||
}
|
}
|
||||||
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
||||||
|
delay(100); // kvuli ESP32 - cekame na start AP
|
||||||
WiFi.softAPConfig(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
WiFi.softAPConfig(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
||||||
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))));
|
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))));
|
||||||
}
|
}
|
||||||
@ -883,11 +834,7 @@ wificonfigresult_t WiFiConfig::begin(int configarea, int forceConfigure, wificon
|
|||||||
{
|
{
|
||||||
switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode))) {
|
switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode))) {
|
||||||
case WIFIMODE_STA: {
|
case WIFIMODE_STA: {
|
||||||
#if defined(ESP8266)
|
SETHOSTNAME(WiFiDeviceName); // nastavime jmeno zarizeni
|
||||||
WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
|
||||||
#else
|
|
||||||
WiFi.setHostname(WiFiDeviceName);
|
|
||||||
#endif
|
|
||||||
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
||||||
DEBUG_MSG("Static configuration SET.\r\n");
|
DEBUG_MSG("Static configuration SET.\r\n");
|
||||||
WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
||||||
@ -941,4 +888,91 @@ wificonfigresult_t WiFiConfig::begin(int configarea, int forceConfigure, int tim
|
|||||||
_time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat
|
_time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat
|
||||||
return begin(configarea, forceConfigure, cb); // spustime WiFi
|
return begin(configarea, forceConfigure, cb); // spustime WiFi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WiFiConfig::initConfig(int cfgBase, const String &ssid, const String &pass, const int mode, const int ipcfg, const IPAddress &ip, const IPAddress &mask, const IPAddress &gw, const IPAddress &dns)
|
||||||
|
{
|
||||||
|
|
||||||
|
DEBUG_MSG("initConfig %d\r\n", mode);
|
||||||
|
configBase = cfgBase;
|
||||||
|
EES_storeString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), (String &)ssid);
|
||||||
|
EES_storeString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), (String &)pass);
|
||||||
|
EEPROM.write(configBase + offsetof(wificonfigarea_t, mode), mode);
|
||||||
|
EEPROM.write(configBase + offsetof(wificonfigarea_t, ip), ipcfg);
|
||||||
|
EEPROM.write(configBase + offsetof(wificonfigarea_t, apchannel), 3);
|
||||||
|
setEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr), (uint32_t) ip);
|
||||||
|
setEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask), (uint32_t) mask);
|
||||||
|
setEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway), (uint32_t) gw);
|
||||||
|
setEEPROMuint32(configBase + offsetof(wificonfigarea_t, dns), (uint32_t) dns);
|
||||||
|
DEBUG_MSG("IP: %s\r\n", ip.toString().c_str());
|
||||||
|
EEPROM.commit(); // ulozime zmeny v EEPROM
|
||||||
|
_prepareWifi(); // nastavime novou WiFi konfiguraci
|
||||||
|
}
|
||||||
|
|
||||||
|
void WiFiConfig::_prepareWifi(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci
|
||||||
|
WiFi.disconnect(); // vsechno odpojime
|
||||||
|
delay(100);
|
||||||
|
|
||||||
|
String s = EES_readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
||||||
|
String pass = EES_readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
||||||
|
uint8_t mode = EEPROM.read(configBase + offsetof(wificonfigarea_t, mode));
|
||||||
|
|
||||||
|
switch (mode) {
|
||||||
|
case WIFIMODE_STA: {
|
||||||
|
DEBUG_MSG("STA mode.\r\n");
|
||||||
|
#if defined(ESP8266)
|
||||||
|
if (strlen(WiFiDeviceName)) {
|
||||||
|
SETHOSTNAME(WiFiDeviceName); // nastavime jmeno zarizeni
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
||||||
|
DEBUG_MSG("Static configuration.\r\n");
|
||||||
|
WiFi.config(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
||||||
|
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, dns))));
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta
|
||||||
|
WiFi.begin(s.c_str(), pass.c_str());
|
||||||
|
DEBUG_MSG("STA params: %s, %s\r\n", s.c_str(), pass.c_str());
|
||||||
|
#if !defined(ESP8266)
|
||||||
|
if (strlen(WiFiDeviceName)) {
|
||||||
|
SETHOSTNAME(WiFiDeviceName); // nastavime jmeno zarizeni
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if defined(ESP8266)
|
||||||
|
WiFi.setAutoConnect(true);
|
||||||
|
WiFi.setAutoReconnect(true);
|
||||||
|
// wifi_station_set_auto_connect(true);
|
||||||
|
#else
|
||||||
|
//esp_wifi_set_auto_connect(true);
|
||||||
|
#endif
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case WIFIMODE_AP:
|
||||||
|
DEBUG_MSG("AP mode.\r\n");
|
||||||
|
WiFi.mode(WIFI_AP); // startujeme AP
|
||||||
|
if (pass.length()) {
|
||||||
|
// je zadane heslo do AP
|
||||||
|
WiFi.softAP(s.c_str(), pass.c_str(), EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
||||||
|
} else {
|
||||||
|
// otevreny AP
|
||||||
|
WiFi.softAP(s.c_str(), NULL, EEPROM.read(configBase + offsetof(wificonfigarea_t, apchannel)));
|
||||||
|
}
|
||||||
|
if (IPCONFIG_STATIC == EEPROM.read(configBase + offsetof(wificonfigarea_t, ip))) {
|
||||||
|
WiFi.softAPConfig(IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, ipaddr))), IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, gateway))),
|
||||||
|
IPAddress(getEEPROMuint32(configBase + offsetof(wificonfigarea_t, netmask))));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // jakykoliv neznamy rezim (mozna zavada na EEPROM???)
|
||||||
|
DEBUG_MSG("Mode Error (%d)!!\r\n", (int)mode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay(1000); // cekame XX sekund na ulozeni atd...
|
||||||
|
}
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* @file WiFiConfig.h
|
* @file WiFiConfig.h
|
||||||
* @author Pavel Brychta, http://www.xpablo.cz
|
* @author Pavel Brychta, http://www.xpablo.cz
|
||||||
*
|
*
|
||||||
* Copyright (c) 2015-20 Pavel Brychta. All rights reserved.
|
* Copyright (c) 2015-21 Pavel Brychta. All rights reserved.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
@ -31,9 +31,9 @@
|
|||||||
#define __WiFiConfig_h__
|
#define __WiFiConfig_h__
|
||||||
|
|
||||||
#if defined(ESP8266)
|
#if defined(ESP8266)
|
||||||
#include <ESP8266WiFi.h>
|
# include <ESP8266WiFi.h>
|
||||||
#else
|
#else
|
||||||
#include <WiFi.h>
|
# include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
@ -71,6 +71,19 @@ typedef enum {
|
|||||||
WCR_CONFIGAP_NOT_STARTED = 2, // wifi neni pripojena a spusteni konfiguracniho AP bylo zakazane parametrem timeout (WC_DONT_RUN_CONFIGAP)
|
WCR_CONFIGAP_NOT_STARTED = 2, // wifi neni pripojena a spusteni konfiguracniho AP bylo zakazane parametrem timeout (WC_DONT_RUN_CONFIGAP)
|
||||||
} wificonfigresult_t;
|
} wificonfigresult_t;
|
||||||
|
|
||||||
|
// Interni reprezentace konfigurace WiFi
|
||||||
|
enum {
|
||||||
|
WIFIMODE_AP = WIFI_AP, // rezim prace jako pristupovy bod (AP)
|
||||||
|
WIFIMODE_STA = WIFI_STA, // rezim prace jako klient
|
||||||
|
WIFIMODE_AP_STA = WIFI_AP_STA // rezim prace jako klient i pristupovy bod
|
||||||
|
};
|
||||||
|
|
||||||
|
// Interni reprezentace konfigurace ip
|
||||||
|
enum {
|
||||||
|
IPCONFIG_DHCP = 0x55, // DHCP konfigurace ip adres (default)
|
||||||
|
IPCONFIG_STATIC = 0xaa // staticka konfigurace ip adres
|
||||||
|
};
|
||||||
|
|
||||||
typedef void (*wificonfig_cb)(wificonfigstate_t state); // definice callbacku
|
typedef void (*wificonfig_cb)(wificonfigstate_t state); // definice callbacku
|
||||||
|
|
||||||
typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzivatelskeho parametru
|
typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzivatelskeho parametru
|
||||||
@ -170,7 +183,10 @@ public:
|
|||||||
wificonfigresult_t begin(int configarea, int forceConfigure, wificonfig_cb cb);
|
wificonfigresult_t begin(int configarea, int forceConfigure, wificonfig_cb cb);
|
||||||
wificonfigresult_t begin(int configarea, int forceConfigure, int timeout, wificonfig_cb cb);
|
wificonfigresult_t begin(int configarea, int forceConfigure, int timeout, wificonfig_cb cb);
|
||||||
void addParameter(WiFiConfigUsrParameter *p);
|
void addParameter(WiFiConfigUsrParameter *p);
|
||||||
|
void initConfig(int cfgBase, const String &ssid, const String &pass, const int mode = WIFIMODE_STA, const int ipcfg = IPCONFIG_DHCP, const IPAddress &ip = 0, const IPAddress &mask = 0, const IPAddress &gw = 0, const IPAddress &dns = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void _prepareWifi(void);
|
||||||
wificonfigresult_t _setupAP(wificonfig_cb cb);
|
wificonfigresult_t _setupAP(wificonfig_cb cb);
|
||||||
void _handleDisplayAP(void);
|
void _handleDisplayAP(void);
|
||||||
void _handleSetAP(void);
|
void _handleSetAP(void);
|
||||||
@ -188,4 +204,5 @@ private:
|
|||||||
uint32_t _time; // hodnota, po ktere bude ESP restartovano (pokud je _timeout != 0)
|
uint32_t _time; // hodnota, po ktere bude ESP restartovano (pokud je _timeout != 0)
|
||||||
uint8_t _status; // stav pripojeni - je pouzity pro signalizaci duvodu, proc se nepripoji k AP
|
uint8_t _status; // stav pripojeni - je pouzity pro signalizaci duvodu, proc se nepripoji k AP
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
// HTML data
|
// HTML data
|
||||||
|
#ifndef WIFICONFIG_WEBTITLE
|
||||||
|
# define WIFICONFIG_WEBTITLE "xPablo.cz Setup"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WIFICONFIG_TITLE
|
||||||
|
# define WIFICONFIG_TITLE "ESP WiFiConfig"
|
||||||
|
#endif
|
||||||
|
|
||||||
static const char TEXTHTML[] PROGMEM = "text/html";
|
static const char TEXTHTML[] PROGMEM = "text/html";
|
||||||
static const char TEXTPLAIN[] PROGMEM = "text/plain";
|
static const char TEXTPLAIN[] PROGMEM = "text/plain";
|
||||||
|
|
||||||
static const char PAGE_INDEX1[] PROGMEM = R"=====(
|
static const char PAGE_INDEX1[] PROGMEM = R"=====(
|
||||||
<!DOCTYPE html><html lang="en"><head><meta charset= "utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
<!DOCTYPE html><html lang="en"><head><meta charset= "utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||||
<title>xPablo.cz Setup</title>
|
<title>)=====" WIFICONFIG_WEBTITLE R"=====(</title>
|
||||||
<style>
|
<style>
|
||||||
.c{text-align: center;}
|
.c{text-align: center;}
|
||||||
div,input{padding:5px;font-size:1em;}
|
div,input{padding:5px;font-size:1em;}
|
||||||
@ -21,7 +29,7 @@ function c(l){document.getElementById('_s').value=l.innerText||l.textContent;doc
|
|||||||
function hAP(){if (document.getElementById('_a').checked){document.getElementById('apconfig').style.display = 'block';}else{document.getElementById('apconfig').style.display = 'none';}}
|
function hAP(){if (document.getElementById('_a').checked){document.getElementById('apconfig').style.display = 'block';}else{document.getElementById('apconfig').style.display = 'none';}}
|
||||||
function hSC(){if (document.getElementById('_st').checked){document.getElementById('staticip').style.display = 'block';}else{document.getElementById('staticip').style.display = 'none';}}
|
function hSC(){if (document.getElementById('_st').checked){document.getElementById('staticip').style.display = 'block';}else{document.getElementById('staticip').style.display = 'none';}}
|
||||||
</script>
|
</script>
|
||||||
</head><body><h1>ESP WiFiConfig</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
|
</head><body><h1>)=====" WIFICONFIG_TITLE R"=====(</h1><div style='text-align:left;display:inline-block;min-width:260px;'>
|
||||||
)=====";
|
)=====";
|
||||||
|
|
||||||
/* Polozky nalezenych SSID
|
/* Polozky nalezenych SSID
|
||||||
|
Reference in New Issue
Block a user