-
Notifications
You must be signed in to change notification settings - Fork 2.1k
net/gcoap: add macro to delay initialization of gcoap #12798
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
Conversation
Thanks for the thumbs up, @pokgak. Unfortunately, I can't add you as a reviewer (yet), but I know this PR is important for gcoap support of DTLS. If you'd like to review it, I bet we could talk @leandrolanzieri or @miri64 into giving a proxy-ACK. ;-) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely simpler than the lazy init approach. I like how, with CFLAG, you can document what the flag does compared to pseudomodules where there is normally no documentation about it.
How can this CFLAG be included as a dependency to another module? I haven't seen any CFLAGS in Makefile.dep
so not sure if there are any rules regarding CFLAGS in that file or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I certainly find this solution simpler than lazy init mode
.
Although, I wonder if we should add some inline function to check if the server is already running or not. I think, for example, about the gcoap_cli, when you call coap info
it will tell you that the server is listening on GCOAP_PORT
even when gcoap is not initialized yet. There may be in the future some other modules that depend on gcoap server to be running on init?
Otherwise I find this macro to be a good solution, and agree with @miri64 's proposal for the renaming.
|
@pokgak, would a function like Also, we may create some more generic facility on the state of gcoap, which I kind of started with |
Comments addressed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good. I tested this and works as expected. ACK.
@kb2ma please squash |
1b0f9cb
to
e873e58
Compare
Squashed and tests pass. |
Contribution description
Sometimes we do not wish gcoap to start at auto-initialization time. For example, #12104 must initialize its credman tool for DTLS before the gcoap thread starts. We wish to facilitate this use case without breaking existing applications. This PR adds a macro,
GCOAP_INIT_DELAY
, to accomplish this goal. When set to 1, gcoap must be started explicitly.Testing procedure
In the gcoap example
main()
, insert the snippet below before the call togcoap_cli_init()
.Test with and without defining the macro at compile time with something like:
When defined, you should see the following at startup, and be able to send/receive gcoap messages as usual.
Issues/PRs references
Alternative to #12529.