Post topics, source code that relate to the Arduino Platform

User avatar
By lolceh
#71898 Hello :)
I have problem with exception when changing Wifi.mode to station. First when ESP is turned on it setup itself as AP (setupWifi is first called in setup() ). Than i change settings on web configuration and save them on ESP, setupWifi is called again with accesspoint = false. Esp is than reset with Exception(28). Did a little of debug and it stops when WiFi.mode(STA) is called.

Code:
Code: Select all
void setupWifi(){
  //disconnect
  WiFi.disconnect();
  delay(1000);

  if(accesspoint){
      LOG.println("Nastavljam AP nacin");
      WiFi.softAPConfig(apIP,apIP,apMask);
      WiFi.softAP(ap_name,ap_pass);
      IPAddress myIP = WiFi.softAPIP();
      LOG.println("Ip naslov multisenzorja je ");
      LOG.print(myIP);
      LOG.println();
      delay(100);
    }else{
      WiFi.mode(WIFI_STA);
      if(config.dhcp){
        LOG.println("Povezujem z uporabo dhcp");
      }else{
        LOG.println("Povezujem z uporabo staticnega naslova");
        WiFi.config(config.ip,config.gateway,config.netmask);
      }
     
      //WiFi.begin(config.ssid.c_str(),config.pass.c_str());
      LOG.println("Status po station mode");
      LOG.println(WiFi.status());
     
      while ((WiFi.status() != WL_CONNECTED)) {
        delay(500);
        LOG.print(".");
        }

      if (WiFi.status() == WL_CONNECTED) {
        LOG.println("");
        LOG.print("Connected with IP: ");
        LOG.println(WiFi.localIP());
        }
    }
}



Code: Select allException (28):
epc1=0x4020881f epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000090 depc=0x00000000

ctx: sys
sp: 3ffffbc0 end: 3fffffb0 offset: 01a0

>>>stack>>>
3ffffd60:  00000000 3fff37fc 3fff37fc 4020ffb4 
3ffffd70:  3ffe8928 0000000e 00000000 4020a3b2 
3ffffd80:  3ffedb30 3fff37fc 3fff277c 4020a416 
3ffffd90:  3ffe8928 0000000e 00000002 40101b7a 
3ffffda0:  40104e3c 3fff37fc 3fff37fc 4020a444 
3ffffdb0:  3ffe8928 000001fa 000001fa 4010020c 
3ffffdc0:  3fff3824 3fff25c4 00000001 4020844c 
3ffffdd0:  00000001 00000000 00000002 3fff30c4 
3ffffde0:  3fff3810 3fff37fc 00000001 40211026 
3ffffdf0:  3fff3824 3fff25c4 3fff37fc 40211269 
3ffffe00:  00000000 40104e57 3ffedce8 4020ffdc 
3ffffe10:  00000000 00000000 3fff37fc 4020a8c3 
3ffffe20:  3fff258c 3ffefaf8 3fff37fc 4020a8ef 
3ffffe30:  3fff26f4 3fff30c8 3fff258c 4020aa7f 
3ffffe40:  3fff26e4 3fff3620 402097b8 402111f4 
3ffffe50:  00000000 00000000 3fff317c 4020aab8 
3ffffe60:  00000000 00000000 3fff30c4 4020aad0 
3ffffe70:  00000000 0000001f 3fff317c 40208962 
3ffffe80:  00000000 00000000 0000001f 402089c9 
3ffffe90:  00000000 00000001 3fff317c 40208a40 
3ffffea0:  4000050c 00000000 00000000 40209d14 
3ffffeb0:  40000f83 00000030 0000001b 40209d28 
3ffffec0:  40000f3d 00000023 00000000 40208c59 
3ffffed0:  3fff317c 00000000 00000000 fffffffe 
3ffffee0:  ffffffff 3fffc6fc 3fff159c 40208ca4 
3ffffef0:  00000000 3fffdad0 3ffefd7c 402319e4 
3fffff00:  00000000 00000000 00000064 401004d8 
3fffff10:  3ffefc9c 00000225 00000225 00000000 
3fffff20:  3fff12ac 3fff12a8 00f55725 40231bd8 
3fffff30:  3fff12ac 3fff12a8 00f4fb99 40233028 
3fffff40:  4010551e 00f55722 60000600 402331c9 
3fffff50:  40233020 00000000 00f55722 00000000 
3fffff60:  40228cdc 3ffef458 3ffef480 60000600 
3fffff70:  04b0ea78 3ffef480 3ffef458 40228ce9 
3fffff80:  40228d2e 3fffdab0 00000000 3fffdcb0 
3fffff90:  3ffef4a0 3fffdad0 3ffefd7c 4021005f 
3fffffa0:  40000f49 40000f49 3fffdab0 40000f49 
<<<stack<<<

 ets Jan  8 2013,rst cause:1, boot mode:(1,7)


 ets Jan  8 2013,rst cause:4, boot mode:(1,7)


Code has Asyncserver running and when i trigger event from asyncserver it runs setupwifi again. Maybe setupWifi get's called multiple times? Because i tried create another script with async server and make it to change to station mode onclientdisconnect, and i get same problem.

Code: Select all
void onEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, AwsEventType type, void * arg, uint8_t *data, size_t len){
  switch(type){
        case WS_EVT_CONNECT:
            Serial.print("Nov klient povezan ");
            Serial.println(client->id());
            break;
        case WS_EVT_DISCONNECT:
                accesspoint=false;
                setupWifi();
            break;
        case WS_EVT_ERROR:
            Serial.println("Napaka websocketa");
            break;
  }

}




Thanks for help! :)