-
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
~~Rename and~~ split of esp
feature based on ESP32 chip types
#236
Conversation
Good investigating, I like how much you're asking why on these things! I wonder if someone at espressif might have a good answer on how (and why) we should be setting lower limits on these based on chip selected, and what the interaction here is with esp-wifi. @bjoernQ perhaps? |
@jamessizeland Thanks. Espressif surely will know. My current guess is it's something within their wifi blob. I don't really understand why there would be a lower limit, at all. Could even be a bug in their blob. References:
|
ESP32, ESP32-S2, ESP32-S3 and ESP32-C3 use different Bluetooth drivers than later chips (which are based on Nimble). For the later chips there is a config |
I might. However, thanks to your information I'm able to make a change to TrouBLE that works for now. This fixes my personal itch. @ALL: I've crafted another approach, where the forcing of 255 happens directly from Once
|
@lure23 Would it make more sense maybe to pass the MTU as a const generic to the APP functions? Afaik, this avoid having to use features at all, with only a const generic needing to be added to the app run() fn. The reason it was not passed as a param before was the the host resources had to be in a static, but it does not need to be anymore. |
But if I pass the other branch (that works) into this PR, we can discuss that as a proposal. :) If there are structural ways that you guys know of to make the change better, great. Also keeping in mind that @bjoernQ 's comment implies the problem could be solved by edit Now I get it. Sure, we can let the MCU-specific projects pass the MTU's that way. I don't really like the app/MCU specific arrangement, to begin with; would rather have it the other way round (MCU specific stuff as dependency of the We can also do a combined approach: pass the MTU as generic to |
Yes, this is what I'm proposing. |
Would you be okay to check a PR that moves all of this to the MCU-specific side: let mut resources = Resources::new(PacketQos::None);
// Hardcoded peripheral address
let address: Address = Address::random([0xff, 0x8f, 0x1a, 0x05, 0xe4, 0xff]);
info!("Our address = {:?}", address);
let (stack, mut peripheral, _, mut runner) = trouble_host::new(controller, &mut resources)
.set_random_address(address)
.build(); Moving the address generation there has the benefit that we could showcase how to make non-fixed (MAC-based) addresses. Something that was mentioned a while back. I'll toy with this and see how it feels. Anyhow, the outcome will be towards your proposal. p.s. This does mean |
I think it's better if the trouble setup is within the example to make it more self contained. This separates the controller setup which is MCU-specific and the host stack which is MCU independent. Something like the following type signature is what I'm thinking of:
|
/test |
esp
feature based on ESP32 chip typesesp
feature based on ESP32 chip types // don't merge yet; WIP
/test |
I've tried two approaches now (links below). Neither seems perfect and I'll try to analyse the pros/cons here. Trying to give optional overrides for const generics in Rust is... kind of painful. :) Actually, cannot be done. Also, structs can have default const generics but functions cannot (in Most importantly, I feel the My suggestion is becoming a hybrid of these two. I would a) move b) follow the earlier work I did, to steer the ESP32-specific overrides in Let's see the code. // It might be good if you open these to another window. I'll narrate them below. lure23/trouble.fork@main...lure23:trouble.fork:examples-feature-l2cap-mtu2This has changes for all the four examples.
Pros:
Cons:
lure23/trouble.fork@main...lure23:trouble.fork:examples-feature-l2cap-mtu3I did this only for the Pros:
Cons:
I'd like to hear your response. Personally, I'm fine pushing the force-featuring branch into this PR and then crafting a separate one of the |
My vote goes to the examples-feature-l2cap-mtu3 - I really don't think it is good to have esp32-specific features mixed into the trouble-host crate, it should stay independent of the controller. For the CI, I have another suggestion which is to use https://doc.rust-lang.org/std/macro.option_env.html instead of features to allow overriding the chip-specific address with a fixed one. Invoked like this:
|
…chips we *think* don't need it, documented
5b7d656
to
8f91160
Compare
I hear you. There's also one more approach, which I've updated this PR itself to show.
Once this is merged, I would raise an issue at I chose to leave the 1017 magic numbers to a) limit PR size, b) change behaviour from the current state as little as possible. The reason I find this better than above discussed options p.s. Do we know people who'd have ESP32-C2 and ESP32-H2 hardware, willing to test? |
esp
feature based on ESP32 chip types // don't merge yet; WIPesp
feature based on ESP32 chip types
esp
feature based on ESP32 chip typesesp
feature based on ESP32 chip types
esp
feature based on ESP32 chip typesesp
feature based on ESP32 chip types
/test |
1 similar comment
/test |
Looks good to me, thanks for taking the time exploring the alternatives here. There are clearly trade-offs, and I agree the current approach looks most attractive right now.
I do not have any of those (only c3 which I'm planning to get added to the HIL hardware soon). |
I was somewhat bothered by the "magical" 1017 MTU limit for "Some ESP[32] chips". Which chips? Where are the details?
So I tested on the two chips I have access to: ESP32-C3 and ESP32-C6. Results:
Seems that a) ESP32-C3 doesn't need any special handling in the TrouBLE examples.
b) The limit for ESP32-C6 is >= 255, not 1017.
I don't claim this to be the whole truth. I haven't found any mention of such MTU limits. What I do suggest is renaming the feature and splitting it so that for each chip we run as closed to the (by trial and error) found limit as possible.
Is this okay?
What to do with the other ESP32 chips? In the initial version of the PR I left their behaviour unchanged (safe bet). Actually I'd like to not use MTU limits with each, until someone reports seeing a panic in the examples.
If this approach looks okay-ish, I'd also like to experiment with a better way to define the repeating blocks. Have two ideas about it, but having
build.rs
create a constant would mean generating a code snippet. Don't know if you are okay with such added complexity (it would clean the example code, though).