[GH-ISSUE #1035] wifiManager.server->hasArg creates exception #882

Open
opened 2026-02-28 01:27:28 +03:00 by kerem · 0 comments
Owner

Originally created by @jbronikowski on GitHub (Apr 9, 2020).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1035

Basic Infos

Hardware

WiFimanager Branch/Release:

  • Master
  • [ x] Development

Esp8266/Esp32:

  • [ x] ESP8266
  • ESP32

Hardware: ESP-12e, esp01, esp25

  • ESP01
  • [ x] ESP12 E/F/S (nodemcu, wemos, feather)
  • Other

ESP Core Version: 2.4.0, staging

  • 2.3.0
  • [ x] 2.4.0
  • staging (master/dev)

Description

Anytime i try to access the saved params i get the following exception. It looks to be saving them correctly but server->hasArg is throwing exceptions.

Settings in IDE

Module: NodeMcu, Wemos D1

Additional libraries:

Sketch


//#include <ESP8266WebServer.h>
#include <WiFiManager.h>          //https://github.com/tzapu/WiFiManager

#include <ESP8266HTTPClient.h>
#include <WiFiClientSecureBearSSL.h>

// Fingerprint for demo URL, expires on June 2, 2021, needs to be updated well before this date
const char fingerprint[] PROGMEM = "4C BA 93 17 2D F3 CA FA 67 1A 10 09 61 7A D9 68 45 93 1A BF";


const int RED_PIN = 0;
const int GREEN_PIN = 2;
const int BLUE_PIN = 5;

char* apikey;
char* email;

//flag for saving data
bool shouldSaveConfig = false;

//callback notifying us of the need to save config
void saveConfigCallback () {
  Serial.println("Should save config");
  shouldSaveConfig = true;
}

void saveParamCallback(){
  Serial.println("[CALLBACK] saveParamCallback fired");
  // wm.stopConfigPortal();
}


WiFiManager wifiManager;
WiFiManagerParameter custom_api_key("api_key", "api key", "", 255);
WiFiManagerParameter custom_email("email", "email", "", 255);

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println();

  pinMode(RED_PIN, OUTPUT);
  pinMode(GREEN_PIN, OUTPUT);
  pinMode(BLUE_PIN, OUTPUT);

  digitalWrite(RED_PIN, HIGH);
  digitalWrite(GREEN_PIN, HIGH);
  digitalWrite(BLUE_PIN, HIGH);


  // The extra parameters to be configured (can be either global or just in the setup)
  // After connecting, parameter.getValue() will get you the configured value
  // id/name placeholder/prompt default length
  //WiFiManager
  //Local intialization. Once its business is done, there is no need to keep it around
  

  //set config save notify callback
  wifiManager.setSaveConfigCallback(saveConfigCallback);
  

  //exit after config instead of connecting
  wifiManager.setBreakAfterConfig(true);


  //reset settings - for testing
  wifiManager.resetSettings();
  
  wifiManager.addParameter(&custom_api_key);
  wifiManager.addParameter(&custom_email);
  
  wifiManager.setSaveParamsCallback(saveParamCallback);
  
  //tries to connect to last known settings
  //if it does not connect it starts an access point with the specified name
  //here  "AutoConnectAP" with password "password"
  //and goes into a blocking loop awaiting configuration
  if (!wifiManager.autoConnect("AutoConnectAP", "password")) {
    Serial.println("failed to connect, we should reset as see if it connects");
    delay(3000);
    ESP.reset();
    delay(5000);
  }

  //if you get here you have connected to the WiFi
  Serial.println("connected...yeey :)");
  //read updated parameters

  Serial.println("local ip");
  Serial.println(WiFi.localIP());

  Serial.println("Setting Webex Variables");
  Serial.println("local ip");
  Serial.println(WiFi.localIP());
  Serial.println(WiFi.gatewayIP());
  Serial.println(WiFi.subnetMask());
  WiFi.begin();
}

