esp-rs / std-training

Embedded Rust on Espressif training material.
https://esp-rs.github.io/std-training
Apache License 2.0
590 stars 75 forks source link

WIFI Example does not compile with the esp_idf_svc crate recommended in the `esp-rs` book #242

Open juliankrieger opened 5 months ago

juliankrieger commented 5 months ago

When running a project templated by esp-idf-template and adding wifi.rs from common, I can not successfully run cargo build.

I must admit, I'm a bit confused on the use of heapless in the esp_idf_svf::wifi Component. I thought the whole point of using the std feature flag was to enable the use of std::String.

Note that I am aware of #233 and the usage of heapless:v.08, however, since the esp-rs book links to std-training and std-training uses esp_idf_svc:v.0.47.3 and neither crate uses Semver past 1.0, users (like me) could be rightfully confused on compilation errors when using the esp-idf-template instead of the provided workshop repository.

I think we should consider moving from .into to try_from, as the documentation of heapless suggests.

Error:

error[E0277]: the trait bound `heapless::string::String<64>: From<&str>` is not satisfied
  --> src/wifi.rs:59:24
   |
59 |         password: pass.into(),
   |                        ^^^^ the trait `From<&str>` is not implemented for `heapless::string::String<64>`, which is required by `&str: Into<_>`
   |
   = note: required for `&str` to implement `Into<heapless::string::String<64>>`
Vollbrecht commented 5 months ago

Yeah that is not ideal. The overall correct way would be to update the training to the latest esp-idf-svc release. Thanks for bringing up the issue.

juliankrieger commented 5 months ago

@Vollbrecht I wouldn't mind helping out.

Vollbrecht commented 5 months ago

Feel free to create a PR, it probably would be enough to update every occurrence of esp-idf-svc in the Cargo.toml and test if all solution examples still work. Besides the mention wifi problem the esp-idf-svc API that is used in the training should not have changed much.

juliankrieger commented 5 months ago

On it. What's to determine is if using .try_into.unwrap() is sufficient. Alternatively, one would need to implement error handling in the style of anyhow for conversion errors.

Vollbrecht commented 5 months ago

I think the training is using anyhow, so an context() with a panic massage would be ok here

juliankrieger commented 5 months ago

Done. Works on my machine. https://github.com/esp-rs/std-training/pull/243