Compare commits
12 Commits
v5.7
...
7a6f936a1a
Author | SHA1 | Date | |
---|---|---|---|
7a6f936a1a | |||
3a8ffdcd01 | |||
dc8aa8890d | |||
81ceb9aca9 | |||
33f8f6a8b8 | |||
f5fce8dee3 | |||
8c23c4eddb | |||
51ae416dd0 | |||
a742f624fb | |||
242238a1f0 | |||
f4f8915197 | |||
68083ee040 |
@ -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 |
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"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":
|
||||||
{
|
{
|
||||||
"name": "Pavel Brychta",
|
"name": "Pavel Brychta",
|
||||||
@ -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.7",
|
"version": "6.0",
|
||||||
"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.7
|
version=6.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 module to be configured over network. 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
@ -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,16,17 Pavel Brychta. All rights reserved.
|
* Copyright (c) 2015-18 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
|
||||||
@ -24,12 +24,17 @@
|
|||||||
* 1. Pokud je forceConfigure ==0, tak se aktivuje WiFi v rezimu AP a cele ESP je mozne nastavit webovym rozhranim (pocitam s prenosem hodnoty nouzoveho tlacitka pri startu).
|
* 1. Pokud je forceConfigure ==0, tak se aktivuje WiFi v rezimu AP a cele ESP je mozne nastavit webovym rozhranim (pocitam s prenosem hodnoty nouzoveho tlacitka pri startu).
|
||||||
* 2. Neni-li tlacitko stisknute, tak se vezme rezim prace a AP se nastavi dle nej (WIFI_STA a WIFI_AP)
|
* 2. Neni-li tlacitko stisknute, tak se vezme rezim prace a AP se nastavi dle nej (WIFI_STA a WIFI_AP)
|
||||||
* 3. Pokud byl rezim prace WIFI_STA a ESP se nepripoji k zadne siti do casu WIFI_STA_CONNECT_TIMEOUT, tak se pokracuje jako kdyby bylo stisknute rekonfiguracni tlacitko
|
* 3. Pokud byl rezim prace WIFI_STA a ESP se nepripoji k zadne siti do casu WIFI_STA_CONNECT_TIMEOUT, tak se pokracuje jako kdyby bylo stisknute rekonfiguracni tlacitko
|
||||||
|
* Podrobnejsi informace o upravach chovani v jednotlivych verzich jsou v zahlavi .cpp souboru.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#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)
|
||||||
@ -41,9 +46,9 @@ typedef struct
|
|||||||
{
|
{
|
||||||
uint8_t mode; // rezim prace AP/STA
|
uint8_t mode; // rezim prace AP/STA
|
||||||
uint8_t ip; // konfigurace ip (staticka/DHCP)
|
uint8_t ip; // konfigurace ip (staticka/DHCP)
|
||||||
char ssid[32]; // SSID site
|
char ssid[32 + 2]; // SSID site
|
||||||
char pass[64]; // heslo
|
char pass[64 + 2]; // heslo
|
||||||
char devname[32]; // jmeno zarizeni (pro NBNS plati jen 16 znaku)
|
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
|
||||||
@ -93,7 +98,7 @@ typedef void (*storeparam_cb)(const char *newvalue); // callback pro ulozeni uzi
|
|||||||
* \param [in] len Delka retezce
|
* \param [in] len Delka retezce
|
||||||
* \return Vycteny retezec
|
* \return Vycteny retezec
|
||||||
*/
|
*/
|
||||||
String getEEPROMString(int start, int len);
|
String getEEPROMString(unsigned int start, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ulozeni retezce do EEPROM
|
* \brief Ulozeni retezce do EEPROM
|
||||||
@ -102,7 +107,7 @@ String getEEPROMString(int start, int len);
|
|||||||
* \param [in] len Maximalni delka ulozeneho retezce
|
* \param [in] len Maximalni delka ulozeneho retezce
|
||||||
* \param [in] string Ukladany retezec
|
* \param [in] string Ukladany retezec
|
||||||
*/
|
*/
|
||||||
void setEEPROMString(int start, int len, String string);
|
void setEEPROMString(unsigned int start, size_t len, String &string);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Ziskani nasi ip adresy
|
* \brief Ziskani nasi ip adresy
|
||||||
@ -121,8 +126,21 @@ IPAddress getOurIP(void);
|
|||||||
*/
|
*/
|
||||||
uint8_t * getOurMAC(uint8_t *mac);
|
uint8_t * getOurMAC(uint8_t *mac);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Ziskani 32 bitoveho cisla z EEPROM
|
||||||
|
*
|
||||||
|
* @param[in] start Pocatecni adresa, ze ktere se ziskava cislo.
|
||||||
|
*
|
||||||
|
* @return Ziskane cislo.
|
||||||
|
*/
|
||||||
uint32_t getEEPROMuint32(int start);
|
uint32_t getEEPROMuint32(int start);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Ulozeni 32 bitoveho cisla do EEPROM
|
||||||
|
*
|
||||||
|
* @param[in] start Pocatecni adresa, kam cislo ukladame.
|
||||||
|
* @param[in] val Ukladana hodnota
|
||||||
|
*/
|
||||||
void setEEPROMuint32(int start, uint32_t val);
|
void setEEPROMuint32(int start, uint32_t val);
|
||||||
|
|
||||||
extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP
|
extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP
|
||||||
@ -130,23 +148,23 @@ extern char WiFiDeviceName[]; // jmeno zarizeni, pouzivane i pro DHCP
|
|||||||
class WiFiConfigUsrParameter
|
class WiFiConfigUsrParameter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, int length, storeparam_cb cb);
|
WiFiConfigUsrParameter(const char *id, const char *label, const char *defaultValue, unsigned int length, storeparam_cb cb);
|
||||||
|
|
||||||
const char *getID();
|
const char *getID();
|
||||||
const char *getValue();
|
const char *getValue();
|
||||||
const char *getLabel();
|
const char *getLabel();
|
||||||
int getValueLength();
|
int getValueLength();
|
||||||
void setNext(WiFiConfigUsrParameter *n);
|
void setNext(WiFiConfigUsrParameter *n);
|
||||||
WiFiConfigUsrParameter *getNext();
|
WiFiConfigUsrParameter *getNext();
|
||||||
void setNewValue(const char *newval);
|
void setNewValue(const char *newval);
|
||||||
private:
|
private:
|
||||||
const char *_id;
|
const char *_id;
|
||||||
const char *_label;
|
const char *_label;
|
||||||
char *_value;
|
char *_value;
|
||||||
int _length;
|
int _length;
|
||||||
|
|
||||||
storeparam_cb _cb;
|
storeparam_cb _cb;
|
||||||
WiFiConfigUsrParameter *_next;
|
WiFiConfigUsrParameter *_next;
|
||||||
|
|
||||||
friend class WiFiConfig;
|
friend class WiFiConfig;
|
||||||
};
|
};
|
||||||
@ -155,9 +173,9 @@ 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);
|
||||||
void _handleDisplayAP(void);
|
void _handleDisplayAP(void);
|
||||||
@ -167,6 +185,8 @@ private:
|
|||||||
void _handleNotFound(); // CaptivePortal redirector
|
void _handleNotFound(); // CaptivePortal redirector
|
||||||
void _handleRoot(); // jen jednoducha stranka kvuli CaptivePortalu umoznuje prejit na spravnou stranku (ale nedela to...)
|
void _handleRoot(); // jen jednoducha stranka kvuli CaptivePortalu umoznuje prejit na spravnou stranku (ale nedela to...)
|
||||||
bool _testWifi(wificonfig_cb cb);
|
bool _testWifi(wificonfig_cb cb);
|
||||||
|
bool _storeString(unsigned int start, size_t maxlen, String &string); // sifrovany retezec, max 255 znaku
|
||||||
|
String _readString(unsigned int start, size_t maxlen); // sifrovany retezec, max. 255 znaku
|
||||||
WiFiConfigUsrParameter *_searchUsrParameter(const char *name);
|
WiFiConfigUsrParameter *_searchUsrParameter(const char *name);
|
||||||
|
|
||||||
WiFiConfigUsrParameter *_params; // ukazatel na posledni zadany uzivatelsky parametr
|
WiFiConfigUsrParameter *_params; // ukazatel na posledni zadany uzivatelsky parametr
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
// file:///I:/MyProjects/PB_ESP8266_WiFiConfig_Vyvoj/doc/_testy/s?_s=SSID1&_p=heslo&_n=jmeno_zarizeni&_a=on&_st=on&_i=192.168.1.1&_m=255.255.255.0&_g=192.168.1.3&_d=192.168.1.3&{n}={v}
|
// HTML data
|
||||||
static const char TEXTHTML[] PROGMEM = "text/html";
|
static const char TEXTHTML[] PROGMEM = "text/html";
|
||||||
|
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">
|
||||||
@ -25,11 +26,12 @@ function hSC(){if (document.getElementById('_st').checked){document.getElementBy
|
|||||||
|
|
||||||
/* Polozky nalezenych SSID
|
/* Polozky nalezenych SSID
|
||||||
{v} - SSID
|
{v} - SSID
|
||||||
{a} - RSSI (primo v dBm)
|
{a} - RSSI (%)
|
||||||
{s} - bud nic, nebo 'l'>
|
{s} - bud nic, nebo 'l'>
|
||||||
|
Rozsahy otestovany zde https://css-tricks.com/html5-meter-element/
|
||||||
*/
|
*/
|
||||||
static const char SSID_ITEM[] PROGMEM = R"=====(
|
static const char SSID_ITEM[] PROGMEM = R"=====(
|
||||||
<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {s}'><meter value="{a}" min="0" max="100" low="30" high="80" optimum="50" style="width: 70%;"></meter></span></div>
|
<div><a href='#p' onclick='c(this)'>{v}</a> <span class='q {s}'><meter value="{a}" min="0" low="30" optimum="70" high="60" max="100" style="width: 70%;"></meter></span></div>
|
||||||
)=====";
|
)=====";
|
||||||
|
|
||||||
/* Zacatek formulare pro vyplneni
|
/* Zacatek formulare pro vyplneni
|
||||||
|
Reference in New Issue
Block a user