embassy-rs / nrf-softdevice

Apache License 2.0
264 stars 79 forks source link

Low power with softdevice #79

Closed kuon closed 2 years ago

kuon commented 3 years ago

This might be a bit of a broad question, but how can I make a gatt server low power?

I have an app similar to the ble_bas_peripheral example.

Basically, I have 3 tasks:

The sensor read task is similar to this: https://github.com/embassy-rs/embassy/blob/master/examples/nrf/src/bin/twim_lowpower.rs

And the sensor task has a channel to communicate with the bluetooth task to push data to it.

Dirbaio commented 3 years ago

Yeah, lowpower should Just Work.

The embassy executor automatically puts the CPU to sleep with WFE when there's no work to do.

If you ensure all peripherals that require HFCLK are disabled when not needed (like with that twim_lowpower example) you should get super low power operation :)

kuon commented 3 years ago

So, even if sd.run().await is still running, embassy will be able to put the device to sleep?

Dirbaio commented 3 years ago

Yep!