I am using ESP32 with PlatformIO and looking to add OTA feature. Can I upload firmware to ESP32 anywhere in the world. If it is so how to find IP of my ESP32. Is it enough public IP? and how to add authentication for OTA? otherwise anyone who knows public IP can do OTA.
OTA and methods for authentication are explained in the documentation. For the “how to find the IP of my ESP32” when the ESP32 could be connected in any unknown way to the internet, you need to look into NATs, port forwarding and dynamic-DNS.
If you want to do OTA remotely, I it would be better to approach it the other way… too many hoops to jump otherwise! Instead of connecting to the ESP32 for an update… have it connect to a publicly facing source for your file… i.e. a file hosted online that the ESP32 can access via the wifi, and check against to see if it should download an update for it self. i.e. The file might contain the latest version number and URL for that firmware file, and the ESP32 firmware would have it’s version number embedded in it to compare, so when the two don’t match, it triggers an ESPhttpUpdate.
Make sure you look at the documentation link Max gave above, as Ivan did a presentation and provided demo source code for how to do secure OTA with bintray, with the device only needed internet access to do the update checks and firmware download.
A writeup for how to do a more sophisticated and basically automatic once it’s configured ‘public’ OTA is this one… I tried it out myself a while ago, and really liked it, but it takes some working through, especially if you’re new to source version control, OTA, CI, etc.
Sorry, haven’t done anything GSM based yet (I have one or two projects in mind), so have no idea how to do stuff in that space.