kstobbe / esp-update-server

Webserver to handle binary files for ESP32 and ESP8266 Over-The-Air updates.
MIT License
29 stars 15 forks source link

Wrong version parsed from firmware.bin #6

Open dloeckx opened 3 years ago

dloeckx commented 3 years ago

I really love the approach and code, thank you very much!

Unfortunately, the server recognised the wrong version number for me. Early in the binary, there is the following text: esp32-arduino-lib-builder00:39:13Feb 21 2021v3.3.4-432-g7a85334d8. server.py recognised this version number, instead of the one from my project.

To make the search more robust, I suggest to change the code in checkForUpdates to

  String checkUrl = String( ota_update_server) + String("update?dev=" HOST "&ver=" VERSION);

This will ensure that the binary contains (for HOST PoolWeather and VERSION v0.0.2) exactly the following text: update?dev=PoolWeather&ver=v0.0.2, followed by 0x00 to terminate the string. The regex can then be adjusted to m = re.search(b"update\?dev=" + __dev.encode('UTF-8') + b"&ver=(v\d+\.\d+\.\d+)\x00", data, re.IGNORECASE).

Note that also update should be dropped from the urlBase.

Also note that after this update older binaries will no longer be recognised during upload.

I've created a fork with these updates, see https://github.com/dloeckx/esp-update-server

PS: I am using platform.io , not sure if this matters.