embassy-rs / embassy

Modern embedded framework, using Rust and async.
https://embassy.dev
Apache License 2.0
4.79k stars 650 forks source link

Add http request example to rp #3115

Closed 1-rafael-1 closed 6 days ago

1-rafael-1 commented 6 days ago

After myself and 2 others had the same question in 3 days on matrix: Maybe You want an example?

This is not strictly an embassy thing, but it took me (= new to Rust and fairly new to embedded) quite some time & a lot of kind help on matrix to figure out. So my guess is others might benefit. (thanks @jamesmunns especially!)

Word of caution: Binary size grew > 10xxkb and flashing that somehow corrupts the device and the code fails. The exact same code copied into my own project works just fine. So I added a secction to cargo.toml to reduce binary size:

[profile.dev]
lto = true
opt-level = "z"

That way the code now runs without issue, with less than half the original binary size.

-> if that is not okay, then the entire thing should not go into the repo without some other solution. As a newbie I would then need help to do it differently.

1-rafael-1 commented 6 days ago

I tested some random other examples and it does not look like I broke stuff.