konnected-io / konnected-security

Konnected connects wired sensors and switches to SmartThings, Home Assistant, Hubitat and OpenHAB
https://konnected.io
Apache License 2.0
416 stars 322 forks source link

Fix OTA updates when connected to AWS. #172

Closed h2zero closed 1 year ago

h2zero commented 1 year ago

This resolves an out of memory issue when updating via Over-The-Air while connected to a secure MQTT broker/AWS. The process creates a file and writes the update info into it. The device is then rebooted and the file, if detected after connection to WiFi, is read from and the update performed using the data in the file.

Resolves #170

heythisisnate commented 1 year ago

I don't see where the ota_update.lua file is deleted after the update. Does this happen internally?

h2zero commented 1 year ago

I was confused by this also but it does seem to delete it internally. I had code in there to delete it at first but it would crash saying the file was nil.

heythisisnate commented 1 year ago

Hmm maybe because the file is written to LFS but subsequently replaced? Where is LFS.ota_update defined? I couldn't find the documentation for that.

I guess my worry is what if the OTA update fails? Would it continuously reboot? Perhaps just add a line to delete ota_update.lua (checking for presence first) if it still exists after calling LFS.ota_update

h2zero commented 1 year ago

Agreed, I'll see what I can do.

Where is LFS.ota_update defined? I couldn't find the documentation for that.

I think you meant LFS.http_ota which just runs the http_ota.lua file.

h2zero commented 1 year ago

Well that was strange, file removal worked now, not sure what the issue was before...

I also added a small change to get rid of the deprecation warning.