-
Notifications
You must be signed in to change notification settings - Fork 2k
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
pkg/wakaama: Add basic LWM2M client implementation #11036
Conversation
bc9957d
to
feafb2e
Compare
@kb2ma you mentioned you would be able to review the rework of wakaama? |
Thanks for the reminder. I'll start digging in. |
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.
@leandrolanzieri, it will be great to have an LwM2M client example! I have started by testing against only a registration server, with no bootstrap server. I was able to run the client and server, manipulate the LEDs, and interact with the Leshan demo server. See the inline comments and question below on issues that arose.
How did you set up the tap interface on native? I usually assign a ULA on the tap interface, like fd00:dead:beef::1. I then add the native instance to that network, at fd00:dead:beef::2, via RIOT's ifconfig command. The Leshan server was able to receive CoAP messages in this case. However, to send a message to read a value, the Leshan server used a different local address on the same network, like fd00:dead:beef::919f:e3c:0:2721, which the RIOT native instance did not respond to. I found that I had to set the local address of the server via the --coaphost option, like '--coaphost [fd00:dead:beef::1]' to get this to work.
Thanks for testing!
What I have been doing so far (though it may not be the correct way) is to create the tap interfaces and use the address of the tapbr0 as the server. Then I run the Leshan server without setting the |
Thanks, I'll try use of tapbr0 address. |
I got the bootstrap server to work after resolving the issue with the port noted inline. I have started to look at the code, but there is a lot to review! I hope we can make some time at IETF over the next week to make progress. |
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 ran through the example with and without bootstrap on both native and samr21-xpro. The only thing that may be nice is to link to some general tutorial that explains lwm2m for those who are starting from scratch. Not everyone has a @leandrolanzieri across the desk.
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.
First, I don't know LWM2M, or waakama. My comments are thus only related to general coding stuff and the RIOT integration.
The most important thing here is that this is ALOT of code, so I probably missed many things. At the same time, I feel its size is not so much because of what it does, but how it does it:
- A pooled allocator implementation that AFAICT does not belong here.
- Bit switch...case that can be replaced by table lookups.
- A big URI parsing routine.
- The lights stuff does not belong to the package.
Because of the last point, I did not go deep into the lights code.
sys/include/net/lwm2m.h
Outdated
* @brief Device name used to register at the LWM2M server | ||
*/ | ||
#ifndef LWM2M_DEVICE_NAME | ||
#define LWM2M_DEVICE_NAME "testRIOTDevice" |
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.
Is it a good idea to give default values for parameters other than port? I can imagine loads of devices showing up as "testRIOTDevice".
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 part of the exposed compile configurations for the module, should be changed by the user when using multiple nodes, I think it makes things easier to have a default one.
pkg/wakaama/contrib/lwm2m_objects/light_control/light_control.c
Outdated
Show resolved
Hide resolved
return 0; | ||
} | ||
|
||
static lwm2m_client_connection_t *_connection_create(int instance_id, |
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.
Do we really need to roll out a URI parser from scratch specifically for this module?
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 guess it could be eventually refactored to a module or replaced by an existing pkg.
release status ping, should I change the milestone? |
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.
Blocking until hard feature freeze
The latest code tests fine without the internal Wakaama logging. However, with It looks like some problem with LWM2M_ALT_PATH defined as NULL. I saw you added a patch for something similar in 2cc4ec4. What changed?
|
Hmm I patched It's odd because this functions accept |
I just checked out an early commit from this PR, and I see that LWM2M_ALT_PATH was defined as NULL there also. I know I have tested with LWM2M_WITH_LOGS before, but I don't remember this issue with the garbage output. It might be worth digging a little to determine if something about RIOT has changed that now is triggering this issue. |
I tested this on latest release (without the logging fix patch) and the logs seem to be OK:
The NULL pointer is recognized and no garbage is printed. I will try to bisect. |
Disregard this. It does not work for samr21-xpro. It seems it really depends on the implementation of Do you remember if the moment when you tested this with logs you were compiling for native or a different platform? |
OK, sounds good. It really needs to be fixed. You can see that upstream handles this case in internals.h for
No, I don't remember. |
@kb2ma I added the patch |
I don't see the error any more with this patch. Thanks! I have discovered one more problem with logging on samr21-xpro. There are lines like this in the code:
which result in the following in the log:
|
So this seems to be a limitation of the implementation of |
I can only suggest to do the simplest thing to make it work. I got the code below to compile in Wakaama's Maybe you could just patch the code for I know it's a pain in the neck, but I think it will be useful for debugging to see these values.
|
Looks good. Tests fine for bootstrap and non-bootstrap. Please squash! |
354c554
to
98fade8
Compare
98fade8
to
153d3bc
Compare
153d3bc
to
8d47813
Compare
@kb2ma done, everything looks good |
Before I press the button, what were the problems? I saw some out of memory issues, LLVM issues. |
Some boards missing in the 'insufficient memory list' (some new boards and renaming of nucleo boards), some new 8-bits boards had to be added to the blacklist. LLVM didn't like the lack of a newline at the end of one file in the package (thus the new patch 0021) and needs an attribute line for the printf function, that performs a check on all the calls to make sure that the format string is ok for printf. |
Finally the embedded OS deities have been satisfied. 126 comments to bring in a package. Is @leandrolanzieri getting stronger or is he about to fold? Only time will tell. ;-) At any rate, we mortals appreciate all the work you put into this! |
Thanks everyone!! 🎉 Especially @kb2ma for your thorough testing and reviewing! 🚀 |
@leandrolanzieri yay! |
Contribution description
This PR is a part of a rework of #8610 by @moenoel (see #8610 (comment)).
This PR adds
Contrib code
Example
For now the client only implements no security connections. In future PRs DTLS support will be added.
Testing procedure
Run the
examples/wakaama
applicationSERVER_URI='\"coap://[<ADDRESS_OF_SERVER>]\"' make all term -C examples/wakaama/
Issues/PRs references
#8610
Depends on #10738