OTA Update: 1x ESP8266 Access Point and 1 ESP8266 as STA

Hi,

I have an ESP8266 that works as Access Point and I implemented the OTA Flashing option.
Here is the sample code.

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

ESP8266WebServer webServer(80);
ESP8266HTTPUpdateServer webUpdater;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  
  //The SSID must be >8 characters and <64 characters
  //I'm adding the chip ID onto the end to get a unique (ish) name
  //String ssid = "ESP8266 " + String(ESP.getChipId(), HEX);
  String ssid = "Test Access Point AP";
  
  //The password must be <64 characters and can be left blank for no password
  String pass = "password";
  
  Serial.printf("WiFiSSID: '%s'\n", ssid.c_str());
  Serial.printf("Password: '%s'\n", pass.c_str());
  
  WiFi.mode(WIFI_AP);
  WiFi.softAP(ssid.c_str(), pass.c_str());

  webServer.on("/", [](){
    webServer.send(200, "text/plain", "Successfullly wifi updated
HELLOWORLD");
    //webServer.send(200, "text/plain", "Successfullly wifi updated");
  });

 webUpdater.setup(&webServer);
 webServer.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  webServer.handleClient();  
}

I want to add a line in the setup() when a GPIO Pin is connected to ground it should start in Station mode and connect to Access Point.

Now the big question.

When I connect to my AccessPoint and go to “192.168.4.1/update” is there any chance to update both ESP8266 or do I have to set a fixed IP for the ESP in Station Mode (e.g. 192.168.4.2) and visit “192.168.4.2/update” and upload the *.bin" file again?

Is there a possibility to do this?

Thanks

Any help?

Whatever is sending the updates must of course be connected to the ESP you want to update.

So if you put your ESP in access point mode and connect the laptop you use for programming to it, you should be able to do OTA updates to that ESP, and maybe other ESPs connected to that one as station.