ayushsharma82 / WebSerial

A remote terminal library for wireless microcontrollers to log, monitor or debug your firmware/product
https://webserial.pro
GNU Affero General Public License v3.0
461 stars 107 forks source link

Cant Upload OTA while Webserial is running #67

Closed Coaxgames closed 10 months ago

Coaxgames commented 10 months ago

From what i see there is no way to Force close Webserial Socket once open, This leads to OTA functions not working correctly Shown Below is the errors i get while webserial is running(Client connected or not) from the USB Serial.

Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed
Start updating sketch
Progress: 0%
Error[2]: Connect Failed
Error[4]: End Failed

So in this block i want to close Webserial so OTA can work(Shown Below)

ArduinoOTA
  .onStart([]() {
    String type;
    if (ArduinoOTA.getCommand() == U_FLASH)
      type = "sketch";
    else // U_SPIFFS
      type = "filesystem";

    // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
    Serial.println("Start updating " + type);

    //Would also like a way to check if Webserial is running currently
    if (WebSerial.IsRunning()==true) {
     WebSerial.CloseConnection(); //close Connection so i have to recall "WebSerial.begin(&server);"
      //OR
     WebSerial.PauseConnection(5); //A pause for X world work as well however i would prefer to close and begin Webserial
    }

  })
Coaxgames commented 10 months ago

Problem solved, i had forgot ESPAsync has server.begin() and server.end()