String getParam(String name){
  //read parameter from server, for customhmtl input
  String value;
  if(wifiManager.server->hasArg(name)) {
    value = wifiManager.server->arg(name);
  }
  return value;
}

void loop() {
  // wait for WiFi connection
  if ((WiFi.localIP())) {

    Serial.println("===============");
    Serial.println(apikey);
    Serial.println(email);

    std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure);

    client->setFingerprint(fingerprint);

    HTTPClient https;


    
    Serial.print("[HTTPS] begin...\n");
    if (https.begin(*client, "https://api.ciscospark.com/v1/people?email=" + getParam("email"))) {  // HTTPS
      https.addHeader("Content-Type", "application/json");
      https.addHeader("Authorization", "Bearer " + getParam("api_key")); 

      Serial.print("[HTTPS] GET...\n");
      // start connection and send HTTP header
      int httpCode = https.GET();

      // httpCode will be negative on error
      if (httpCode > 0) {
        // HTTP header has been send and Server response header has been handled
        Serial.printf("[HTTPS] GET... code: %d\n", httpCode);

        // file found at server
        if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) {
          String payload = https.getString();
          Serial.println(payload);
          String im_status = "";
          if(payload.indexOf("\"status\":\"meeting\"") > 0) {
            im_status = "Meeting";
            digitalWrite(RED_PIN, LOW);
            digitalWrite(GREEN_PIN, HIGH);
            digitalWrite(BLUE_PIN, HIGH);
          }
          if(payload.indexOf("\"status\":\"presenting\"") > 0) {
            im_status = "Presenting";
            digitalWrite(RED_PIN, HIGH);
            digitalWrite(GREEN_PIN, HIGH);
            digitalWrite(BLUE_PIN, LOW);
          }
          if(payload.indexOf("\"status\":\"active\"") > 0) {
            im_status = "Active";
            digitalWrite(RED_PIN, HIGH);
            digitalWrite(GREEN_PIN, LOW);
            digitalWrite(BLUE_PIN, HIGH);
          }
          if(payload.indexOf("\"status\":\"inactive\"") > 0) {
            im_status = "Inactive";
            digitalWrite(RED_PIN, HIGH);
            digitalWrite(GREEN_PIN, HIGH);
            digitalWrite(BLUE_PIN, HIGH);
          }

          Serial.println(im_status);
          
        }
      } else {
        Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str());
      }

      https.end();
    } else {
      Serial.printf("[HTTPS] Unable to connect\n");
    }
  }

  Serial.println("Wait 2s before next round...");
  delay(2000);
  //
}


Debug Messages

