-
Notifications
You must be signed in to change notification settings - Fork 376
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
Enable COAP logs from cmake #716
base: main
Are you sure you want to change the base?
Conversation
It is now possible to enable COAP logs via the cmake file, without having to edit the "coap/er-coap-13/er-coap-13.c" file. Also usually the printf() function is not available with embedded platforms, so it has been replaced with lwm2m_coap_printf() which must be defined in the platform.c file.
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.
Seems like a good idea to me, thanks!
If you feel like, I suggest the following to be done too:
- Add documentation about this flag to the README.md file. There is no section yet for debugging flags, so feel free to come up with a proposal.
- Add a build with this new flag enabled, so that CI can check it does not break.
- Add a format attribute to the function lwm2m_coap_printf(), so that passed arguments can be checked at compile time.
Please let me know what you think and whether you have time/motivation to implement it. If not - no problem at all, I can do this after merging this PR.
@@ -124,6 +124,11 @@ time_t lwm2m_gettime(void); | |||
void lwm2m_printf(const char * format, ...); | |||
#endif | |||
|
|||
#ifdef LWM2M_WITH_COAP_LOGS | |||
// Same usage as C89 printf() |
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 think C89 is too specific (will also work with C99, C11, etc.)
// Same usage as C89 printf() | |
// Same usage as printf() |
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 just copied this from the comment above lwm2m_printf(...)
, anyway no problem, I'll fix this.
Do you mean add the format like this (in the __attribute__ ((format (printf, 1, 2))) void lwm2m_coap_printf(const char * format, ...); When I added this attribute the compiler gave me several warnings in the
|
Do you mean that I should append this in the wakaama/examples/client/CMakeLists.txt file? # Client without DTLS support and CoAP logs enabled
add_executable(lwm2mclient ${SOURCES})
target_compile_definitions(lwm2mclient PRIVATE LWM2M_CLIENT_MODE LWM2M_BOOTSTRAP LWM2M_SUPPORT_SENML_JSON LWM2M_WITH_COAP_LOGS)
target_sources_wakaama(lwm2mclient)
target_sources_shared(lwm2mclient) |
I would like to point out that after I fix the warnings in the I guess this was due to lines of code like this (in c the behaviour of the code is undefined in these cases): |
We moved the default branch from |
I did some big refactoring and improvements for the logging infrastructure in Wakaama: #748. The logging in the CoAP part should eventually be incorporated into the rest of Wakaama logging. |
It is now possible to enable COAP logs via the cmake file, without having to edit the
coap/er-coap-13/er-coap-13.c
file.Also usually the
printf(...)
function is not available with embedded platforms, so it has been replaced withlwm2m_coap_printf(...)
which must be defined in theplatform.c
file.