Arduino OTA update - how to set TCP port?

My home network (Unifi) has all the arduino devices on a seperate VLAN.
To perform OTA update the following needs to happen:

local network -> arduino network, dst 8266/udp
arduino network -> local network, dst $yourpick/tcp

Within Arduino IDE, is there a way to specify the TCP port, so I can set a firewall wall to allow just that?

Seems that ArduinoOTA.setPort(8266); can specify the UDP port within the sketch, but nowhere I can find for the seemingly random TCP port needed for the other direction.

Source article which sums up pretty much what I want to do, except I wonder the TCP port can be set with Arduino IDE: tech.fawk.eu

Ok I have it working now, if anyone could advise if there is an issue with this:

Edit this file with IDLE python editor:
C:\Users\USERNAME\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.2\tools\espota.py

And change:

  group.add_option("-P", "--host_port",
    dest = "host_port",
    type = "int",
    help = "Host server ota Port. Default random 10000-60000",
    default = random.randint(10000,60000)

to whatever port you want i.e. 12345

  group.add_option("-P", "--host_port",
    dest = "host_port",
    type = "int",
    help = "Host server ota Port. Default random 10000-60000",
    default = 12345

Anyone see an issue/easier way?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.