14:54:12.525 -> Exception (28):
14:54:12.525 -> epc1=0x40201269 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000090 depc=0x00000000
14:54:12.525 -> 
14:54:12.525 -> >>>stack>>>
14:54:12.525 -> 
14:54:12.525 -> ctx: cont
14:54:12.525 -> sp: 3ffffd00 end: 3fffffc0 offset: 01a0
14:54:12.525 -> 3ffffea0:  4021047c 00000005 3fffff70 4021110c  
14:54:12.525 -> 3ffffeb0:  3fff0cfc 3fffff70 3ffe87a3 3ffef3a0  
14:54:12.525 -> 3ffffec0:  3fff0cfc 3ffef260 3fffff58 402013f9  
14:54:12.525 -> 3ffffed0:  00000000 00000000 00000000 00000000  
14:54:12.563 -> 3ffffee0:  40240550 80240524 3f010000 00001388  
14:54:12.563 -> 3ffffef0:  40240400 3ffedafc 80000012 40100100  
14:54:12.563 -> 3fffff00:  40240aa0 80fedafc 00000000 40242bc4  
14:54:12.563 -> 3fffff10:  802404cd 3fff240c 0011001f 00000000  
14:54:12.563 -> 3fffff20:  40242900 0000010f 80fef1fc 00000000  
14:54:12.563 -> 3fffff30:  00000000 00000000 ffffffff 00000000  
14:54:12.563 -> 3fffff40:  4025000a 3ffef100 3ffef1fc 80000003  
14:54:12.563 -> 3fffff50:  00000000 00000000 3fff21e4 002b002f  
14:54:12.601 -> 3fffff60:  007a1200 eeedf200 3ffef100 8020ac80  
14:54:12.601 -> 3fffff70:  69616d65 3ffe006c 85fef260 4020121a  
14:54:12.601 -> 3fffff80:  00000000 00000000 00000001 40100198  
14:54:12.601 -> 3fffff90:  3fffdad0 00000000 3ffef360 3ffef3a0  
14:54:12.601 -> 3fffffa0:  3fffdad0 00000000 3ffef360 402123d0  
14:54:12.601 -> 3fffffb0:  feefeffe feefeffe 3ffe84ec 40100c85  
14:54:12.601 -> <<<stack<<<
14:54:12.638 -> 
14:54:12.638 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,6)
14:54:12.638 -> 
14:54:12.638 -> load 0x4010f000, len 1392, room 16 
14:54:12.638 -> tail 0
14:54:12.638 -> chksum 0xd0
14:54:12.638 -> csum 0xd0
14:54:12.638 -> v3d128e5c
14:54:12.638 -> ~ld


Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x40201269: getParam(String) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h line 582
EXCVADDR: 0x00000090

Decoding stack results
0x4021047c: HardwareSerial::write(unsigned char const*, unsigned int) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/HardwareSerial.h line 164
0x4021110c: String::copy(char const*, unsigned int) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/WString.cpp line 214
0x402013f9: loop() at /Users/jbroniko/Documents/Arduino/webexv2/webexv2.ino line 133
0x40100100: std::function ::operator()() const at /Users/jbroniko/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/xtensa-lx106-elf/include/c++/4.8.2/functional line 2465
0x4025000a: dhcps_start_LWIP2 at glue-lwip/esp-dhcpserver.c line 805
0x4020121a: setup() at /Users/jbroniko/Documents/Arduino/webexv2/webexv2.ino line 105
0x40100198: ets_post(uint8, ETSSignal, ETSParam) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 160
0x402123d0: loop_wrapper() at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 180

