CurtRod / SimpleEVSE-WiFi

Brings EVSE WB/DIN into your WiFi
https://www.evse-wifi.de
78 stars 31 forks source link

switch to STA mode is failing only emergency AP Mode get's activate. #18

Closed Leftaf closed 5 years ago

Leftaf commented 5 years ago

It looks like that there is an issue to switch from AP mode to STA after once AP has been Setup successful.

Trying to go into STA mode always the WEMOS start in fallbacktoAPMode(); 13-08-2018 13-20-01 as this function is only called in the Setup(); sequence there must be an issue with loading the config.json 13-08-2018 13-21-19

Does any body else have this behavior?

in depend of this behavior the [debug] activation is unfortunately after the relevant error messages :-( so the code should be move upwards and the first messages should be always shown.

bool ICACHE_FLASH_ATTR loadConfiguration() {
  File configFile = SPIFFS.open("/config.json", "r");
  if (!configFile) {
    Serial.println(F("[ WARN ] Failed to open config file"));
    return false;
  }
  size_t size = configFile.size();
  std::unique_ptr<char[]> buf(new char[size]);
  configFile.readBytes(buf.get(), size);
  DynamicJsonBuffer jsonBuffer14;
  JsonObject& json = jsonBuffer14.parseObject(buf.get());

  if (!json.success()) {
    Serial.println(F("[ WARN ] Failed to parse config file"));
    return false;
  }
  if (json.containsKey("debug")){
    debug = json["debug"];
  }
  if(debug){
    Serial.println("Debug Mode: ON!");
    Serial.println(F("[ INFO ] Config file found"));
    json.prettyPrintTo(Serial);
    Serial.println();
  }
  else{
    Serial.println("Debug Mode: OFF!");
  }
CurtRod commented 5 years ago

Thank you for reporting this issue. I will have a look at this in the next days!

Leftaf commented 5 years ago

I could figure out that I had an issue with the SPIFFS that's why it always start in [fallbacktoAPMode] so it's not a bug it's a hardware issue with the ESP6288. But anyhow the mentioned changes could help to find the error for users how don't have the SDK access possibility

CurtRod commented 5 years ago

okay. I changed the lines a bit diffent, but now there would be an error message on Serial, when no config file is found. Thank you for your help.