Code Monkey home page Code Monkey logo

espbootstrap's People

Contributors

arkhipenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

espbootstrap's Issues

A few Compiler warnings with platformio

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;
        ^

Adding "captive portal" functionality to `EspBootstrap::run()`

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.

Using `#include <ParametersSPIFFS.h>` and `#include <EspBootstrapDict.h>` in the same .ino file causes redefinition errors

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.