-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove C: Controller
from HostResources<C>
#252
Comments
C:Controller
from HostResources<C>
. ConsiderC:Controller
from HostResources<C>
C:Controller
from HostResources<C>
C: Controller
from HostResources<C>
My example project here allocates it in a static cell, which works okay where I can select the controller non-generically. https://github.com/jamessizeland/microbit-ble-gamepad/blob/main/src%2Fble%2Fgatt.rs#L49-L51 |
Sure but (a) the SoftDevice controller is It can be made |
The relevant PR that (I think) fixed a similar lifetime issue in |
Would like to add one more benefit:
|
Yep I agree it would be worth making it able to be torn down. |
The above PR is actually the basis of the current design. However, I've not found a nice way to decouple the Controller trait from the resources, that still allows it to be allocated on the stack like for embassy-net. In contrast to embassy-net, which only needs to store a byte buffer for sockets that the drivers push/pull from, the bt-hci Controller defines all possible HCI commands that allows skipping serialization/deserialization. Maybe we should just require HostResources to be static for now, and find a different way to make it possible to stack-allocate it. Regarding PacketQos, I'd like to get rid of that entirely, as it's not as useful in practice as I originally intended. |
I'm not sure I follow how from this it follows that the Specifically, why is it that this field has to live inside
I'm not sure I follow this either. Your examples do exactly that - stack allocate both the
And that's exactly the problem. We should strive to somehow make it possible for |
So, if the
Yes, that would be possible, but isn't that a bit problematic, as you'd generally not want to risk users passing a different controller instance to each different method? Also it kind of convolutes the API a lot needing to pass the controller instance everywhere don't you think?
Yes, I agree. |
I think I have an approach that may work that I'm testing out that merges Stack and Builder:
This way, I think it should be possible to fix this. HostResources no longer holds onto BleHost, it is stored in Stack. However, Stack is no longer Clone + Copy, I'm not really sure it needs to really. It means an additional lifetime of the stack must be managed separately from the resources, but it should be contained to the Perpiheral, Central and Runner types. |
That looks very promising! Is
I never meant passing the |
(Mentioned ~ 3 months ago.)
I guess the idea of
HostResources
is similar toembassy_net::StackResources
which I think is a solid approach.However - and because
HostResources
is generified byC
- it simply cannot be stored in a static context, or in fact in any context which has a longer lifetime than the controller itself (as the controllermost often than notsometimes is itself not: 'static
, or if it can be made: 'static
via a series ofmake_static
calls to its parameters it means the BT stack runs forever).I guess it is no coincidence that the examples have the
HostResources
allocated on-stack and not from a static cell - the later is not possible IMO.Removing the controller from the host resources will have multiple benefits:
rodata
space given that theQoS
parameter is also removed. Currently it spoils the party, as it is neither all-0-bits, norMaybeUninit
and is the only such one in the structThe text was updated successfully, but these errors were encountered: