zhouhan0126 / WIFIMANAGER-ESP32

wifimanager-esp32
MIT License
401 stars 135 forks source link

Can't get custom parameters to work #5

Closed JasXSL closed 6 years ago

JasXSL commented 6 years ago

Code:

void initWifi( bool force ){

    WiFiManager wifiManager;

        wifiManager.setAPCallback(configModeCallback);
    wifiManager.setSaveConfigCallback(configModeSaveCallback);

    WiFiManagerParameter par("Device ID", "Your device ID", "", 64);
    wifiManager.addParameter(&par);

    String ssid = getssid();
    if( force ){
        if( !wifiManager.startConfigPortal(ssid.c_str()) ){
            Serial.println("failed to connect and hit timeout");
            //reset and try again, or maybe put it to deep sleep
            ESP.restart();
            delay(1000);
        }
    }
        else if( !wifiManager.autoConnect(ssid.c_str()) ){
        Serial.println("failed to connect and hit timeout");
        //reset and try again, or maybe put it to deep sleep
        ESP.restart();
        delay(1000);
        }

    Serial.println("New device ID: ");
    Serial.println(par.getValue());

}

Problem I'm facing is that par.getValue always prints a blank line, regardless of what I put in the box. Wifi settings are updated properly and it connects. Am I doing something wrong here?

JasXSL commented 6 years ago

Just realized I posted on the wrong repo, closing as invalid I guess