BleRadio requires buffers to be &'static mut, which is quite difficult to satisfy cleanly, if I'm not missing anything. It played well with RTIC 0.5 resources, but e.g. RTIC 0.6 (as I understand) no longer has static resources, and all resources are now in return value from init task, so now you have to initialize those buffers in the init task (I might be wrong here, I'm quite new to RTIC). Just to be sure, is there a better way to create BleRadio instance with RTIC 0.6 (or in general case), rather than declaring those buffers as static mut which implies unsafe?
Though even if BleRadio buffers didn't require static lifetime but were still borrowed, it would still be difficult to wrap them together in the single struct (as below, e.g. for RTIC 0.6 local resources) cleanly:
Such struct can't be fully initialized at once, because BleRadio::new() would need to borrow other fields of the struct. One way is to instantiate mutable struct with initialized buffers and dummy radio field (or making it None with Option), then instantiate proper BleRadio with borrowed buffers from the struct, and then replace the dummy radio value with the correct one it in the struct. But it doesn't look optimal.
And so I was thinking, what if BleRadio owned buffers instead of borrowing them, and their sizes could be specified with const generic params?
After some more practice with embedded side of Rust, I realized I had a very naive and distorted view about it. Please, disregard this issue. Sorry for the noise.
Hi! I wanted to replicate
nrf52-beacon
demo with RTIC 0.6.0-rc.2, and I struggled with providing rubble-nrf5x::BleRadio with TX and RX buffers.BleRadio
requires buffers to be&'static mut
, which is quite difficult to satisfy cleanly, if I'm not missing anything. It played well with RTIC 0.5 resources, but e.g. RTIC 0.6 (as I understand) no longer has static resources, and all resources are now in return value frominit
task, so now you have to initialize those buffers in the init task (I might be wrong here, I'm quite new to RTIC). Just to be sure, is there a better way to createBleRadio
instance with RTIC 0.6 (or in general case), rather than declaring those buffers asstatic mut
which impliesunsafe
?Though even if
BleRadio
buffers didn't require static lifetime but were still borrowed, it would still be difficult to wrap them together in the single struct (as below, e.g. for RTIC 0.6 local resources) cleanly:Such struct can't be fully initialized at once, because
BleRadio::new()
would need to borrow other fields of the struct. One way is to instantiate mutable struct with initialized buffers and dummyradio
field (or making itNone
withOption
), then instantiate properBleRadio
with borrowed buffers from the struct, and then replace the dummyradio
value with the correct one it in the struct. But it doesn't look optimal.And so I was thinking, what if
BleRadio
owned buffers instead of borrowing them, and their sizes could be specified with const generic params?