arkhipenko / espbootstrap Goto Github PK
View Code? Open in Web Editor NEWA simple way to get your ESP8266 or ESP32 project configured and online quickly
License: BSD 3-Clause "New" or "Revised" License
A simple way to get your ESP8266 or ESP32 project configured and online quickly
License: BSD 3-Clause "New" or "Revised" License
See https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html#spiffs-deprecation-warning.
That page claims it should be relatively easy to switch over since they "share a compatible API"...
Example URL:
config: http://192.168.1.175:8081/EBS3_config.json
Serial log:
2020/05/21 13:52:09: [E][WiFiClient.cpp:258] connect(): socket error on fd 54, errno: 113, "Software caused connection abort"
JSONConfig finished. rc = -1
For some reason if I use a port other than 80 in the config_url, the JSONConfig.parse method does not work and the device will keep getting stuck in a Bootstrap required cycle.
A few compiler warnings while compiling the example ParametersEEPROM.ino with platformio.
Maybe the same is with other examples too.
EBS_example02_ParametersEEPROM.ino:36:0: warning: "_PP" redefined [enabled by default]
#define _PP(a)
^
EBS_example02_ParametersEEPROM.ino:33:0: note: this is the location of the previous definition
#define _PP(a) Serial.print(a);
^
EBS_example02_ParametersEEPROM.ino:37:0: warning: "_PL" redefined [enabled by default]
#define _PL(a)
^
EBS_example02_ParametersEEPROM.ino:34:0: note: this is the location of the previous definition
#define _PL(a) Serial.println(a);
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
^
and
In file included from JsonConfigHttp.h:35:0,
from EBS_example02_ParametersEEPROM.ino:44:
JsonConfigBase.h: In member function 'virtual int8_t JsonConfigBase::_doParse(size_t, uint16_t)':
JsonConfigBase.h:73:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < aLen; i++) {
and
EBS_example02_ParametersEEPROM.ino: In function 'void setup()':
EBS_example02_ParametersEEPROM.ino:164:23: warning: 'wifiTimeout' may be used uninitialized in this
function [-Wmaybe-uninitialized]
if (rc != PARAMS_OK || wifiTimeout) {
^
EBS_example02_ParametersEEPROM.ino:89:8: note: 'wifiTimeout' was declared here
bool wifiTimeout;
^
I thought that the functionality that can often be seen on public WiFi networks where you are automatically directed to a login page when connecting to that network would be quite useful for the EspBootstrap use case.
During searching for solutions I found out that this is apparently called a "captive portal" and that it can be implemented by having a DNS server on the Access Point like it is done here: https://github.com/125K/ESP8266-Captive-Portal/blob/master/WiFi_Captive_Portal.ino
I just tried adding the DNS server to EspBootstrapDict::doRun()
like so:
#include <Arduino.h>
#include <DNSServer.h> //============================================= ADDED THIS
#include <EspBootstrapBase.h>
#include <Dictionary.h>
/*[...]*/
int8_t EspBootstrapDict::doRun() {
String ssid(SSID_PREFIX);
const IPAddress APIP (10, 1, 1, 1);
const IPAddress APMASK (255, 255, 255, 0);
WiFi.disconnect();
WiFi.mode(WIFI_AP);
ssid += WiFi.macAddress();
ssid.replace(":", "");
ssid.toLowerCase();
//#if defined( ARDUINO_ARCH_ESP8266 )
// ssid += String(ESP.getChipId(), HEX);
//#endif
#if defined( ARDUINO_ARCH_ESP32 )
// ssid += String((uint32_t)( ESP.getEfuseMac() & 0xFFFFFFFFL ), HEX);
WiFi.softAP( ssid.c_str());
delay(50);
#endif
WiFi.softAPConfig(APIP, APIP, APMASK);
delay(50);
WiFi.softAP( ssid.c_str());
yield();
DNSServer dnsServer; //============================================= ADDED THIS
iServer = new WebServer(80);
if (iServer == NULL) return BOOTSTRAP_ERR;
dnsServer.start(53, "*", APIP); // DNS spoofing (Only for HTTP) //== ADDED THIS
iServer->on("/submit.html", __espbootstrap_handlesubmit);
iServer->onNotFound(__espbootstrap_handleroot);
iAllDone = false;
iServer->begin();
uint32_t timeNow = millis();
while (!iAllDone && !iCancelAP) {
dnsServer.processNextRequest(); //================================ ADDED THIS
iServer->handleClient();
if ( millis() - timeNow > iTimeout ) {
iServer->stop();
iServer->close();
delete iServer;
iServer = NULL;
return BOOTSTRAP_TIMEOUT;
}
delay(10);
// yield();
}
iServer->stop();
iServer->close();
delete iServer;
iServer = NULL;
return (iCancelAP ? BOOTSTRAP_CANCEL: BOOTSTRAP_OK);
}
It worked just fine when connecting with my smartphone! My PC probably didn't do it because it already has a wired connection with another DNS Server answering.
I don't know enough about the structure of the EspBootstrap library but I would be toatally stoked if this feature would find its way into it since I think that it adds a really nice step to streamlining the setup process for devices.
Originally I noticed the compilation to fail and saw the last output of the Arduino build which was the deprecation warning about SPIFFS.
On closer inspection I just noticed that the actual cause of the failure are a lot of redefinition errors like this:
In file included from C:\Users\josts\OneDrive\Documents\Arduino\libraries\EspBootstrap\src/EspBootstrapDict.h:37,
from c:\Users\josts\Downloads\gitClones\HumiTempSensor\HumiTempSensor.ino:8:
C:\Users\josts\OneDrive\Documents\Arduino\libraries\Dictionary\src/Dictionary.h: At global scope:
C:\Users\josts\OneDrive\Documents\Arduino\libraries\Dictionary\src/Dictionary.h:3:8: error: redefinition of 'int8_t node::create(const char*, uint8_t, const char*, uint8_t, node*, node*)'
3 | int8_t node::create(const char* aKey, _DICT_KEY_TYPE aKeySize, const char* aVal, _DICT_VAL_TYPE aValSize, node* aLeft, node* aRight) {
| ^~~~
In file included from C:\Users\josts\OneDrive\Documents\Arduino\libraries\EspBootstrap\src/ParametersSPIFFS.h:35,
from c:\Users\josts\Downloads\gitClones\HumiTempSensor\HumiTempSensor.ino:7:
C:\Users\josts\OneDrive\Documents\Arduino\libraries\Dictionary\src/Dictionary.h:3:8: note: 'int8_t node::create(const char*, uint8_t, const char*, uint8_t, node*, node*)' previously defined here
3 | int8_t node::create(const char* aKey, _DICT_KEY_TYPE aKeySize, const char* aVal, _DICT_VAL_TYPE aValSize, node* aLeft, node* aRight) {
| ^~~~
In file included from C:\Users\josts\OneDrive\Documents\Arduino\libraries\EspBootstrap\src/EspBootstrapDict.h:37,
from c:\Users\josts\Downloads\gitClones\HumiTempSensor\HumiTempSensor.ino:8:
C:\Users\josts\OneDrive\Documents\Arduino\libraries\Dictionary\src/Dictionary.h:58:8: error: redefinition of 'int8_t node::updateValue(const char*, uint8_t)'
58 | int8_t node::updateValue(const char* aVal, _DICT_VAL_TYPE aValSize) {
| ^~~~
In file included from C:\Users\josts\OneDrive\Documents\Arduino\libraries\EspBootstrap\src/ParametersSPIFFS.h:35,
from c:\Users\josts\Downloads\gitClones\HumiTempSensor\HumiTempSensor.ino:7:
C:\Users\josts\OneDrive\Documents\Arduino\libraries\Dictionary\src/Dictionary.h:58:8: note: 'int8_t node::updateValue(const char*, uint8_t)' previously defined here
58 | int8_t node::updateValue(const char* aVal, _DICT_VAL_TYPE aValSize) {
| ^~~~
[...]
I have the feeling that the Dictionary
library has changed since I last successfully built my project (jostsalathe/HumiTempSensor). It appears to me that it has no header guard surrounding its contents which would make it unsuitable for including it in multiple other header files...
Now I don't really know what to do with that information, though...
Would you mind checking if you can reproduce this? Just to be sure that my setup isn't just broken, somehow...
Originally posted by @jostsalathe in #3 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.