embassy-rs / embassy

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

Disconnect wifi to save energy #1519

Open lucasmerlin opened 1 year ago

lucasmerlin commented 1 year ago

Hi! Is there any way to disconnect the wifi after the connection has been established?

Frostie314159 commented 11 months ago

Any updates on this?

phire commented 10 months ago

The energy cost of reconnecting is somewhat high, so if you are planning to reconnect every few min, it would be more sane to just to put the wifi into the SuperSave power management mode and leave it idle.

I'm not sure how long your polling period would have to be to actually save power by disconnecting.


It wouldn't be too hard for someone to implement disassociation. According to the upstream driver, it's just a matter of sending a single ioctl.

But, from what I can tell, you need to to fully de-initialize the wifi chip to get the lowest power consumption, which would require quite a bit of refactoring. Either the job of uploading the firmware needs to be moved inside the wifi runner, or embassy-executor needs to gain functionality to stop tasks and start them again later.

Frostie314159 commented 10 months ago

Prehaps we could make use of the target wake functionality, which was made available in wifi 6.