LWM2M C Language Implementation for the Small Embedded IoT Devices

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi group!

As a n00b in the IoT domain I have had trouble finding a suitable open sour
ce implementation in C for the LWM2M protocol with DTLS support.

What I have found so far are following implementations:

- Contiki lwm2m: https://github.com/sics-iot/lwm2m-contiki
- Wakaama LWM2M: https://github.com/eclipse/wakaama
- Awa LWM2M: https://github.com/FlowM2M/AwaLWM2M
- Anjay: https://github.com/AVSystem/Anjay

However I am not able to compare pros and cons of the different implementat
ions in terms of code quality, features, maturity, code size etc.

The target device is built on an ARM Cortex M4 with 256 KB Flash memory, 48
 KB of RAM and an Ethernet connection. The network stack might be LwIP supp
orting IPv4 and IPv6, but if I decide to go for Contiki I probably will use
 the built-in uIP stack. The device is a OS-less bare-metal system or Conti
ki.

I would appreciate very much if someone has experience in those implementat
ions and could give me some feedback or point me to the right direction.

Best regards,
Kalvin

Re: LWM2M C Language Implementation for the Small Embedded IoT Devices
Small update: After some evaluation I decided to go with Wakaama LWM2M due  
to decent memory requirements and porting effort. I was able to port Wakaam
a LWM2M Client with DTLS-support running on top of a LwIP 2.0.2 using the L
wIP IPv4 event-driven Raw API (ie. no sockets) with a PPP connection, consu
ming around 132KB Flash and 32KB RAM. The system is a bare-metal ARM M4 sys
tem (ie. not actual operating system) targeted for very low power sensor ap
plications requiring IoT connectivity for device management and sensor data
 uploading to the cloud server.

Br,
Kalvin

Re: LWM2M C Language Implementation for the Small Embedded IoT Devices

hi Kalvin

any updates, sample code, im trying to do the same on an m4 g55 microchip m
cu.

thanks  

rp


On Thursday, April 27, 2017 at 2:34:38 AM UTC+10, snipped-for-privacy@gmail.com wrote:
Quoted text here. Click to load it
urce implementation in C for the LWM2M protocol with DTLS support.
Quoted text here. Click to load it
ations in terms of code quality, features, maturity, code size etc.
Quoted text here. Click to load it
48 KB of RAM and an Ethernet connection. The network stack might be LwIP su
pporting IPv4 and IPv6, but if I decide to go for Contiki I probably will u
se the built-in uIP stack. The device is a OS-less bare-metal system or Con
tiki.
Quoted text here. Click to load it
ations and could give me some feedback or point me to the right direction.
Quoted text here. Click to load it


Re: LWM2M C Language Implementation for the Small Embedded IoT Devices
keskiviikko 30. toukokuuta 2018 22.48.12 UTC+3 snipped-for-privacy@gmail.com kirjoitti:
Quoted text here. Click to load it
 mcu.
Quoted text here. Click to load it
e:
Quoted text here. Click to load it
source implementation in C for the LWM2M protocol with DTLS support.
Quoted text here. Click to load it
ntations in terms of code quality, features, maturity, code size etc.
Quoted text here. Click to load it
, 48 KB of RAM and an Ethernet connection. The network stack might be LwIP  
supporting IPv4 and IPv6, but if I decide to go for Contiki I probably will
 use the built-in uIP stack. The device is a OS-less bare-metal system or C
ontiki.
Quoted text here. Click to load it
ntations and could give me some feedback or point me to the right direction
.
Quoted text here. Click to load it

Hi rp,
Sorry this late reply, but I haven't been reading the newsgroups lately. An
yway, here is how I proceeded with the porting effort:

1. First, I took the Wakaama client source code and the LwIP 2.0.2 source c
ode, and made the Wakaama client running on a PC using the LwIP socket inte
rface. This required tweaking the Wakaama build scripts so that the build p
rocess would also build the LwIP and link it with Wakaama.

2. Modified Wakaama client to use the LwIP raw API running on a PC. The LwI
P porting guide is a good place to start:
http://lwip.wikia.com/wiki/Porting_for_an_OS

This all was pretty straight forward to do as Wakaama has quite simple and  
thin networking interface using only UDP protocol.

Wireshark proved to be a very valuable too in this process when debugging t
he DTSL-related stuff for example.

You may need to use the TAP-interface adapter so that the LwIP is able to u
se the Ethernet interface of your development machine:
https://backreference.org/2010/03/26/tuntap-interface-tutorial/

Now that I had the Wakaama client running on a PC using LwIP raw interface  
I had to make it running on my target hardware.

3. I needed setup a LwIP PPP connection.

4. Tweaked the LwIP configuration to fit the target hardware.

5. Tweaked the TinyDTLS build scripts so that it compiles cleanly on the ta
rget hardware and ARM C compiler.

6. My target ARM-system did not provide the malloc and free, so I had to fi
gure out what to do with that. Luckily the LwIP provided also malloc and fr
ee, and modified the source code to use these library functions. There were
 some other minor functions that I needed to implement, like the time funct
ions.

6. After a clean build and some printf-debugging, I was able to connect my  
target hardware running Wakaama client to a server over PPP.  

That's basically the whole process. Although I hadn't been working with the
 LwIP nor Wakaama before, it took me less than two weeks (with very little  
sleep) to get the things up and running and to get the Wakaama LWM2M client
 DTLS connection working with the Leshan server.

During more comprehensive testing it was found out that DTLS/Wakaama was bl
eeding some memory. I added some printf's to LwIP malloc/free adapter stubs
 which were created to mimic the std malloc and free functions. Created a s
imple Python tool to track the malloc/free memory blocks using the printf-o
utput, and I was able to spot the problematic places and patched the code t
o release the allocated memory so that the malloc/free was working without  
any further issues.

Hope this helps you to get started.

Br,
Kalvin

Site Timeline