Originally created by @jbronikowski on GitHub (Apr 9, 2020). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1035 ### Basic Infos #### Hardware **WiFimanager Branch/Release:** - [ ] Master - [ x] Development **Esp8266/Esp32:** - [ x] ESP8266 - [ ] ESP32 **Hardware: ESP-12e, esp01, esp25** - [ ] ESP01 - [ x] ESP12 E/F/S (nodemcu, wemos, feather) - [ ] Other **ESP Core Version: 2.4.0, staging** - [ ] 2.3.0 - [ x] 2.4.0 - [ ] staging (master/dev) ### Description Anytime i try to access the saved params i get the following exception. It looks to be saving them correctly but server->hasArg is throwing exceptions. ### Settings in IDE Module: NodeMcu, Wemos D1 Additional libraries: ### Sketch ```cpp //#include <ESP8266WebServer.h> #include <WiFiManager.h> //https://github.com/tzapu/WiFiManager #include <ESP8266HTTPClient.h> #include <WiFiClientSecureBearSSL.h> // Fingerprint for demo URL, expires on June 2, 2021, needs to be updated well before this date const char fingerprint[] PROGMEM = "4C BA 93 17 2D F3 CA FA 67 1A 10 09 61 7A D9 68 45 93 1A BF"; const int RED_PIN = 0; const int GREEN_PIN = 2; const int BLUE_PIN = 5; char* apikey; char* email; //flag for saving data bool shouldSaveConfig = false; //callback notifying us of the need to save config void saveConfigCallback () { Serial.println("Should save config"); shouldSaveConfig = true; } void saveParamCallback(){ Serial.println("[CALLBACK] saveParamCallback fired"); // wm.stopConfigPortal(); } WiFiManager wifiManager; WiFiManagerParameter custom_api_key("api_key", "api key", "", 255); WiFiManagerParameter custom_email("email", "email", "", 255); void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.println(); pinMode(RED_PIN, OUTPUT); pinMode(GREEN_PIN, OUTPUT); pinMode(BLUE_PIN, OUTPUT); digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH); // The extra parameters to be configured (can be either global or just in the setup) // After connecting, parameter.getValue() will get you the configured value // id/name placeholder/prompt default length //WiFiManager //Local intialization. Once its business is done, there is no need to keep it around //set config save notify callback wifiManager.setSaveConfigCallback(saveConfigCallback); //exit after config instead of connecting wifiManager.setBreakAfterConfig(true); //reset settings - for testing wifiManager.resetSettings(); wifiManager.addParameter(&custom_api_key); wifiManager.addParameter(&custom_email); wifiManager.setSaveParamsCallback(saveParamCallback); //tries to connect to last known settings //if it does not connect it starts an access point with the specified name //here "AutoConnectAP" with password "password" //and goes into a blocking loop awaiting configuration if (!wifiManager.autoConnect("AutoConnectAP", "password")) { Serial.println("failed to connect, we should reset as see if it connects"); delay(3000); ESP.reset(); delay(5000); } //if you get here you have connected to the WiFi Serial.println("connected...yeey :)"); //read updated parameters Serial.println("local ip"); Serial.println(WiFi.localIP()); Serial.println("Setting Webex Variables"); Serial.println("local ip"); Serial.println(WiFi.localIP()); Serial.println(WiFi.gatewayIP()); Serial.println(WiFi.subnetMask()); WiFi.begin(); } String getParam(String name){ //read parameter from server, for customhmtl input String value; if(wifiManager.server->hasArg(name)) { value = wifiManager.server->arg(name); } return value; } void loop() { // wait for WiFi connection if ((WiFi.localIP())) { Serial.println("==============="); Serial.println(apikey); Serial.println(email); std::unique_ptr<BearSSL::WiFiClientSecure>client(new BearSSL::WiFiClientSecure); client->setFingerprint(fingerprint); HTTPClient https; Serial.print("[HTTPS] begin...\n"); if (https.begin(*client, "https://api.ciscospark.com/v1/people?email=" + getParam("email"))) { // HTTPS https.addHeader("Content-Type", "application/json"); https.addHeader("Authorization", "Bearer " + getParam("api_key")); Serial.print("[HTTPS] GET...\n"); // start connection and send HTTP header int httpCode = https.GET(); // httpCode will be negative on error if (httpCode > 0) { // HTTP header has been send and Server response header has been handled Serial.printf("[HTTPS] GET... code: %d\n", httpCode); // file found at server if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY) { String payload = https.getString(); Serial.println(payload); String im_status = ""; if(payload.indexOf("\"status\":\"meeting\"") > 0) { im_status = "Meeting"; digitalWrite(RED_PIN, LOW); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH); } if(payload.indexOf("\"status\":\"presenting\"") > 0) { im_status = "Presenting"; digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, LOW); } if(payload.indexOf("\"status\":\"active\"") > 0) { im_status = "Active"; digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, LOW); digitalWrite(BLUE_PIN, HIGH); } if(payload.indexOf("\"status\":\"inactive\"") > 0) { im_status = "Inactive"; digitalWrite(RED_PIN, HIGH); digitalWrite(GREEN_PIN, HIGH); digitalWrite(BLUE_PIN, HIGH); } Serial.println(im_status); } } else { Serial.printf("[HTTPS] GET... failed, error: %s\n", https.errorToString(httpCode).c_str()); } https.end(); } else { Serial.printf("[HTTPS] Unable to connect\n"); } } Serial.println("Wait 2s before next round..."); delay(2000); // } ``` ### Debug Messages ``` 14:54:12.525 -> Exception (28): 14:54:12.525 -> epc1=0x40201269 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000090 depc=0x00000000 14:54:12.525 -> 14:54:12.525 -> >>>stack>>> 14:54:12.525 -> 14:54:12.525 -> ctx: cont 14:54:12.525 -> sp: 3ffffd00 end: 3fffffc0 offset: 01a0 14:54:12.525 -> 3ffffea0: 4021047c 00000005 3fffff70 4021110c 14:54:12.525 -> 3ffffeb0: 3fff0cfc 3fffff70 3ffe87a3 3ffef3a0 14:54:12.525 -> 3ffffec0: 3fff0cfc 3ffef260 3fffff58 402013f9 14:54:12.525 -> 3ffffed0: 00000000 00000000 00000000 00000000 14:54:12.563 -> 3ffffee0: 40240550 80240524 3f010000 00001388 14:54:12.563 -> 3ffffef0: 40240400 3ffedafc 80000012 40100100 14:54:12.563 -> 3fffff00: 40240aa0 80fedafc 00000000 40242bc4 14:54:12.563 -> 3fffff10: 802404cd 3fff240c 0011001f 00000000 14:54:12.563 -> 3fffff20: 40242900 0000010f 80fef1fc 00000000 14:54:12.563 -> 3fffff30: 00000000 00000000 ffffffff 00000000 14:54:12.563 -> 3fffff40: 4025000a 3ffef100 3ffef1fc 80000003 14:54:12.563 -> 3fffff50: 00000000 00000000 3fff21e4 002b002f 14:54:12.601 -> 3fffff60: 007a1200 eeedf200 3ffef100 8020ac80 14:54:12.601 -> 3fffff70: 69616d65 3ffe006c 85fef260 4020121a 14:54:12.601 -> 3fffff80: 00000000 00000000 00000001 40100198 14:54:12.601 -> 3fffff90: 3fffdad0 00000000 3ffef360 3ffef3a0 14:54:12.601 -> 3fffffa0: 3fffdad0 00000000 3ffef360 402123d0 14:54:12.601 -> 3fffffb0: feefeffe feefeffe 3ffe84ec 40100c85 14:54:12.601 -> <<<stack<<< 14:54:12.638 -> 14:54:12.638 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6) 14:54:12.638 -> 14:54:12.638 -> load 0x4010f000, len 1392, room 16 14:54:12.638 -> tail 0 14:54:12.638 -> chksum 0xd0 14:54:12.638 -> csum 0xd0 14:54:12.638 -> v3d128e5c 14:54:12.638 -> ~ld Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads PC: 0x40201269: getParam(String) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h line 582 EXCVADDR: 0x00000090 Decoding stack results 0x4021047c: HardwareSerial::write(unsigned char const*, unsigned int) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/HardwareSerial.h line 164 0x4021110c: String::copy(char const*, unsigned int) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/WString.cpp line 214 0x402013f9: loop() at /Users/jbroniko/Documents/Arduino/webexv2/webexv2.ino line 133 0x40100100: std::function ::operator()() const at /Users/jbroniko/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-4-b40a506/xtensa-lx106-elf/include/c++/4.8.2/functional line 2465 0x4025000a: dhcps_start_LWIP2 at glue-lwip/esp-dhcpserver.c line 805 0x4020121a: setup() at /Users/jbroniko/Documents/Arduino/webexv2/webexv2.ino line 105 0x40100198: ets_post(uint8, ETSSignal, ETSParam) at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 160 0x402123d0: loop_wrapper() at /Users/jbroniko/Library/Arduino15/packages/esp8266/hardware/esp8266/2.6.3/cores/esp8266/core_esp8266_main.cpp line 180 ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#882
No description provided.