From 8b4dd5b2636fc1bfa4180e4c58e6d4d6aba9d16b Mon Sep 17 00:00:00 2001
From: Florian <1technophile@users.noreply.github.com>
Date: Sat, 4 Aug 2018 15:01:25 +0200
Subject: [PATCH 01/19] Update README.md
---
README.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README.md b/README.md
index 5cf447b..579d9f8 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,7 @@ Download OpenMQTTGateway from [here](https://github.com/1technophile/OpenMQTTGat
A list of supported 433mhz devices is available [here](https://community.home-assistant.io/t/433tomqttto433-gateway-device-list/7819):
https://community.home-assistant.io/t/433tomqttto433-gateway-device-list/7819
+
+If you want to buy a coffee or other beverage so as to give me some support, here is a way to do it :
+
+
From 0134f9ab0e7391d0108a9c041e45ff0d69f62088 Mon Sep 17 00:00:00 2001
From: Florian <1technophile@users.noreply.github.com>
Date: Sat, 11 Aug 2018 16:45:05 +0200
Subject: [PATCH 02/19] Create stale.yml
enable auto closing of issues without activity
---
.github/ISSUE_TEMPLATE/stale.yml | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
create mode 100644 .github/ISSUE_TEMPLATE/stale.yml
diff --git a/.github/ISSUE_TEMPLATE/stale.yml b/.github/ISSUE_TEMPLATE/stale.yml
new file mode 100644
index 0000000..2dc5b67
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/stale.yml
@@ -0,0 +1,19 @@
+# Number of days of inactivity before an issue becomes stale
+daysUntilStale: 60
+# Number of days of inactivity before a stale issue is closed
+daysUntilClose: 7
+# Issues with these labels will never be considered stale
+exemptLabels:
+ - pinned
+ - security
+ - enhancement
+ - bug
+# Label to use when marking an issue as stale
+staleLabel: wontfix
+# Comment to post when marking an issue as stale. Set to `false` to disable
+markComment: >
+ This issue has been automatically marked as stale because it has not had
+ recent activity. It will be closed if no further activity occurs. Thank you
+ for your contributions.
+# Comment to post when closing a stale issue. Set to `false` to disable
+closeComment: false
From f0c060791964e3f540b56e7833da244c81195dec Mon Sep 17 00:00:00 2001
From: Florian <1technophile@users.noreply.github.com>
Date: Sun, 19 Aug 2018 15:36:06 +0200
Subject: [PATCH 03/19] Update wifimanager to 0.14 (#252)
---
lib/WiFiManager/README.md | 25 ++--
lib/WiFiManager/WiFiManager.cpp | 136 +++++++++++++-----
lib/WiFiManager/WiFiManager.h | 27 ++--
.../examples/AutoConnect/AutoConnect.ino | 2 +-
.../AutoConnectWithFSParameters.ino | 1 +
.../OnDemandConfigPortal.ino | 2 +-
.../extras/WiFiManager.template.html | 112 ++++++++++-----
lib/WiFiManager/extras/parse.js | 60 ++++++++
lib/WiFiManager/extras/template.h | 12 ++
lib/WiFiManager/library.json | 4 +-
lib/WiFiManager/library.properties | 2 +-
11 files changed, 287 insertions(+), 96 deletions(-)
create mode 100644 lib/WiFiManager/extras/parse.js
create mode 100644 lib/WiFiManager/extras/template.h
diff --git a/lib/WiFiManager/README.md b/lib/WiFiManager/README.md
index a329f2b..3782339 100644
--- a/lib/WiFiManager/README.md
+++ b/lib/WiFiManager/README.md
@@ -1,3 +1,5 @@
+## Current development going on here :arrow_right: [Development Branch](https://github.com/tzapu/WiFiManager/tree/development)
+
# WiFiManager
ESP8266 WiFi Connection manager with fallback web configuration portal
@@ -43,16 +45,19 @@ First attempt at a library. Lots more changes and fixes to do. Contributions are
 
## Wishlist
-- ~~remove dependency on EEPROM library~~
-- ~~move HTML Strings to PROGMEM~~
-- ~~cleanup and streamline code~~ (although this is ongoing)
-- if timeout is set, extend it when a page is fetched in AP mode
-- ~~add ability to configure more parameters than ssid/password~~
-- ~~maybe allow setting ip of ESP after reboot~~
-- ~~add to Arduino Library Manager~~
-- ~~add to PlatformIO~~
-- add multiple sets of network credentials
-- ~~allow users to customize CSS~~
+- [x] remove dependency on EEPROM library
+- [x] move HTML Strings to PROGMEM
+- [x] cleanup and streamline code (although this is ongoing)
+- [x] if timeout is set, extend it when a page is fetched in AP mode
+- [x] add ability to configure more parameters than ssid/password
+- [x] maybe allow setting ip of ESP after reboot
+- [x] add to Arduino Library Manager
+- [x] add to PlatformIO
+- [ ] add multiple sets of network credentials
+- [x] allow users to customize CSS
+- [ ] ESP32 support or instructions
+- [ ] rewrite documentation for simplicity, based on scenarios/goals
+- [ ] rely on the SDK's built in auto connect more than forcing a connect
## Quick Start
diff --git a/lib/WiFiManager/WiFiManager.cpp b/lib/WiFiManager/WiFiManager.cpp
index 3fbbb42..2e7884d 100644
--- a/lib/WiFiManager/WiFiManager.cpp
+++ b/lib/WiFiManager/WiFiManager.cpp
@@ -5,7 +5,7 @@
inspired by:
http://www.esp8266.com/viewtopic.php?f=29&t=2520
https://github.com/chriscook8/esp-arduino-apboot
- https://github.com/esp8266/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/DNSServer/examples/CaptivePortalAdvanced
+ https://github.com/esp8266/Arduino/tree/master/libraries/DNSServer/examples/CaptivePortalAdvanced
Built by AlexT https://github.com/tzapu
Licensed under MIT license
**************************************************************/
@@ -34,7 +34,7 @@ void WiFiManagerParameter::init(const char *id, const char *placeholder, const c
_placeholder = placeholder;
_length = length;
_value = new char[length + 1];
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < length + 1; i++) {
_value[i] = 0;
}
if (defaultValue != NULL) {
@@ -44,6 +44,12 @@ void WiFiManagerParameter::init(const char *id, const char *placeholder, const c
_customHTML = custom;
}
+WiFiManagerParameter::~WiFiManagerParameter() {
+ if (_value != NULL) {
+ delete[] _value;
+ }
+}
+
const char* WiFiManagerParameter::getValue() {
return _value;
}
@@ -60,14 +66,42 @@ const char* WiFiManagerParameter::getCustomHTML() {
return _customHTML;
}
+
WiFiManager::WiFiManager() {
+ _max_params = WIFI_MANAGER_MAX_PARAMS;
+ _params = (WiFiManagerParameter**)malloc(_max_params * sizeof(WiFiManagerParameter*));
}
-void WiFiManager::addParameter(WiFiManagerParameter *p) {
+WiFiManager::~WiFiManager()
+{
+ if (_params != NULL)
+ {
+ DEBUG_WM(F("freeing allocated params!"));
+ free(_params);
+ }
+}
+
+bool WiFiManager::addParameter(WiFiManagerParameter *p) {
+ if(_paramsCount + 1 > _max_params)
+ {
+ // rezise the params array
+ _max_params += WIFI_MANAGER_MAX_PARAMS;
+ DEBUG_WM(F("Increasing _max_params to:"));
+ DEBUG_WM(_max_params);
+ WiFiManagerParameter** new_params = (WiFiManagerParameter**)realloc(_params, _max_params * sizeof(WiFiManagerParameter*));
+ if (new_params != NULL) {
+ _params = new_params;
+ } else {
+ DEBUG_WM(F("ERROR: failed to realloc params, size not increased!"));
+ return false;
+ }
+ }
+
_params[_paramsCount] = p;
_paramsCount++;
- DEBUG_WM("Adding parameter");
+ DEBUG_WM(F("Adding parameter"));
DEBUG_WM(p->getID());
+ return true;
}
void WiFiManager::setupConfigPortal() {
@@ -109,14 +143,14 @@ void WiFiManager::setupConfigPortal() {
dnsServer->start(DNS_PORT, "*", WiFi.softAPIP());
/* Setup web pages: root, wifi config pages, SO captive portal detectors and not found. */
- server->on("/", std::bind(&WiFiManager::handleRoot, this));
- server->on("/wifi", std::bind(&WiFiManager::handleWifi, this, true));
- server->on("/0wifi", std::bind(&WiFiManager::handleWifi, this, false));
- server->on("/wifisave", std::bind(&WiFiManager::handleWifiSave, this));
- server->on("/i", std::bind(&WiFiManager::handleInfo, this));
- server->on("/r", std::bind(&WiFiManager::handleReset, this));
+ server->on(String(F("/")), std::bind(&WiFiManager::handleRoot, this));
+ server->on(String(F("/wifi")), std::bind(&WiFiManager::handleWifi, this, true));
+ server->on(String(F("/0wifi")), std::bind(&WiFiManager::handleWifi, this, false));
+ server->on(String(F("/wifisave")), std::bind(&WiFiManager::handleWifiSave, this));
+ server->on(String(F("/i")), std::bind(&WiFiManager::handleInfo, this));
+ server->on(String(F("/r")), std::bind(&WiFiManager::handleReset, this));
//server->on("/generate_204", std::bind(&WiFiManager::handle204, this)); //Android/Chrome OS captive portal check.
- server->on("/fwlink", std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
+ server->on(String(F("/fwlink")), std::bind(&WiFiManager::handleRoot, this)); //Microsoft captive portal. Maybe not needed. Might be handled by notFound handler.
server->onNotFound (std::bind(&WiFiManager::handleNotFound, this));
server->begin(); // Web server start
DEBUG_WM(F("HTTP server started"));
@@ -149,10 +183,34 @@ boolean WiFiManager::autoConnect(char const *apName, char const *apPassword) {
return startConfigPortal(apName, apPassword);
}
+boolean WiFiManager::configPortalHasTimeout(){
+ if(_configPortalTimeout == 0 || wifi_softap_get_station_num() > 0){
+ _configPortalStart = millis(); // kludge, bump configportal start time to skew timeouts
+ return false;
+ }
+ return (millis() > _configPortalStart + _configPortalTimeout);
+}
+
+boolean WiFiManager::startConfigPortal() {
+ String ssid = "ESP" + String(ESP.getChipId());
+ return startConfigPortal(ssid.c_str(), NULL);
+}
+
boolean WiFiManager::startConfigPortal(char const *apName, char const *apPassword) {
- //setup AP
- WiFi.mode(WIFI_AP_STA);
- DEBUG_WM("SET AP STA");
+
+ if(!WiFi.isConnected()){
+ WiFi.persistent(false);
+ // disconnect sta, start ap
+ WiFi.disconnect(); // this alone is not enough to stop the autoconnecter
+ WiFi.mode(WIFI_AP);
+ WiFi.persistent(true);
+ }
+ else {
+ //setup AP
+ WiFi.mode(WIFI_AP_STA);
+ DEBUG_WM(F("SET AP STA"));
+ }
+
_apName = apName;
_apPassword = apPassword;
@@ -165,7 +223,11 @@ boolean WiFiManager::startConfigPortal(char const *apName, char const *apPasswo
connect = false;
setupConfigPortal();
- while (_configPortalTimeout == 0 || millis() < _configPortalStart + _configPortalTimeout) {
+ while(1){
+
+ // check if timeout
+ if(configPortalHasTimeout()) break;
+
//DNS
dnsServer->processNextRequest();
//HTTP
@@ -222,7 +284,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
}
//fix for auto connect racing issue
if (WiFi.status() == WL_CONNECTED) {
- DEBUG_WM("Already connected. Bailing out.");
+ DEBUG_WM(F("Already connected. Bailing out."));
return WL_CONNECTED;
}
//check if we have ssid and pass and force those, if not, try with last saved values
@@ -230,7 +292,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
WiFi.begin(ssid.c_str(), pass.c_str());
} else {
if (WiFi.SSID()) {
- DEBUG_WM("Using last saved values, should be faster");
+ DEBUG_WM(F("Using last saved values, should be faster"));
//trying to fix connection in progress hanging
ETS_UART_INTR_DISABLE();
wifi_station_disconnect();
@@ -238,7 +300,7 @@ int WiFiManager::connectWifi(String ssid, String pass) {
WiFi.begin();
} else {
- DEBUG_WM("No saved credentials");
+ DEBUG_WM(F("No saved credentials"));
}
}
@@ -246,11 +308,13 @@ int WiFiManager::connectWifi(String ssid, String pass) {
DEBUG_WM ("Connection result: ");
DEBUG_WM ( connRes );
//not connected, WPS enabled, no pass - first attempt
+ #ifdef NO_EXTRA_4K_HEAP
if (_tryWPS && connRes != WL_CONNECTED && pass == "") {
startWPS();
//should be connected at the end of WPS
connRes = waitForConnectResult();
}
+ #endif
return connRes;
}
@@ -278,9 +342,9 @@ uint8_t WiFiManager::waitForConnectResult() {
}
void WiFiManager::startWPS() {
- DEBUG_WM("START WPS");
+ DEBUG_WM(F("START WPS"));
WiFi.beginWPSConfig();
- DEBUG_WM("END WPS");
+ DEBUG_WM(F("END WPS"));
}
/*
String WiFiManager::getSSID() {
@@ -362,13 +426,14 @@ void WiFiManager::handleRoot() {
page += FPSTR(HTTP_STYLE);
page += _customHeadElement;
page += FPSTR(HTTP_HEAD_END);
- page += "