Benjamin Cabé

Zephyr Weekly Update – HTTP Server FTW! 🥳

Zephyr Weekly Update - May 3, 2024

Zephyr Weekly Update - May 3, 2024

Happy Friday, and welcome back for a new Zephyr Weekly Update! Before diving into some of the additions and notable updates from this week, I wanted to mention that the recordings of all the presentations from the Zephyr Developer Summit 2024 are now available on the YouTube channel of the Zephyr Project.

There were some truly great sessions (and speakers!) and there is a very good chance that you will want to catch up and watch all of them if you didn’t have a chance to attend in person! 😀

HTTP Server

This week’s big update is the addition of a long awaited HTTP server library. It supports HTTP/1.1 as well as HTTP/2, with or without TLS, and WebSocket support should be coming shortly! This has been a multi-month effort that started last year as a Google Summer of Code project from Emna Rekik.

Similar to the socket and CoAP services, adding new HTTP resources can easily be done, with very little overhead, not so differently from how you would do it in a higher-level language like Python or JavaScript!

struct http_resource_detail_static index_html_gz_resource_detail = {
	.common = {
			.type = HTTP_RESOURCE_TYPE_STATIC,
			.bitmask_of_supported_http_methods = BIT(HTTP_GET),
			.content_encoding = "gzip",
		},
	.static_data = index_html_gz,
	.static_data_len = sizeof(index_html_gz),
};

HTTP_RESOURCE_DEFINE(index_html_gz_resource, test_http_service, "/",
		     &index_html_gz_resource_detail);

I highly recommend you dive into the new code sample that will tell you a lot more about the various capabilities of this new service, including how to configure it, or even to profile it.

Power Management for dummies using the Zephyr shell

You’ve heard me praise the Zephyr shell many times before. It is an awesome resource to quickly troubleshoot your system and interact with all your peripherals and subsystems without having to write any code.

A new pm shell module has been introduced to let you interact with the power management subsystem using simple commands. Assuming that power management is indeed enabled in your Zephyr application, you can now do things like pm suspend mydevice to quickly suspend a device.

What’s more, device list, which might be one of the most useful commands in the Zephyr now also gives you feedback regarding the actual PM mode of all the devices in your system:

uart:~$ device list
devices:
- i2c@40003000 (active)
- buttons (active, usage=1)
- leds (READY)

In this example, leds is a device that does not support PM, i2c supports PM with manual suspend and resume actions and is currently active, and buttons supports runtime PM, is currently active and “used” by one user.

As part of introducing all these great commands, Fabio has also added a new callback that a shell module might implement to make tab-completion for device names smarter. In the context of the new pm shell command mentioned before, it means that only devices that do support power management will be suggested when you hit TAB!

Please check out PR #72037 and update your shell modules accordingly 🙂

Boards & SoCs

New boards:

Drivers

Miscellaneous


A big thank you to the 9 individuals who had their first pull request accepted this week, 💙 🙌: @swift-tk, @DeHess, @dalprahcd, @0x6e, @fgihl, @bogdanm, @tychofrei02, @JefersonFernando, and @kail.

As always, I very much welcome your thoughts and feedback in the comments below!

If you enjoyed this article, don’t forget to subscribe to this blog to be notified of upcoming publications! And of course, you can also always find me on Twitter and Mastodon.

Catch up on all previous issues of the Zephyr Weekly Update:

Exit mobile version