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
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,11 @@
|
|||||||
#ifndef __WiFiConfig_h__
|
#ifndef __WiFiConfig_h__
|
||||||
#define __WiFiConfig_h__
|
#define __WiFiConfig_h__
|
||||||
|
|
||||||
#include <ESP8266WiFi.h>
|
#if defined(ESP8266)
|
||||||
|
#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