Compare commits
16 Commits
Author | SHA1 | Date | |
---|---|---|---|
ed1659791a | |||
60f106cef3 | |||
4590e99a54 | |||
557d06a557 | |||
f45d742435 | |||
3172bb0d17 | |||
90618b0ae6 | |||
7fec2df6b9 | |||
d0e01c567c | |||
48986510dd | |||
90da6a05e5 | |||
7a6f936a1a | |||
3a8ffdcd01 | |||
dc8aa8890d | |||
81ceb9aca9 | |||
33f8f6a8b8 |
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
Knihovna pro konfiguraci WiFi rozhraní modulu ESP8266
|
Knihovna pro konfiguraci WiFi rozhraní modulu ESP8266 a ESP32, obsahující Captive portal.
|
Binary file not shown.
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 56 KiB |
@ -4,6 +4,7 @@
|
|||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <ESP8266NetBIOS.h>
|
#include <ESP8266NetBIOS.h>
|
||||||
#include <WiFiConfig.h>
|
#include <WiFiConfig.h>
|
||||||
|
#include <encipheredEEPROMStrings.h>
|
||||||
|
|
||||||
// Plati pro desticku Witty s modulem ESP-12E
|
// Plati pro desticku Witty s modulem ESP-12E
|
||||||
#define PIN_FORCE_CONFIG 4
|
#define PIN_FORCE_CONFIG 4
|
||||||
@ -14,6 +15,19 @@
|
|||||||
//#define DEBUG_OUT(a) {}
|
//#define DEBUG_OUT(a) {}
|
||||||
#define DEBUG_OUT(a) Serial.print(a)
|
#define DEBUG_OUT(a) Serial.print(a)
|
||||||
|
|
||||||
|
// Definice obsazeni EEPROM
|
||||||
|
#define elementSize(type, element) sizeof(((type *)0)->element)
|
||||||
|
#define countof(a) (sizeof(a) / sizeof(a[0]))
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char devname[32 + 2]; // jmeno zarizeni (pro NBNS plati jen 16 znaku)
|
||||||
|
} eepromconfig_t;
|
||||||
|
|
||||||
|
#define EEPROM_SIZE (sizeof(wificonfigarea_t) + sizeof(eepromconfig_t) + 10) // velikost EEPROM oblasti (POZOR!!! zbytecnym zvetsovanim se zaroven zmensuje velikost RAM kvuli zrcadlu!!!)
|
||||||
|
#define EEPROM_WIFICONFIG_ORIGIN (EEPROM_SIZE - sizeof(wificonfigarea_t)) // pocatek oblasti, pouzivane WiFiConfig (alokovano odzadu)
|
||||||
|
#define EEPROM_CONFIG_ORIGIN (0)
|
||||||
|
|
||||||
|
char WiFiDeviceName[elementSize(eepromconfig_t, devname)]; // misto pro jmeno zarizeni (dodane do DNS, DHCP NBNS apod...)
|
||||||
ESP8266WebServer wwwserver(80); // webovy server
|
ESP8266WebServer wwwserver(80); // webovy server
|
||||||
String content;
|
String content;
|
||||||
|
|
||||||
@ -52,23 +66,27 @@ void ICACHE_FLASH_ATTR wcb(wificonfigstate_t state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void saveServer(const char *param)
|
void ICACHE_FLASH_ATTR saveDevname(const char *param)
|
||||||
{
|
{
|
||||||
|
String p = param;
|
||||||
|
|
||||||
DEBUG_OUT(param);
|
EES_storeString(EEPROM_CONFIG_ORIGIN + offsetof(eepromconfig_t, devname), elementSize(eepromconfig_t, devname), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ICACHE_FLASH_ATTR setup()
|
void ICACHE_FLASH_ATTR setup()
|
||||||
{
|
{
|
||||||
WiFiConfig wifi; // konfigurace ESP modulu
|
WiFiConfig wifi; // konfigurace ESP modulu
|
||||||
WiFiConfigUsrParameter testOnly("server", "adresa serveru", "Default server", 32, saveServer);
|
WiFiConfigUsrParameter devname("devname", "Jméno zařízení", (const char *)WiFiDeviceName, 32, saveDevname);
|
||||||
|
|
||||||
EEPROM.begin(512); // zahajujeme praci s EEPROM
|
EEPROM.begin(EEPROM_SIZE); // zahajujeme praci s EEPROM
|
||||||
pinMode(PIN_FORCE_CONFIG, INPUT_PULLUP); // pin, co slouzi jako vstup tlacitka
|
pinMode(PIN_FORCE_CONFIG, INPUT_PULLUP); // pin, co slouzi jako vstup tlacitka
|
||||||
int fc = digitalRead(PIN_FORCE_CONFIG); // pozadavek na vynucene vyvolani konfigurace
|
int fc = digitalRead(PIN_FORCE_CONFIG); // pozadavek na vynucene vyvolani konfigurace
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
wifi.addParameter(&testOnly);
|
String dn = EES_readString(EEPROM_CONFIG_ORIGIN + offsetof(eepromconfig_t, devname), elementSize(eepromconfig_t, devname));
|
||||||
if (WCR_OK != wifi.begin(0, fc, wcb)) // startujeme pripojeni
|
strcpy(WiFiDeviceName, dn.c_str());
|
||||||
|
wifi.addParameter(&devname);
|
||||||
|
|
||||||
|
if (WCR_OK != wifi.begin(EEPROM_WIFICONFIG_ORIGIN, fc, wcb)) // startujeme pripojeni
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
|
|
||||||
wwwserver.on("/", handleRoot);
|
wwwserver.on("/", handleRoot);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name":"WiFiConfig",
|
"name":"WiFiConfig",
|
||||||
"description":"Web based WiFi part configuration for the ESP8266 SoC",
|
"description":"Web based WiFi part configuration for the ESP8266 and ESP32 SoC",
|
||||||
"keywords":"wifi, configuration",
|
"keywords":"wifi, configuration",
|
||||||
"authors":
|
"authors":
|
||||||
{
|
{
|
||||||
@ -12,10 +12,10 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git"
|
"url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git"
|
||||||
},
|
},
|
||||||
"version": "5.9",
|
"version": "6.3.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"frameworks": "arduino",
|
"frameworks": "arduino",
|
||||||
"platforms": "espressif8266",
|
"platforms": ["espressif8266", "espressif32"],
|
||||||
"build": {
|
"build": {
|
||||||
"libCompatMode": 2
|
"libCompatMode": 2
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
name=WiFiConfig
|
name=WiFiConfig
|
||||||
version=5.9
|
version=6.3.1
|
||||||
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 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=http://www.xpablo.cz
|
||||||
architectures=esp8266
|
architectures=esp8266,esp32
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
/*
|
/*
|
||||||
|
* V6.3.1- 1.9.2019 - Odstraneni HTML5 validatoru - delaly akorat problemy anedala se ulozit konfigurace i kdyz byly polozky skryty
|
||||||
|
*
|
||||||
|
* V6.3 - 12.8.2019 - IP adresa Captive portalu je zmenena na 172.217.28.1 kvuli funkcnosti na Android zarizenich (viz. zmena zde https://github.com/esp8266/Arduino/blob/master/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino)
|
||||||
|
* ladici vypis pri zachyceni presmerovani v Captive portalu.
|
||||||
|
*
|
||||||
|
* V6.2 - 12.12.2018- Nastaveni jmena zarizeni nadale NENI soucasti WiFiConfig a je treba ho pridat jako uzivatelsky parametr. Je to proto, protoze
|
||||||
|
* se ukazalo, ze neni dobre z externiho kodu sahat do vnitrni struktury WiFiConfig (napr. pri ukladani noveho jmena).
|
||||||
|
*
|
||||||
|
* V6.1 - 11.12.2018- Sifrovani retezcu vytazeno mimo WiFiConfig do knihovny encipheredEEPROMStrings (dostupna na gitu) kvuli pristupu i jinych modulu
|
||||||
|
*
|
||||||
|
* V6.0 - 20.11.2018- Verze i pro ESP32
|
||||||
|
*
|
||||||
* V5.9 - 18.7.2018 - Retezce, ukladane do EEPROM jsou primitivnim zpusobem sifrovany pro ztizeni odhaleni SSID a hesla pri dumpu pameti
|
* V5.9 - 18.7.2018 - Retezce, ukladane do EEPROM jsou primitivnim zpusobem sifrovany pro ztizeni odhaleni SSID a hesla pri dumpu pameti
|
||||||
*
|
*
|
||||||
* V5.8 - 5.7.2018 - Opraveno spatne zobrazovani sily signalu v prehledu WiFi siti (spatne barvy)
|
* V5.8 - 5.7.2018 - Opraveno spatne zobrazovani sily signalu v prehledu WiFi siti (spatne barvy)
|
||||||
@ -14,7 +26,7 @@
|
|||||||
*
|
*
|
||||||
* V5.3 - 8.12.2017 - prepracovano presmerovani v Captive portalu, DEBUG_MSG makro upraveno na posledni pouzivanou verzi, scitani retezcu prepracovano na .concat. Pripsany Informace o modulu, reakce na Reset
|
* V5.3 - 8.12.2017 - prepracovano presmerovani v Captive portalu, DEBUG_MSG makro upraveno na posledni pouzivanou verzi, scitani retezcu prepracovano na .concat. Pripsany Informace o modulu, reakce na Reset
|
||||||
*
|
*
|
||||||
* V5.2 - 20.4.2017 - Pokud je pouzite v timeoutu EC_DONT_RUN_CONFIGAP tak se vracime okamzite a necekame na pripojeni k WiFi (take nevolame zadnou callback metodu).
|
* V5.2 - 20.4.2017 - Pokud je pouzite v timeoutu WC_DONT_RUN_CONFIGAP tak se vracime okamzite a necekame na pripojeni k WiFi (take nevolame zadnou callback metodu).
|
||||||
* Navratovy kod je pak WCR_CONFIGAP_NOT_STARTED .
|
* Navratovy kod je pak WCR_CONFIGAP_NOT_STARTED .
|
||||||
*
|
*
|
||||||
* V5.1 - 3.4.2017 - Webove rozhrani upravene pro snadnejsi ovladani na telefonu/tabletu, sila signalu AP zobrazena jako barevne odliseny indikator.
|
* V5.1 - 3.4.2017 - Webove rozhrani upravene pro snadnejsi ovladani na telefonu/tabletu, sila signalu AP zobrazena jako barevne odliseny indikator.
|
||||||
@ -67,11 +79,16 @@
|
|||||||
* Prejit na pripojovani pomoci vnitrnich mechanizmu SDK ESP - zvysi se tim rychlost pripojeni kvuli bateriovym zarizenim
|
* Prejit na pripojovani pomoci vnitrnich mechanizmu SDK ESP - zvysi se tim rychlost pripojeni kvuli bateriovym zarizenim
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "WiFiConfig.h"
|
|
||||||
#include <ESP8266WebServer.h>
|
|
||||||
#include <DNSServer.h>
|
#include <DNSServer.h>
|
||||||
|
#if defined(ESP8266)
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#else
|
||||||
|
#include <WebServer.h>
|
||||||
|
#endif
|
||||||
|
#include "WiFiConfig.h"
|
||||||
#include <EEPROM.h>
|
#include <EEPROM.h>
|
||||||
#include <Ticker.h>
|
#include <Ticker.h>
|
||||||
|
#include <encipheredEEPROMStrings.h>
|
||||||
#include "embHTML.h"
|
#include "embHTML.h"
|
||||||
|
|
||||||
#ifdef DEBUG_ESP_PORT
|
#ifdef DEBUG_ESP_PORT
|
||||||
@ -80,13 +97,19 @@
|
|||||||
#define DEBUG_MSG(...)
|
#define DEBUG_MSG(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "user_interface.h"
|
#include "user_interface.h"
|
||||||
}
|
}
|
||||||
|
#define ESP_getChipId() (ESP.getChipId())
|
||||||
|
#else
|
||||||
|
#include <esp_wifi.h>
|
||||||
|
#define ESP_getChipId() ((uint32_t)ESP.getEfuseMac())
|
||||||
|
#endif
|
||||||
|
|
||||||
#define DNS_PORT 53
|
#define DNS_PORT 53
|
||||||
|
|
||||||
char WiFiDeviceName[elementSize(wificonfigarea_t, devname)]; // misto pro jmeno zarizeni (dodane do DNS, DHCP NBNS apod...)
|
extern char WiFiDeviceName[];
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
@ -104,7 +127,11 @@ enum
|
|||||||
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;
|
||||||
|
#if defined(ESP8266)
|
||||||
static std::unique_ptr<ESP8266WebServer> server;
|
static std::unique_ptr<ESP8266WebServer> server;
|
||||||
|
#else
|
||||||
|
static std::unique_ptr<WebServer> server;
|
||||||
|
#endif
|
||||||
static std::unique_ptr<Ticker> rsttick;
|
static std::unique_ptr<Ticker> rsttick;
|
||||||
|
|
||||||
const char VALUE[] PROGMEM = "value='";
|
const char VALUE[] PROGMEM = "value='";
|
||||||
@ -291,7 +318,13 @@ void WiFiConfig::_handleNotFound(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
server->sendHeader(F("Location"), String(F("http://")) + server->client().localIP().toString() + String(F("/index.htm")), true);
|
String redirect;
|
||||||
|
redirect.reserve(256);
|
||||||
|
redirect = F("http://");
|
||||||
|
redirect.concat(server->client().localIP().toString());
|
||||||
|
redirect.concat(F("/index.htm"));
|
||||||
|
DEBUG_MSG("Redirection to: %s\r\n", redirect.c_str());
|
||||||
|
server->sendHeader(F("Location"), redirect, true);
|
||||||
server->send_P(302, TEXTPLAIN, PSTR("Redirect"));
|
server->send_P(302, TEXTPLAIN, PSTR("Redirect"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,20 +353,32 @@ void WiFiConfig::_handleInfo(void)
|
|||||||
reply.concat(F("<form><table><TR><TH>System Info<TH>"));
|
reply.concat(F("<form><table><TR><TH>System Info<TH>"));
|
||||||
|
|
||||||
reply.concat(F("<TR><TD>Core Version:<TD>"));
|
reply.concat(F("<TR><TD>Core Version:<TD>"));
|
||||||
reply.concat(ESP.getCoreVersion());
|
#if defined(ESP8266)
|
||||||
|
reply.concat(ESP.getFullVersion());
|
||||||
|
#else
|
||||||
|
// TODO
|
||||||
|
reply.concat(ESP.getSdkVersion());
|
||||||
|
#endif
|
||||||
|
|
||||||
reply.concat(F("<TR><TD>Flash Size:<TD>"));
|
reply.concat(F("<TR><TD>Flash Size:<TD>"));
|
||||||
|
#if defined(ESP8266)
|
||||||
reply.concat(ESP.getFlashChipRealSize() / 1024);
|
reply.concat(ESP.getFlashChipRealSize() / 1024);
|
||||||
|
#else
|
||||||
|
// TODO
|
||||||
|
reply.concat(ESP.getFlashChipSize());
|
||||||
|
#endif
|
||||||
reply.concat(F(" kB"));
|
reply.concat(F(" kB"));
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
reply.concat(F("<TR><TD>Sketch Size/Free:<TD>"));
|
reply.concat(F("<TR><TD>Sketch Size/Free:<TD>"));
|
||||||
reply.concat(ESP.getSketchSize() / 1024);
|
reply.concat(ESP.getSketchSize() / 1024);
|
||||||
reply.concat(F(" kB / "));
|
reply.concat(F(" kB / "));
|
||||||
reply.concat(ESP.getFreeSketchSpace() / 1024);
|
reply.concat(ESP.getFreeSketchSpace() / 1024);
|
||||||
reply.concat(F(" kB"));
|
reply.concat(F(" kB"));
|
||||||
|
#endif
|
||||||
|
|
||||||
reply.concat(F("<TR><TD>STA MAC:<TD>"));
|
reply.concat(F("<TR><TD>STA MAC:<TD>"));
|
||||||
uint8_t mac[] = {0, 0, 0, 0, 0, 0};
|
uint8_t mac[6];
|
||||||
uint8_t* macread = WiFi.macAddress(mac);
|
uint8_t* macread = WiFi.macAddress(mac);
|
||||||
char macaddress[20];
|
char macaddress[20];
|
||||||
sprintf_P(macaddress, PSTR("%02x:%02x:%02x:%02x:%02x:%02x"), macread[0], macread[1], macread[2], macread[3], macread[4], macread[5]);
|
sprintf_P(macaddress, PSTR("%02x:%02x:%02x:%02x:%02x:%02x"), macread[0], macread[1], macread[2], macread[3], macread[4], macread[5]);
|
||||||
@ -345,12 +390,21 @@ void WiFiConfig::_handleInfo(void)
|
|||||||
reply.concat(macaddress);
|
reply.concat(macaddress);
|
||||||
|
|
||||||
reply.concat(F("<TR><TD>ESP Chip ID:<TD>"));
|
reply.concat(F("<TR><TD>ESP Chip ID:<TD>"));
|
||||||
sprintf_P(buff, PSTR("%06X"), ESP.getChipId());
|
sprintf_P(buff, PSTR("%06X"), ESP_getChipId());
|
||||||
reply.concat(buff);
|
reply.concat(buff);
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
reply.concat(F("<TR><TD>Flash Chip ID:<TD>"));
|
reply.concat(F("<TR><TD>Flash Chip ID:<TD>"));
|
||||||
sprintf_P(buff, PSTR("%08X"), ESP.getFlashChipId());
|
sprintf_P(buff, PSTR("%08X"), ESP.getFlashChipId());
|
||||||
reply.concat(buff);
|
reply.concat(buff);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
|
uint8_t stations = wifi_softap_get_station_num();
|
||||||
|
|
||||||
|
reply.concat(F("<TR><TD>Clients:<TD>"));
|
||||||
|
reply.concat(stations);
|
||||||
|
#endif
|
||||||
|
|
||||||
reply.concat(F("</table></form>"));
|
reply.concat(F("</table></form>"));
|
||||||
server->send(200, FPSTR(TEXTHTML), reply);
|
server->send(200, FPSTR(TEXTHTML), reply);
|
||||||
@ -364,6 +418,7 @@ void WiFiConfig::_handleRoot(void)
|
|||||||
content = FPSTR(PAGE_CAPTIVEPORTALCATCH); // 1. cast stranky
|
content = FPSTR(PAGE_CAPTIVEPORTALCATCH); // 1. cast stranky
|
||||||
// pridame informaci o stavu pokusu o pripojeni
|
// pridame informaci o stavu pokusu o pripojeni
|
||||||
content.concat(F("<div class=\"vl-info\">Pokus o připojení: "));
|
content.concat(F("<div class=\"vl-info\">Pokus o připojení: "));
|
||||||
|
#if defined(ESP8266)
|
||||||
switch (_status)
|
switch (_status)
|
||||||
{
|
{
|
||||||
case STATION_IDLE:
|
case STATION_IDLE:
|
||||||
@ -402,6 +457,9 @@ void WiFiConfig::_handleRoot(void)
|
|||||||
content.concat(F("Neznámý"));
|
content.concat(F("Neznámý"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
content.concat(F("Prozatím nedostupné"));
|
||||||
|
#endif
|
||||||
content.concat(F("</div>"));
|
content.concat(F("</div>"));
|
||||||
content.concat(FPSTR(PAGE_CAPTIVEPORTALCATCH2)); // 2. cast stranky (ukonceni)
|
content.concat(FPSTR(PAGE_CAPTIVEPORTALCATCH2)); // 2. cast stranky (ukonceni)
|
||||||
server->send(200, FPSTR(TEXTHTML), content);
|
server->send(200, FPSTR(TEXTHTML), content);
|
||||||
@ -438,26 +496,25 @@ void WiFiConfig::_handleDisplayAP(void)
|
|||||||
s = FPSTR(SSID_ITEM);
|
s = FPSTR(SSID_ITEM);
|
||||||
s.replace(F("{v}"), WiFi.SSID(i));
|
s.replace(F("{v}"), WiFi.SSID(i));
|
||||||
s.replace(F("{a}"), String(quality));
|
s.replace(F("{a}"), String(quality));
|
||||||
|
#if defined(ESP8266)
|
||||||
s.replace(F("{s}"), (ENC_TYPE_NONE == WiFi.encryptionType(i)) ? F("") : F("l"));
|
s.replace(F("{s}"), (ENC_TYPE_NONE == WiFi.encryptionType(i)) ? F("") : F("l"));
|
||||||
|
#else
|
||||||
|
s.replace(F("{s}"), (WIFI_AUTH_OPEN == WiFi.encryptionType(i)) ? F("") : F("l"));
|
||||||
|
#endif
|
||||||
content.concat(s);
|
content.concat(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s = FPSTR(PAGE_INDEX2);
|
s = FPSTR(PAGE_INDEX2);
|
||||||
v = _readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
v = EES_readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
||||||
if (v.length())
|
if (v.length())
|
||||||
s.replace(F("{s}"), String(FPSTR(VALUE)) + v + F("'"));
|
s.replace(F("{s}"), String(FPSTR(VALUE)) + v + F("'"));
|
||||||
else
|
else
|
||||||
s.replace(F("{s}"), F("placeholder='SSID'"));
|
s.replace(F("{s}"), F(""));
|
||||||
v = _readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
v = EES_readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
||||||
if (v.length())
|
if (v.length())
|
||||||
s.replace(F("{p}"), String(FPSTR(VALUE)) + v + F("'"));
|
s.replace(F("{p}"), String(FPSTR(VALUE)) + v + F("'"));
|
||||||
else
|
else
|
||||||
s.replace(F("{p}"), F("placeholder='password'"));
|
s.replace(F("{p}"), F(""));
|
||||||
v = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname));
|
|
||||||
if (v.length())
|
|
||||||
s.replace(F("{n}"), String(FPSTR(VALUE)) + v + F("'"));
|
|
||||||
else
|
|
||||||
s.replace(F("{n}"), F("placeholder='name'"));
|
|
||||||
if (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)) == WIFIMODE_AP)
|
if (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)) == WIFIMODE_AP)
|
||||||
s.replace(F("{a}"), FPSTR(CHECKED));
|
s.replace(F("{a}"), FPSTR(CHECKED));
|
||||||
else
|
else
|
||||||
@ -510,13 +567,10 @@ void WiFiConfig::_handleSetAP(void)
|
|||||||
str = server->arg(F("_s"));
|
str = server->arg(F("_s"));
|
||||||
if (str.length() > 0)
|
if (str.length() > 0)
|
||||||
{
|
{
|
||||||
_storeString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), str);
|
EES_storeString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid), str);
|
||||||
|
|
||||||
str = server->arg(F("_p"));
|
str = server->arg(F("_p"));
|
||||||
_storeString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), str);
|
EES_storeString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass), str);
|
||||||
|
|
||||||
str = server->arg(F("_n"));
|
|
||||||
_storeString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname), str);
|
|
||||||
|
|
||||||
str = server->arg(F("_a"));
|
str = server->arg(F("_a"));
|
||||||
if (str.length() > 0)
|
if (str.length() > 0)
|
||||||
@ -572,20 +626,20 @@ void WiFiConfig::_handleSetAP(void)
|
|||||||
WiFi.disconnect(); // vsechno odpojime
|
WiFi.disconnect(); // vsechno odpojime
|
||||||
WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci
|
WiFi.persistent(true); // chceme, aby si modul zapamatoval konfiguraci
|
||||||
|
|
||||||
String s = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname));
|
String s = EES_readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
||||||
strcpy(WiFiDeviceName, s.c_str());
|
String pass = EES_readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
||||||
s = _readString(configBase + offsetof(wificonfigarea_t, ssid), elementSize(wificonfigarea_t, ssid));
|
|
||||||
String pass = _readString(configBase + offsetof(wificonfigarea_t, pass), elementSize(wificonfigarea_t, pass));
|
|
||||||
|
|
||||||
switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)))
|
switch (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)))
|
||||||
{
|
{
|
||||||
case WIFIMODE_STA:
|
case WIFIMODE_STA:
|
||||||
{
|
{
|
||||||
DEBUG_MSG("STA mode.\r\n");
|
DEBUG_MSG("STA mode.\r\n");
|
||||||
|
#if defined(ESP8266)
|
||||||
if (strlen(WiFiDeviceName))
|
if (strlen(WiFiDeviceName))
|
||||||
{
|
{
|
||||||
WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
WiFi.hostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
||||||
}
|
}
|
||||||
|
#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.\r\n");
|
DEBUG_MSG("Static configuration.\r\n");
|
||||||
@ -595,7 +649,18 @@ void WiFiConfig::_handleSetAP(void)
|
|||||||
}
|
}
|
||||||
WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta
|
WiFi.mode(WIFI_STA); // startujeme WiFi v rezimu klienta
|
||||||
WiFi.begin(s.c_str(), pass.c_str());
|
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);
|
wifi_station_set_auto_connect(true);
|
||||||
|
#else
|
||||||
|
//esp_wifi_set_auto_connect(true);
|
||||||
|
#endif
|
||||||
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -636,10 +701,14 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb)
|
|||||||
|
|
||||||
WiFi.persistent(false); // chranime flash pred zbytecnymi prepisy
|
WiFi.persistent(false); // chranime flash pred zbytecnymi prepisy
|
||||||
dnsServer.reset(new DNSServer());
|
dnsServer.reset(new DNSServer());
|
||||||
|
#if defined(ESP8266)
|
||||||
server.reset(new ESP8266WebServer(80));
|
server.reset(new ESP8266WebServer(80));
|
||||||
|
#else
|
||||||
|
server.reset(new WebServer(80));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Soft AP network parameters */
|
/* Soft AP network parameters */
|
||||||
IPAddress apIP(192, 168, 4, 1);
|
IPAddress apIP(172, 217, 28, 1);
|
||||||
IPAddress netMsk(255, 255, 255, 0);
|
IPAddress netMsk(255, 255, 255, 0);
|
||||||
|
|
||||||
WiFi.disconnect(); // pro jistotu se odpojime
|
WiFi.disconnect(); // pro jistotu se odpojime
|
||||||
@ -648,13 +717,9 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb)
|
|||||||
WiFi.softAPConfig(apIP, apIP, netMsk);
|
WiFi.softAPConfig(apIP, apIP, netMsk);
|
||||||
if (ssid.endsWith(F("?")))
|
if (ssid.endsWith(F("?")))
|
||||||
{
|
{
|
||||||
//uint8_t amac[6];
|
|
||||||
char lmac[16];
|
char lmac[16];
|
||||||
|
|
||||||
//WiFi.softAPmacAddress(amac);
|
sprintf_P(lmac, PSTR("%06X"), ESP_getChipId());
|
||||||
//sprintf_P(lmac, PSTR("%02X%02X%02X"), amac[3], amac[4], amac[5]);
|
|
||||||
|
|
||||||
sprintf_P(lmac, PSTR("%06X"), ESP.getChipId());
|
|
||||||
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);
|
||||||
@ -696,76 +761,66 @@ wificonfigresult_t WiFiConfig::_setupAP(wificonfig_cb cb)
|
|||||||
return WCR_TIMEOUT; // nepripojeno, vyprsel timeout konfiguracniho AP
|
return WCR_TIMEOUT; // nepripojeno, vyprsel timeout konfiguracniho AP
|
||||||
}
|
}
|
||||||
|
|
||||||
String WiFiConfig::_readString(unsigned int start, size_t maxlen)
|
|
||||||
{
|
|
||||||
uint8_t mac[WL_MAC_ADDR_LENGTH];
|
|
||||||
unsigned int enciphidx = 0;
|
|
||||||
String result;
|
|
||||||
unsigned int top = EEPROM.read(start);
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
result.reserve(maxlen);
|
|
||||||
WiFi.softAPmacAddress(mac);
|
|
||||||
if ((top > 0) && (top < (maxlen - 2)))
|
|
||||||
{
|
|
||||||
uint8_t b;
|
|
||||||
for (i = start + 1; i < + start + top + 1; ++i)
|
|
||||||
{
|
|
||||||
b = EEPROM.read(i);
|
|
||||||
|
|
||||||
b ^= mac[enciphidx];
|
|
||||||
++enciphidx;
|
|
||||||
enciphidx %= WL_MAC_ADDR_LENGTH;
|
|
||||||
|
|
||||||
result.concat(char(b));
|
|
||||||
}
|
|
||||||
b = EEPROM.read(i) ^ mac[enciphidx];
|
|
||||||
if (b != 0)
|
|
||||||
result = F(""); // spatna ukoncovaci nula - neplatny retezec
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool WiFiConfig::_storeString(unsigned int start, size_t maxlen, String &string)
|
|
||||||
{
|
|
||||||
uint8_t mac[WL_MAC_ADDR_LENGTH];
|
|
||||||
unsigned int enciphidx = 0;
|
|
||||||
unsigned int si = 0;
|
|
||||||
unsigned int top;
|
|
||||||
char c;
|
|
||||||
bool result = false; // retezec nebyl ulozeny cely (nevesel s do bufferu)
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
if (string.length() > maxlen - 2)
|
|
||||||
top = maxlen - 2;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = true; // retezec se do urceneho mista vejde
|
|
||||||
top = string.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
WiFi.softAPmacAddress(mac);
|
|
||||||
EEPROM.write(start, (uint8_t)top); // ulozime delku retezce (pouzite pr kontrolu pri vycitani)
|
|
||||||
for (i = start + 1; i < start + maxlen + 1; ++i)
|
|
||||||
{
|
|
||||||
c = string[si];
|
|
||||||
c ^= mac[enciphidx];
|
|
||||||
++enciphidx;
|
|
||||||
enciphidx %= WL_MAC_ADDR_LENGTH;
|
|
||||||
EEPROM.write(i, c);
|
|
||||||
++si;
|
|
||||||
}
|
|
||||||
c = 0 ^ mac[enciphidx];
|
|
||||||
EEPROM.write(i, c); // ukoncovaci a kontrolni nula
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Testovani, zda se modul pripojil k AP
|
// Testovani, zda se modul pripojil k AP
|
||||||
bool WiFiConfig::_testWifi(wificonfig_cb cb)
|
bool WiFiConfig::_testWifi(wificonfig_cb cb)
|
||||||
{
|
{
|
||||||
uint32_t startt = millis();
|
uint32_t startt = millis();
|
||||||
|
|
||||||
|
#if !defined(ESP8266)
|
||||||
|
// nakonfigurujeme ESP dle nove nastavenych parametru
|
||||||
|
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 (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 (strlen(WiFiDeviceName))
|
||||||
|
{
|
||||||
|
WiFi.setHostname(WiFiDeviceName); // nastavime jmeno zarizeni
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
DEBUG_MSG("Trying to connect.\r\n");
|
DEBUG_MSG("Trying to connect.\r\n");
|
||||||
while ((millis() - startt) < WIFI_STA_CONNECT_TIMEOUT)
|
while ((millis() - startt) < WIFI_STA_CONNECT_TIMEOUT)
|
||||||
{
|
{
|
||||||
@ -781,11 +836,15 @@ bool WiFiConfig::_testWifi(wificonfig_cb cb)
|
|||||||
cb(WCS_CONNECTING); // signalizujeme pokracujici pokus o spojeni
|
cb(WCS_CONNECTING); // signalizujeme pokracujici pokus o spojeni
|
||||||
}
|
}
|
||||||
DEBUG_MSG("Not connected!\r\n");
|
DEBUG_MSG("Not connected!\r\n");
|
||||||
|
#if defined(ESP8266)
|
||||||
_status = wifi_station_get_connect_status();
|
_status = wifi_station_get_connect_status();
|
||||||
|
#else
|
||||||
|
_status = WiFi.status();
|
||||||
|
#endif
|
||||||
return false; // pripojeni se nezdarilo
|
return false; // pripojeni se nezdarilo
|
||||||
}
|
}
|
||||||
|
|
||||||
wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, wificonfig_cb cb)
|
wificonfigresult_t WiFiConfig::begin(int configarea, int forceConfigure, wificonfig_cb cb)
|
||||||
{
|
{
|
||||||
wificonfigresult_t result = WCR_OK; // predpokladame, ze se pripojeni podari
|
wificonfigresult_t result = WCR_OK; // predpokladame, ze se pripojeni podari
|
||||||
|
|
||||||
@ -800,22 +859,25 @@ wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, wif
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(ESP8266)
|
||||||
if (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)) != WiFi.getMode())
|
if (EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)) != WiFi.getMode())
|
||||||
{ // neshoduje se rezim - musime spustit konfiguracni AP (poskozena konfigurace)
|
{ // neshoduje se rezim - musime spustit konfiguracni AP (poskozena konfigurace)
|
||||||
DEBUG_MSG("Wrong config\r\n");
|
DEBUG_MSG("Wrong config (%d, %d)\r\n", EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)), WiFi.getMode());
|
||||||
_status = 0xfe;
|
_status = 0xfe;
|
||||||
result = _setupAP(cb);
|
result = _setupAP(cb);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
String s = _readString(configBase + offsetof(wificonfigarea_t, devname), elementSize(wificonfigarea_t, devname));
|
|
||||||
strcpy(WiFiDeviceName, s.c_str());
|
|
||||||
|
|
||||||
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)
|
||||||
WiFi.hostname(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");
|
||||||
@ -842,24 +904,30 @@ wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, wif
|
|||||||
if (cb)
|
if (cb)
|
||||||
cb(WCS_CONNECTSTART); // signalizujeme zacatek pokusu o pripojeni (zde se nic jineho stejne nestane...)
|
cb(WCS_CONNECTSTART); // signalizujeme zacatek pokusu o pripojeni (zde se nic jineho stejne nestane...)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
#if !defined(ESP8266)
|
||||||
|
default:
|
||||||
|
DEBUG_MSG("Wrong config (%d)\r\n", EEPROM.read(configBase + offsetof(wificonfigarea_t, mode)));
|
||||||
|
_status = 0xfe;
|
||||||
|
result = _setupAP(cb);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result; // mame vyreseno
|
return result; // mame vyreseno
|
||||||
}
|
}
|
||||||
|
|
||||||
wificonfigresult_t WiFiConfig::begin(int configarea, uint8_t forceConfigure, int timeout, wificonfig_cb cb = NULL)
|
wificonfigresult_t WiFiConfig::begin(int configarea, int forceConfigure, int timeout, wificonfig_cb cb = NULL)
|
||||||
{
|
{
|
||||||
if (forceConfigure)
|
|
||||||
{ // pouze pokud nemame vynucenou konfiguraci merime cas - to nam umozni dostat se ze spatne zadaneho timeoutu, ktery se neda zvladnout
|
|
||||||
if ((timeout > 0) && (40 > timeout))
|
if ((timeout > 0) && (40 > timeout))
|
||||||
timeout = 40; // timeout musi byt minimalne 40 sekund
|
timeout = 40; // timeout musi byt minimalne 40 sekund
|
||||||
|
if ((0 == forceConfigure) && (WC_DONT_RUN_CONFIGAP == timeout))
|
||||||
|
timeout = 40;
|
||||||
_timeout = timeout;
|
_timeout = timeout;
|
||||||
if (_timeout > 0)
|
if (_timeout > 0)
|
||||||
_time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat
|
_time = millis() + (_timeout * 1000); // spocitame si novy cas, kdy budeme modul restartovat
|
||||||
}
|
|
||||||
else
|
|
||||||
_timeout = 0; // pri vynucene konfiguraci se parametr timeout neuplatni
|
|
||||||
return begin(configarea, forceConfigure, cb); // spustime WiFi
|
return begin(configarea, forceConfigure, cb); // spustime WiFi
|
||||||
}
|
}
|
||||||
// EOF
|
// EOF
|
||||||
|
@ -30,7 +30,11 @@
|
|||||||
#ifndef __WiFiConfig_h__
|
#ifndef __WiFiConfig_h__
|
||||||
#define __WiFiConfig_h__
|
#define __WiFiConfig_h__
|
||||||
|
|
||||||
|
#if defined(ESP8266)
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
|
#else
|
||||||
|
#include <WiFi.h>
|
||||||
|
#endif
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#define elementSize(type, element) sizeof(((type *)0)->element)
|
#define elementSize(type, element) sizeof(((type *)0)->element)
|
||||||
@ -44,7 +48,6 @@ typedef struct
|
|||||||
uint8_t ip; // konfigurace ip (staticka/DHCP)
|
uint8_t ip; // konfigurace ip (staticka/DHCP)
|
||||||
char ssid[32 + 2]; // SSID site
|
char ssid[32 + 2]; // SSID site
|
||||||
char pass[64 + 2]; // heslo
|
char pass[64 + 2]; // heslo
|
||||||
char devname[32 + 2]; // jmeno zarizeni (pro NBNS plati jen 16 znaku)
|
|
||||||
uint32_t ipaddr; // ip adresa v pripade staticke konfigurace
|
uint32_t ipaddr; // ip adresa v pripade staticke konfigurace
|
||||||
uint32_t netmask; // sitova maska v pripade staticke konfigurace
|
uint32_t netmask; // sitova maska v pripade staticke konfigurace
|
||||||
uint32_t gateway; // sitova brana v pripade staticke konfigurace
|
uint32_t gateway; // sitova brana v pripade staticke konfigurace
|
||||||
@ -139,8 +142,6 @@ uint32_t getEEPROMuint32(int start);
|
|||||||
*/
|
*/
|
||||||
void setEEPROMuint32(int start, uint32_t val);
|
void setEEPROMuint32(int start, uint32_t val);
|
||||||
|
|
||||||
extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP
|
|
||||||
|
|
||||||
class WiFiConfigUsrParameter
|
class WiFiConfigUsrParameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -169,8 +170,8 @@ class WiFiConfig
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WiFiConfig(): _params(NULL), _timeout(0) {}
|
WiFiConfig(): _params(NULL), _timeout(0) {}
|
||||||
wificonfigresult_t begin(int configarea, uint8_t forceConfigure, wificonfig_cb cb);
|
wificonfigresult_t begin(int configarea, int forceConfigure, wificonfig_cb cb);
|
||||||
wificonfigresult_t begin(int configarea, uint8_t 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);
|
||||||
private:
|
private:
|
||||||
wificonfigresult_t _setupAP(wificonfig_cb cb);
|
wificonfigresult_t _setupAP(wificonfig_cb cb);
|
||||||
|
@ -37,7 +37,6 @@ static const char SSID_ITEM[] PROGMEM = R"=====(
|
|||||||
/* Zacatek formulare pro vyplneni
|
/* Zacatek formulare pro vyplneni
|
||||||
{s} - SSID
|
{s} - SSID
|
||||||
{p} - password
|
{p} - password
|
||||||
{n} - Netbios name
|
|
||||||
{a} - AP mode (checkbox)
|
{a} - AP mode (checkbox)
|
||||||
{ch}- cislo kanalu AP
|
{ch}- cislo kanalu AP
|
||||||
{c} - staticka IP konfigurace (checkbox)
|
{c} - staticka IP konfigurace (checkbox)
|
||||||
@ -48,9 +47,8 @@ static const char SSID_ITEM[] PROGMEM = R"=====(
|
|||||||
*/
|
*/
|
||||||
static const char PAGE_INDEX2[] PROGMEM = R"=====(
|
static const char PAGE_INDEX2[] PROGMEM = R"=====(
|
||||||
<form method='post' action='s'>
|
<form method='post' action='s'>
|
||||||
<label>SSID<br><input id='_s' name='_s' maxlength=32 required {s}></label><br>
|
<label>SSID<br><input id='_s' name='_s' maxlength=32 required placeholder='SSID' {s}></label><br>
|
||||||
<label>Heslo<br><input id='_p' name='_p' maxlength=64 {p} type='password'></label><br>
|
<label>Heslo<br><input id='_p' name='_p' maxlength=64 {p} type='password' placeholder='heslo'></label><br>
|
||||||
<label>Jméno zařízení<br><input name='_n' maxlength=32 pattern='^[a-zA-Z][a-zA-Z0-9-_\\.]{1,32}$' title='Jméno dle NetBios konvence (max. 16 znaků písmena, čísla a znaky "_.")' {n}></label><br>
|
|
||||||
<div>
|
<div>
|
||||||
<label><input id='_a' name='_a' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hAP();' {a}>Režim AP</label>
|
<label><input id='_a' name='_a' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hAP();' {a}>Režim AP</label>
|
||||||
<div id="apconfig">
|
<div id="apconfig">
|
||||||
@ -58,12 +56,12 @@ static const char PAGE_INDEX2[] PROGMEM = R"=====(
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label><input id='_st' name='_st' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hSC();' {c}>Staticka IP konfigurace</label>
|
<label><input id='_st' name='_st' type='checkbox' style="width: 10%; float: left; margin-top: 5px;" onclick='hSC();' {c}>Statická IP konfigurace</label>
|
||||||
<div id="staticip">
|
<div id="staticip">
|
||||||
<label>IP adresa<br><input type="text" name="_i" pattern='((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$' title='ip adresa ve formatu <cislo>.<cislo>.<cislo>.<cislo>' value='{i}'></label><br>
|
<label>IP adresa<br><input type="text" name="_i" value='{i}'></label><br>
|
||||||
<label>Síťová maska<br><input type="text" name="_m" pattern='((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$' title='ip adresa ve formatu <cislo>.<cislo>.<cislo>.<cislo>' value='{m}'></label><br>
|
<label>Síťová maska<br><input type="text" name="_m" value='{m}'></label><br>
|
||||||
<label>Síťová brána<br><input type="text" name="_g" pattern='((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$' title='ip adresa ve formatu <cislo>.<cislo>.<cislo>.<cislo>' value='{g}'></label><br>
|
<label>Síťová brána<br><input type="text" name="_g" value='{g}'></label><br>
|
||||||
<label>Server DNS<br><input type="text" name="_d" pattern='((^|\.)((25[0-5])|(2[0-4]\d)|(1\d\d)|([1-9]?\d))){4}$' title='ip adresa ve formatu <cislo>.<cislo>.<cislo>.<cislo>' value='{d}'></label><br>
|
<label>Server DNS<br><input type="text" name="_d" value='{d}'></label><br>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>hAP();hSC();</script>
|
<script>hAP();hSC();</script>
|
||||||
|
Reference in New Issue
Block a user