Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By rDr4g0n
#39200 Can OTA work when the esp's wifi is operating as an access point? If so, I cannot seem to get it to work. I can bring up and connect to the AP, but when I attempt to send an OTA update using espota.py, I get the following from the esp's ota debug serial logging:

Code: Select all[begin] roundedSize:       0x0003F000 (258048)
[begin] updateEndAddress:  0x00100000 (1048576)
[begin] currentSketchSize: 0x0003F000 (258048)
[begin] _startAddress:     0x000C1000 (790528)
[begin] _currentAddress:   0x000C1000 (790528)
[begin] _size:             0x0003EB40 (256832)
Start
Connect Failed
Error[2]: Connect Failed
premature end: res:0, pos:0/256832
rror[4]: End Failed
ERROR[0]: No Error


If I perform the OTA update while the ESP is connected to another AP (that is, the ESP is not operating as an AP), the update works as expected.
User avatar
By rDr4g0n
#39318 Here is a sample sketch. In the sketch as it is here, OTA works perfectly. However, inside the `setup` function, if `connectToAP` is commented out and `beginAP` is uncommented, the esp brings up an AP I can connect to, but I am unable to perform an OTA update.

Code: Select all#include <ArduinoOTA.h>

const char* ssid = "clownshoes";
const char* password = "clownshoes";
const char* ota_hostname = "clownshoes";
IPAddress apIP(192, 168, 1, 1);

// starts an access point
void beginAP(const char* ssid, const char* password, IPAddress ip){
    //WiFi.mode(WIFI_AP);
    WiFi.mode(WIFI_AP_STA);
    WiFi.softAPConfig(ip, ip, IPAddress(255, 255, 255, 0));
    WiFi.softAP(ssid, password);
    Serial.print("AP is up at ");
    Serial.println(WiFi.softAPIP());
}

// connects to an access point
void connectToAP(const char* ssid, const char* password){
    Serial.print("");
    WiFi.begin(ssid, password);
    while(WiFi.status() != WL_CONNECTED){
        Serial.print(".");
        delay(500);
    }
    Serial.print("\nConnected to '");
    Serial.print(ssid);
    Serial.print("' and got IP ");
    Serial.println(WiFi.localIP());
}

// starts OTA server
void beginOTA(const char* hostname){
    ArduinoOTA.setHostname(hostname);
    ArduinoOTA.onStart([]() {
        Serial.println("Start");
    });
    ArduinoOTA.onEnd([]() {
        Serial.println("\nEnd");
    });
    ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
        Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
    });
    ArduinoOTA.onError([](ota_error_t error) {
        Serial.printf("Error[%u]: ", error);
        if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
        else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
        else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
        else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
        else if (error == OTA_END_ERROR) Serial.println("End Failed");
    });
    ArduinoOTA.begin();
    Serial.print("OTA is up");
}

void setup(){
    Serial.begin(9600);
    //beginAP(ssid, password, apIP);
    connectToAP(ssid, password);
    delay(500);
    beginOTA(ota_hostname);
}

void loop(){
    ArduinoOTA.handle();
}
User avatar
By anotherjoe
#41025 I came across this thread and your related github issue when I encountered this same problem myself today and I agree there is a problem here somewhere that prevents IDE OTA working in conjunction with soft AP mode. So your thread and github issue get an up vote from me.

The difference between my scenario and yours is that your sample sketch shows you're using the new v2 ArduinoOTA and here I'm using the stable classic OTA method (https://github.com/esp8266/Arduino/blob ... updates.md).

The result is basically the same though: IDE OTA works fine when softAP is not in use and doesn't work when it is in use.

In classic OTA mode when it fails on OTA update attempt, I see a crash in the connected serial window with a dump of memory addresses. I'm not sure how helpful that is but I'll happily grab and post it if helps anyone fix this.