esp-rs / esp-idf-svc

Type-Safe Rust Wrappers for various ESP-IDF services (WiFi, Network, Httpd, Logging, etc.)
https://docs.esp-rs.org/esp-idf-svc/
Apache License 2.0
309 stars 175 forks source link

Panic on firmware information #378

Open stabl-gjn opened 7 months ago

stabl-gjn commented 7 months ago

Relevant code: https://github.com/esp-rs/esp-idf-svc/blob/730fa3642d7042735de924c3d6ce71eafb8dc615/src/ota.rs#L33-L35

esp-idf-svc panics if the firmware version of esp_app_desc_t.version (and other related fields) is longer than 24 chars.

The upper limit (24 chars) is defined by embedded_svc. esp-idf-svc takes the version provided by esp-idf and tries to convert it into heapless::String::<24> panicking if the version is any longer.

In our project the version used by esp-idf-svc is the output of git describe which is quite big (e.g. v0.3.0-146-gd33fb261-dirty) and leads to a uncontrollable panic.

I think, at least the unwrap should be replaced by an except to give the developer any idea of what went wrong or in the better case be handled (in what ever way, e.g. truncate, Result/Option)

esp-idf app version description: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/misc_system_api.html#app-version

Vollbrecht commented 7 months ago

to set the correct firmware name i would suggest, you are using the app_desc makro we provide. That way you get a version controlled information and build time information, all set via your usual Cargo.toml. That way the information in the descriptor is based on your rust app and not on the esp-idf static lib the project is linked into.

stabl-gjn commented 7 months ago

@Vollbrecht thanks i will try that for now

Update: Works but as the git thing is the default behavior (and the default matters), i still think there should be something done about it.

I am happy to help with implementing it once/if there is a path on what to do.