Problem with WebConfig

49 views
Skip to first unread message

AMT

unread,
Aug 22, 2020, 12:30:04 PM8/22/20
to souliss
Hi,

I expose a problem that happens with my nodes,

I've configured the nodes with webconfig:

      if (!ReadIPConfiguration())  {
           // Start the node as access point with a configuration WebServer
           ...

The first boot is ok with AP mode and , I've configured the wifi & IP,

when reboot (after webconfig or other reboot) the ESP12F boots in mode: STA + AP,

with one more problem, that someone can connect to the AP, and see my wifi SSID and password.

Why does ESP boot in dual mode (STA + AP) after configure with WebConfig?

It should boot in AP mode once wifi & Passw is configured.

I tried erase EEPROM (512), restore ESP with Esspressif Flash Download Tool and nothing.

Thanks.
Message has been deleted
Message has been deleted

AMT

unread,
Aug 24, 2020, 5:42:36 AM8/24/20
to souliss
Excuse-me:

I said (Error): It should boot in AP mode once wifi & Passw is configured.

It should boot in STA  mode once wifi & Passw is configured with WebConfig.

Thanks 

AMT

unread,
Aug 24, 2020, 5:44:51 AM8/24/20
to souliss
The Code:

// Configure the framework
#include "bconf/MCU_ESP8266.h"              // Load the code directly on the ESP8266
#include "conf/RuntimeGateway.h"                   // The main node is the Gateway, we have just one node
#include "conf/DynamicAddressing.h"         // Use dynamically assigned addresses
#include "conf/WEBCONFinterface.h"          // Enable the WebConfig interface
#include "conf/IPBroadcast.h"               // Enable communication M3 use addresses 0xABnn 

#include <ESP8266WiFi.h>
#include <EEPROM.h>
#include <WiFiUdp.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPUpdateServer.h>

const char* update_path = "/firmware";
const char* update_username = "myusermyuser";
const char* update_password = "mypsswmypssw";

/*** All configuration includes should be above this line ***/ 
#include "Souliss.h"

// This identify the Slots of Node
#define CURTAIN_NODE           0

ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater;

unsigned long initmillis = millis();


void setup()  {
  
    Initialize();
   
    Serial.begin(115200);   
    delay(100);
    Serial.println("(.)");
    Serial.println("void setup()");


    // Define inputs (hardware pullup required) and outputs pins
    pinMode(13, INPUT);      // Open Command from pushbutton (13 = GPIO13)
    pinMode(14, INPUT);      // Close Command from pushbutton (14 = GPIO14)
    digitalWrite(4, HIGH);   // When Out with HIGH Relay
    digitalWrite(5, HIGH);   // When Out with HIGH Relay
    pinMode(4, OUTPUT);      // Open Relay (4 = GPIO4)
    pinMode(5, OUTPUT);      // Close Relay (5 = GPIO5)


    if(!digitalRead(14))  {        //Close pushbutton (GPIO14) for EEPROM Reset
      EEPROM.begin(512);
      delay(50);  
      while(!digitalRead(14))  {
        if((millis( ) - initmillis) < 5000)   {
          Serial.print("EEPROM Reset Setup en: ");
          Serial.println((5000-(millis()-initmillis))/1000);
          delay(50);
        } else {
          for(int i = 0; i <= 512; i++)  {
            Serial.println(i);
            EEPROM.write(i,0);
          }
          EEPROM.commit();
        }  
      }
    }
   
    // Read the IP configuration from the EEPROM, if not available start the node as access point
    if(!ReadIPConfiguration()) { 
      // Start the node as access point with a configuration WebServer
      SetAccessPoint();
      startWebServer();

      // We have nothing more than the WebServer for the configuration to run, once configured the node will quit this.
      while(1)  {
        yield();
        runWebServer();
        Serial.print("runWebServer()  AP Souliss WebConfig  ");
        Serial.println((15000-(millis()-initmillis))/1000);
             
        if((millis() - initmillis) >= 15000)  {  //segundos para reset
          ESP.reset();
        }      
      }
    }

    if (IsRuntimeGateway())  {
        // Connect to the WiFi network and get an address from WebConfig + vNet DHCP                      
        SetAsGateway(myvNet_dhcp);       // Set this node as gateway for SoulissApp  
        SetAddressingServer();
    }  else  {
        // This board request an address to the gateway at runtime, no need to configure any parameter here.
        SetDynamicAddressing();  
        GetAddress();
    }

    httpUpdater.setup(&httpServer, update_path, update_username, update_password);
    httpServer.begin();

    // The logic that handles windows and curtains is T22
    Set_T22(CURTAIN_NODE);
}


void loop()  {

    Serial.print(".........  void loop() .........  ");
    Serial.print((millis()-initmillis)/1000);
    Serial.println(" seg.");
    
    httpServer.handleClient();
    
    EXECUTEFAST() {                     
        UPDATEFAST();   

        // Process every 110ms the logic that control the curtain
        FAST_110ms(){
            // Use OPEN and CLOSE Commands Push-buttons local
            LowDigIn(13, Souliss_T2n_OpenCmd_Local, CURTAIN_NODE);  //pullup
            LowDigIn(14, Souliss_T2n_CloseCmd_Local, CURTAIN_NODE); //pullup

            // Run the logic
            Logic_T22(CURTAIN_NODE);
            
            // Control the output relays, the stop is with both the relays not active.
            // If you need to active the relays on stop, use nDigOut instead.
            LowDigOut(4, Souliss_T2n_Coil_Open, CURTAIN_NODE);     //Out High Relay   
            LowDigOut(5, Souliss_T2n_Coil_Close, CURTAIN_NODE);    //Out High Relay         
        }

        
        // Here we handle here the communication with Android, commands and notification
        // Run communication as Gateway or Peer
        if (IsRuntimeGateway())
            FAST_GatewayComms(); 
        else 
            FAST_PeerComms();


        // Define the hold time of the outputs, by default the timer hold the relays for 16 times, so:
        // Change the parameter inside FAST_x10ms() to change this time.
        FAST_x10ms(200){                 
            Timer_T22(CURTAIN_NODE);
        }
    }

    EXECUTESLOW(){
        UPDATESLOW();
        
        Serial.println(".........  SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW .........  ");
        Serial.println(".........  SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW .........  ");
        Serial.println(".........  SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW SLOW .........  ");

        
        // If running as Peer
        if (!IsRuntimeGateway())
            SLOW_PeerJoin();


        SLOW_10s() {
          initmillis=millis();
          if(!digitalRead(13))  {     //Open pushbutton (GPIO13) for ESP Reset
            while(!digitalRead(13))  {
              if((millis( ) - initmillis) < 2000)   {
                delay(50);
                Serial.print("ESP.reset() SLOW en: ");
                Serial.println((2000-(millis()-initmillis))/1000);
              }  else {
                ESP.reset();
                }
            }  
          }
          // If press button is LOW erase EEPROM              
          if(!digitalRead(14))  {        //Close pushbutton (GPIO14) for EEPROM Reset
            EEPROM.begin(512);
            delay(50);            
            while(!digitalRead(14))  {
              if((millis( ) - initmillis) < 5000)   {
                delay(50);
                Serial.print("EEPROM Reset SLOW en: ");
                Serial.println((5000-(millis()-initmillis))/1000);
              }  else {
                for(int i = 0; i <= 512; i++)  {
                  EEPROM.write(i,0);
                }
                EEPROM.commit();
              }  
            }
          }
        } 
    }
}

AMT

unread,
Aug 24, 2020, 5:46:52 AM8/24/20
to souliss
Is It possible configure the AP with access password?

like:   SetAccessPoint( default_Souliss_Name_AP  ,  APpsswAPpssw );

Thanks.
Reply all
Reply to author
Forward
0 new messages