17 Commits
v6.0 ... 6.3.2

Author SHA1 Message Date
52648c8915 Footer, info pro ESP32, lepsi reset stranka 2019-10-04 19:30:14 +02:00
e66a3306f1 Navrh na footer 2019-10-04 13:03:23 +02:00
4033637b82 Indikace stavu pripojeni pro ESP32 2019-10-04 10:50:35 +02:00
ed1659791a Odstraneni HTML5 validatoru 2019-09-02 06:46:45 +02:00
60f106cef3 Merge branch 'feature/ipChange' of pablo2048/WiFiConfig into master 2019-08-28 12:55:44 +02:00
4590e99a54 Oprava chovani pri vynucene konfiguraci a pozadavku rychleho startu. Posun cisla verze v json 2019-08-12 11:04:01 +02:00
557d06a557 Zmena default ip adresy 2019-08-12 10:17:52 +02:00
f45d742435 Oprava demo prikladu. Funkcni i ve verzi core 2.4.2 2019-08-07 12:01:00 +02:00
3172bb0d17 Dalsi fixy v ESP32 casti 2019-01-06 11:00:45 +01:00
90618b0ae6 Undo zmena ip adresy - zatim to nepomohlo. Bugfix v ESP32 kodu. 2019-01-06 10:08:04 +01:00
7fec2df6b9 Zmena ip adresy na 10.1.1.1 kvuli Captive portalu 2018-12-21 07:43:11 +01:00
d0e01c567c Odstranena nepouzivana cast. Vse se zda byt funkcni. 2018-12-12 10:02:39 +01:00
48986510dd drobne zmeny v umisteni placeholderu 2018-12-12 09:18:58 +01:00
90da6a05e5 Verze 6.2 - pozor - zatim se nezobrazi ssid a heslo ve formulari 2018-12-12 08:52:50 +01:00
7a6f936a1a Sifrovani retezcu je nyni v externi knihovne. 2018-12-11 08:33:11 +01:00
3a8ffdcd01 Odstraneny zbytecny vypis timeoutu. 2018-11-20 16:57:26 +01:00
dc8aa8890d Reformatovani textu po zasahu VSC :-( 2018-11-20 16:53:18 +01:00
6 changed files with 537 additions and 543 deletions

View File

@ -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);

View File

@ -12,7 +12,7 @@
"type": "git", "type": "git",
"url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git" "url": "http://git.xpablo.cz/pablo2048/WiFiConfig.git"
}, },
"version": "6.0", "version": "6.3.1",
"license": "MIT", "license": "MIT",
"frameworks": "arduino", "frameworks": "arduino",
"platforms": ["espressif8266", "espressif32"], "platforms": ["espressif8266", "espressif32"],

View File

@ -1,5 +1,5 @@
name=WiFiConfig name=WiFiConfig
version=6.0 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.

File diff suppressed because it is too large Load Diff

View File

@ -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-18 Pavel Brychta. All rights reserved. * Copyright (c) 2015-19 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
@ -48,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
@ -143,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:

View File

@ -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>
@ -83,9 +81,22 @@ static const char PAGE_PARAM[] PROGMEM = R"=====(
static const char PAGE_END[] PROGMEM = R"=====( static const char PAGE_END[] PROGMEM = R"=====(
<br> <br>
<button type='submit'>Uložit a restartovat</button></form> <button type='submit'>Uložit a restartovat</button></form>
</div></body></html> </div>)====="
#if defined APP_NAME && defined APP_VERSION
R"=====(<div style='text-align:right;font-size:11px;'><hr/>)====="
APP_NAME
" v"
APP_VERSION
R"=====(</div>
)====="
#else
R"=====(<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpablo.cz' target='_blank' style='color:#aaa;'>WiFiConfig by xPablo</a></div>)====="
#endif
R"=====(</body></html>
)====="; )=====";
/*
<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpablo.cz' target='_blank' style='color:#aaa;'>WiFiConfig by xPablo</a></div>
*/
// Nenalezeno zadne SSID // Nenalezeno zadne SSID
static const char PAGE_NO_SSID[] PROGMEM = R"=====( static const char PAGE_NO_SSID[] PROGMEM = R"=====(
<div>Nenalezená žádná síť. Občerstvi stránku pro nové hledání.</div> <div>Nenalezená žádná síť. Občerstvi stránku pro nové hledání.</div>
@ -93,13 +104,13 @@ static const char PAGE_NO_SSID[] PROGMEM = R"=====(
// Konfigurace ulozena - restartuji... // Konfigurace ulozena - restartuji...
static const char PAGE_SAVED[] PROGMEM = R"=====( static const char PAGE_SAVED[] PROGMEM = R"=====(
<!DOCTYPE html><html lang="cs"><head><meta http-equiv="refresh" content="10;url=/"/> <!DOCTYPE html><html lang="cs"><head><meta http-equiv="refresh" content="5;url=/"/>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/> <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/>
<title>xPablo Setup - Konfigurace uložena</title> <title>xPablo Setup - Konfigurace uložena</title>
<style>div,input {margin-bottom: 5px;}body{width:200px;display:block;margin-left:auto;margin-right:auto;}</style> <style>div,input {margin-bottom: 5px;}body{width:200px;display:block;margin-left:auto;margin-right:auto;}</style>
</head><body> </head><body>
Uloženo do EEPROM...<br/> Uloženo do EEPROM...<br/>
Restart za 10 sekund. Restart za 5 sekund.
</body></html> </body></html>
)====="; )=====";
@ -113,11 +124,29 @@ static const char PAGE_CAPTIVEPORTALCATCH[] PROGMEM = R"=====(
<form action="/config" method="get"><button>Konfigurace WiFi</button></form><br/><form action="/i" method="get"><button>Informace o modulu</button></form><br/><form action="/r" method="post"><button class="red">Reset</button></form><br> <form action="/config" method="get"><button>Konfigurace WiFi</button></form><br/><form action="/i" method="get"><button>Informace o modulu</button></form><br/><form action="/r" method="post"><button class="red">Reset</button></form><br>
)====="; )=====";
// druha cast (mezi 1. a druhou cast muzeme doplnit dodatecne informace) // druha cast (mezi 1. a 2. cast muzeme doplnit dodatecne informace)
static const char PAGE_CAPTIVEPORTALCATCH2[] PROGMEM = R"=====( static const char PAGE_CAPTIVEPORTALCATCH2[] PROGMEM = R"=====(
</div></body></html> </div>
)====="
#if defined APP_NAME && defined APP_VERSION
R"=====(<div style='text-align:right;font-size:11px;'><hr/>)====="
APP_NAME
" v"
APP_VERSION
R"=====(</div>
)====="
#else
R"=====(<div style='text-align:right;font-size:11px;'><hr/><a href='http://xpablo.cz' target='_blank' style='color:#aaa;'>WiFiConfig by xPablo</a></div>)====="
#endif
R"=====(</body></html>
)====="; )=====";
static const char PAGE_RESTART[] PROGMEM = R"=====( static const char PAGE_RESTART[] PROGMEM = R"=====(
Restartuji... <!DOCTYPE html><html lang="cs"><head><meta http-equiv="refresh" content="5;url=/"/>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"/>
<title>xPablo Setup - Restart</title>
<style>div,input {margin-bottom: 5px;}body{width:200px;display:block;margin-left:auto;margin-right:auto;}</style>
</head><body>
Restartuji...
</body></html>
)====="; )=====";