posted: August 06, 2020 

Developing Anjay for Zephyr

To help developers who would like to use Anjay, we've decided to make another demonstration client for an embedded platform. This time we used Zephyr OS, which is an open-source real-time operating system, managed by The Linux Foundation.

For this purpose, we used the B-L475E-IOT01A development board. The board boasts a wide variety of sensors, including thermometer, humidity sensor, accelerometer, magnetometer, barometer, gyrometer and distance sensor. What’s more, thanks to the built-in WLAN modem, we could easily connect to the LwM2M server.

The big advantage of B-L475E-IOT01A is that no additional components (such as sensor boards, modems or SIM cards) are required. What’s more, Zephyr OS provides support for the selected board, as well as drivers for all sensors and WLAN modem, which made the implementation process quite easy.

The biggest problem we faced during the development of this client was Zephyr's recvfrom function. The function fails when anything other than NULL is passed as src_addr and because of that, Anjay initially didn't work at all. However, we came to the conclusion that src_addr isn't actually even used by Anjay and the passed non-NULL pointer comes from the compatibility layer in avs_commons. With this information, we were able to improve our compatibility layer and Anjay was able to connect to the Server immediately.

Our next step was to successfully report values from sensors. In order to do that, we needed to implement a few LwM2M Objects. This time we decided not to use the anjay_codegen.py, because there were only two types of sensors – single-value sensors and three-axis sensors. They have similar resources, when represented as LwM2M Objects, and they use the same API provided by Zephyr OS, so it was possible to create only two object implementations and reuse them to decrease the application size. We strongly recommend this approach if you want to reduce the amount of work required to support sensors in your applications.

The results of our work are available on our GitHub page, as we made the Anjay-Zephyr-client available publicly on Apache 2.0 license. It might come in handy as a starting point for your projects if you want to use LwM2M. The client should be portable between all boards supported by Zephyr, however, some changes related to the hardware may be required.

Kamil Panek
Software Engineer

Recommended posts

back icon
Hello! We’re always open.
Let’s start a conversation.

Marketing Consent Opt In Date:
Marketing Consent Opt In Reason:
Marketing Consent Opt Out Date:
Marketing Consent Opt Out Reason:

Thank you!

Your message has been sent. Our team will contact you as soon as possible.


AVSystem sp. j., Radzikowskiego 47D, Cracow is the controller of your personal data. We will process your personal data to contact you in response to your message. If you agree to a specific communication channel, we can also contact you in the future for marketing purposes. You can withdraw your consent at any time or object to data processing. You have the right to r access your personal data, the right to rectification data, the right to erasure data, the right to demand the restriction of the processing of your personal data and the right to object to the processing of your data. More information about processing of your personal data is available here.

Message Btn

Hello!
Contact us!

This website is using cookies

We use cookies for statistical and marketing purposes and to improve the quality of our services. The information stored in cookies usually allow the identification of a specific device or user’s browser, so they may contain personal data. By continuing to use this website with setting the web browser in a way which alows the use of cookies by the website means your’s consent to the use of cookies. You can change your web browser settings at any time.

More information on the processing of personal data and cookies you can find in our Privacy and cookies policy.

Accept