JAndrassy / ArduinoOTA

Arduino library to upload sketch over network to Arduino board with WiFi or Ethernet libraries
GNU Lesser General Public License v2.1
435 stars 89 forks source link

Allow re-opening previously uploaded data. #205

Closed freemp closed 1 year ago

JAndrassy commented 1 year ago

what for is it good?

freemp commented 1 year ago

It lets you upload firmware data without losing it if not applied right after. By using the length parameter in open(), pageAddress and pageIndex is recalculated basing on the size of the previously written data. With this, you may either continue uploading or perform apply anytime later.

JAndrassy commented 1 year ago

but what about second attempt to upload from start? maybe just don't call open() again if you can continue the transfer

freemp commented 1 year ago

Why a second attempt if all data is in flash already? Maybe I can't re-attempt, for whatever reason. I would like to be able to upload firmware now, keep it in stock, and apply anytime later.

You cannot continue the transfer if the device is reset meanwhile. But you could if you simply pass and process the previously uploaded size with open(), as proposed.

JAndrassy commented 1 year ago

the flash is written in pages. the unwritten part of the buffer will get lost. but after you close(), you can call apply() any time.

and the second attempt doesn't have to be the same version of the sketch. the IDE always uploads from start.

how would you track what you have currently in flash?

but why you even use this library? the InternalStorageAVR is simple, you can incorporate the code from it into your sketch and have better control over it.