D'Oh!I could write my own code to issue an 'mDNS' lookup packet, handle the reply
Seems I got slapped for being a smart alec and being able to do that.
As 'SirFico' notes; it does work. I just walked myself into another Circle of Hell and only belatedly realised that.
Thanks for that anyway, it is useful information, would have pointed me in the right direction if one of the sleep pixies hadn't been working overtime and whispered in my ear.
MicroPython supposedly supports 'mDNS' but that doesn't actually work, has flawed behaviour; if you try and 'ping PicoW_hostname.local' from a Pi or other host it simply doesn't resolve it. To make it work you need to write your own 'mDNS' server for the Pico W and also need to turn off support for the internal 'mDNS' server in 'lwipopts.h', then rebuild the MicroPython firmware.
And, yes, you can probably tell where this is going; turn that off and 'getaddrinfo' on the Pico W can no longer resolve '.local' names. Turn it back on and it works just fine. Probably why no one else reported that not working or being problematic.
So fundamentally I'm stuck between a rock and a hard place - if I want to be able to ping a Pico W or identify it from a Pi or other host using "PicoW_hostname.local" I need to turn the internal server off. If I want to identify a Pi from a Pico W using 'Pi_hostname.local' I need to turn the internal server on. If I need to do both I'm straight out of luck.
But then a feeling of Deja Vu came over me and, after a bit of digging, I rediscovered my hack to have the internal server actually use a Pico W hostname - viewtopic.php?p=2214096#p2214096
Time to see if that works, can handle '.local' in both directions. And, if it does, I might look at some better way of setting the hostname automatically rather than manually.
Statistics: Posted by hippy — Tue Jul 23, 2024 2:56 pm