Skip to content
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

Embassy support #11

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Conversation

arturkow2000
Copy link

@arturkow2000 arturkow2000 commented Aug 16, 2022

This PR contains a WIP support for embassy.

Currently, the implementation is working and I can run CoAP server on nRF52840 target, but it breaks tokio. Changes done:

  • where possible replaced std imports with core/alloc imports
  • added tokio and embassy features
  • made observable resource support an optional feature - currently, observable resources are not supported on embassy and must be disabled
  • RNG is passed as argument instead of rand::thread_rng()
  • removal of future spawning - embassy requires that all spawned futures must be 'static which caused major problems
    EDIT: TaskPool used for spawning futures requires self: &'static Self, futures must be 'static, not &'static. So taskpool would have to be declared as static and passed to CoAP server, to declare static variable we must known concrete type of the future to be spawned with TaskPool, static POOL: TaskPool<impl Future> won't work. AFAIK it's not possible to use async move {} - futures need to be created by implementing Future trait.

Closes #8 and #3

@arturkow2000 arturkow2000 marked this pull request as draft August 16, 2022 07:17
@jasta
Copy link
Owner

jasta commented Aug 22, 2022

Thanks so much for doing this work, it's a lot for me to unpack as I've not done much embedded rust before but getting into it now. Would you prefer to wait until after Tokio is repaired? If not, I can try to figure out what it would take to fix when I get some free time soon

@arturkow2000
Copy link
Author

Thanks for interest. This work as done as part of CoAP server implementation for the Fobnail project and currently I am focusing on other stuff but I plan to resume work on this PR soon.

@jasta
Copy link
Owner

jasta commented Aug 25, 2022

Ack'd, I may take a look shortly for my own goals and see if I can generalize it to still work with Tokio. There are some good insights into https://github.com/ryankurte/rust-coap-client for how this kind of generalization can work.

@jasta
Copy link
Owner

jasta commented Jul 30, 2023

I'm adding this support myself now as well as supporting no_std in order to use this code on my esp32. See: https://github.com/jasta/coap-server-rs/tree/main/coap-server-embassy

@jasta jasta self-assigned this Jul 31, 2023
@jasta jasta added the enhancement New feature or request label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants