zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.96k stars 6.68k forks source link

HTTP Server dynamic IPs #81008

Open RIPHeisenberg opened 3 weeks ago

RIPHeisenberg commented 3 weeks ago

Hi everyone,

I am currently trying out the Zephyr 3.7 http_server example. It does work fine. I haven't however found out how to assign a dynamic IP address to the Servers properties.

The HTTP_SERVICE_DEFINE() Macro only allows for a dynamic port. As described in the Doc strings.

Would it be possible to change the _host IP address property to a pointer? One could use the http_server_start() and _stop() functions to rerun the socket initialization.

The objective of my current project is to use the Zephyr dhcp api to generate a fitting _host IP and then assign it at runtime. I could write the socket management myself but I really like your HTTP_Server implementation.

Thanks for your interest

jukkar commented 3 weeks ago

You can either leave host as empty "", or as NULL. This was fixed in commit 3949873886a7831f5ba7a1bc02120813dafa35d2

RIPHeisenberg commented 1 week ago

Hi Jukkar, thanks for the responds. Seems as if everything is running smooth now in Zephyr 4.0.0.