tmedicci opened a new pull request, #3543:
URL: https://github.com/apache/nuttx-apps/pull/3543

   ## Summary
   
   Start the mDNS daemon based on the event of getting a new IP address for any 
of the system's network interfaces. This allows DHCP client to trigger the mDNS 
daemon after getting a new IP address, for instance.
   
   ## Impact
   
   Impact on user: Yes. Allow starting the mDNS daemon when a valid IP is 
available.
   
   Impact on build: No.
   
   Impact on hardware: No.
   
   Impact on documentation: No.
   
   Impact on security: No.
   
   Impact on compatibility: No.
   
   ## Testing
   
   Taking `esp32p4-function-ev-board:ethernet` as an example:
   
   ### Building
   
   ```
   make distclean && ./tools/configure.sh -S esp32p4-function-ev-board:ethernet 
&& kconfig-tweak --enable CONFIG_LIB_MDNS && kconfig-tweak --enable 
CONFIG_NETUTILS_MDNS && kconfig-tweak --enable CONFIG_NETUTILS_MDNS_DAEMON && 
kconfig-tweak --enable CONFIG_EXAMPLES_MDNSD && kconfig-tweak --enable 
CONFIG_NET_NETLINK && kconfig-tweak --enable CONFIG_NETLINK_ROUTE && 
kconfig-tweak --enable CONFIG_NET_IGMP && kconfig-tweak --enable 
CONFIG_LIBC_EXECFUNCS && kconfig-tweak --enable CONFIG_SYSTEM_HOSTNAME && 
kconfig-tweak --set-val CONFIG_NETUTILS_MDNS_STACKSIZE 4096 && kconfig-tweak 
--set-str CONFIG_EXAMPLES_MDNS_SERVICE "_http._tcp.local." && kconfig-tweak 
--set-str CONFIG_EXAMPLES_MDNS_SERVICE_PORT "80" && make olddefconfig -s -j && 
make -j
   ```
   
   ### Running
   
   Flash the device with `esptool`:
   
   ```
   esptool.py -p /dev/ttyACM0 write_flash 0x2000 nuttx.bin
   ```
   
   Then, detach the ethernet cable, reset the device, and check the device's 
serial terminal (with `picocom`, for instance).
   
   Then, on NSH, set the hostname and start the `mdnsd_event`:
   
   ```
   nsh> hostname esp32p4
   nsh> mdnsd_event &
   mdnsd_event [8:100]
   nsh> mdnsd_event: waiting for network address event
   ```
   
   Then, attach the ethernet cable in a network that provides a DHCP server 
and, on NuttX, run `renew eth0` to get a new IP address:
   
   ```
   nsh> renew eth0
   mdnsd_event: address set, starting mDNS
   Local IPv4 address: 10.0.10.50
   Opened 1 socket for mDNS service
   Service mDNS: _http._tcp.local.:80
   Hostname: esp32p4
   Sending announce
   ```
   
   ### Results
   
   As soon as a new IP address is set to the `eth0`, the mDNS daemon will 
start. Test it on the host PC:
   
   ```
   $ avahi-browse -r -t _http._tcp
   + enp0s13f0u1u4u4 IPv4 esp32p4                                       Web 
Site             local
   = enp0s13f0u1u4u4 IPv4 esp32p4                                       Web 
Site             local
      hostname = [esp32p4.local]
      address = [10.0.10.50]
      port = [80]
      txt = ["test=1" "other=value"]
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to