Skip to content

WiFi stuck in unknown state during OTA update if connection lost then #5626

Closed
@ankitghevariya

Description

@ankitghevariya

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP-12E]
  • Core Version: [2.4.2]
  • Development Env: [Arduino IDE]
  • Operating System: [Windows]

Settings in IDE

  • Module: [NodeMCU 1.0(ESP-1E Module)]
  • Flash Size: [4MB]
  • Debug port: [Serial]
  • Debug Level: [OTA]
  • lwip Variant: [v2 Higher Bandwidth]
  • CPU Frequency: [80Mhz]
  • Upload Using: [OTA]

Problem Description

I used to upload bin file in NodeMCU using OTA method by web browser. Though, everything was working quite well, but before some day I was trying to upload code by same method, after that I observed that my WiFi was not working, it was stuck in unknown state. However, when I reset the MCU then it started to work perfectly, but I was confused because of this behavior of WiFi

After certain testing I got problem that, when Host sending file to the MCU during that period if host lost the connection, due to network issue, range issue and many other than WiFi goes to unknown state. For recovery I have to do hard reset compulsory or else perform power off and on operation.

Is there solution available, by which I can recover my WiFi without resetting ?

Sketch

/*
  To upload through terminal you can use: curl -F "image=@firmware.bin" esp8266-webupdate.local/update
*/

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>

const char* host = "esp8266-webupdate";
const char* ssid = "office1";
const char* password = "123456789";

ESP8266WebServer httpServer(80);
ESP8266HTTPUpdateServer httpUpdater(true);

void setup(void) {

  Serial.begin(9600);
  Serial.println();
  Serial.println("Booting Sketch...");
  WiFi.mode(WIFI_AP);
  WiFi.begin(ssid, password);

  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    WiFi.begin(ssid, password);
    Serial.println("WiFi failed, retrying.");
  }
  Serial.print(WiFi.localIP());
  MDNS.begin(host);

  httpUpdater.setup(&httpServer);
  httpServer.begin();

  MDNS.addService("http", "tcp", 80);
  Serial.printf("HTTPUpdateServer ready! Open http://%s.local/update in your browser\n", host);
}

void loop(void)
{
  httpServer.handleClient();
}

Debug Messages

⸮�⸮=⸮⸮⸮
SDK:2.2.1(cfd48f3)/Core:2.4.2/lwIP:2.0.3(STABLE-2_0_3_RELEASE/glue:arduino-2.4.1-13-g163bb82)/BearSSL:6d1cefc

Booting Sketch...
scandone
del if0
mode : softAP(a2:20:a6:13:18:2b)
mode : sta(a0:20:a6:13:18:2b) + softAP(a2:20:a6:13:18:2b)
add if0
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 6
cnt 

connected with office1, channel 2
dhcp client start...
ip:192.168.31.53,mask:255.255.255.0,gw:192.168.31.1
192.168.31.53HTTPUpdateServer ready! Open http://esp8266-webupdate.local/update in your browser
Update: WebUpdater.ino.nodemcu.bin
sleep disable
...................

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions