Go Down

Topic: Add extra safety treshold to OTA updates (Read 1 time) previous topic - next topic

paai

Mar 24, 2020, 12:17 pm Last Edit: Mar 24, 2020, 12:20 pm by paai
Is it possible to tie the selected port for uploading a sketch exclusively to that particular sketch if it is an IP number?

As the situation with the IDE is now, the last port used remains active for all open sketches. So if I worked on, say, an update for my sun blinds and upload it OTA to the IP number of the installation, the port keeps pointing to that IP number until I explicitly change it.

So if the next day I decide to work on a different project, that has no OTA and should be attached to an USB port, and forget to change the port in the IDE, my sun blinds program gets clobbered and I have to climb to the attic to detach the box, bring it down to my PC, repair it using the USB port, climb back to the attic and attach it again.

I may be an exception, but it happens to me far too often to be funny any more.

The obvious remedy would be for the IDE to remember which sketch uses what IP number and refuse all other sketches to be uploaded to that same IP number (unless overrided by the programmer).

Paai
 

ballscrewbob

If you DEFINE the IP in the sketch used by the program it should be locked.
You may also have to set that IP in your router too.

If you use DNS and your router changes anything often then that IP should still be valid for that particular board.

Not knowing what board you have is also a disadvantage.

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

paai

Thank you for your answer. The board I work with is a WEMOS D1 R2 (esp8266) and there is no local DNS on my network.

How would 'defining' the IP number (#define IP 192.168.178.43?) work? That would imply that somewhere in preferences.txt (or in a different file) that IP number is associated with that particular sketch. But then, the IDE should somehow check all other sketches to see if that particular IP number was addressed.

Anyhow, I tried a sketch with  "#define IP 192.168.178.43" added, first updating with OTA (which worked) changed to a different sketch that had no IP defined and yes, the original sketch got clobbered again.

Paai

ballscrewbob

If as you say "defining" the IP worked then I am not sure what else to offer.

Normally most home use a DNS to offer an IP to new devices as they join the network.
This tends to be especially true to WiFi devices.

Networking can either be a simple or a complex subject.

Most users prefer a simple approach but if you want to lock down an IP to a device there are the two methods.
In the router, managed switch or similar or the device itself.
That moves you into the beginning of a more complex approach.

At least 3 devices here are locked in at both the device and router level.
Unfortunately  none of them are wemos devices.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

paai

I may have put it not clearly enough. No, I don't have problems with assigning an IP number to a hostname. Everything works just fine.

The problem occurs with OTA updates. They work also fine, but the last IP number to which an OTA update was sent, remains the default in the IDE for all subsequent sketches, until you change it explicitly using Tools->Port.

I may be the only person in the world who occasionally forgets to change the port and subsequently sends a non-OTA sketch to that IP number, clobbering the original sketch at that host (and worse, the possibility to repair it On The Air).

What would help is a feature in the Arduino IDE, that somehow pairs a sketch and an IP port and subsequently prevents sending other sketches to that IP port.

Alternatively, the IDE could prevent sketches that do not have the OTA library included, to IP ports.

Paai




 

Go Up