Resolving Host on mDNS

Hi. I have a mDNS set up in a network on a Linux machine. I want the photon to get the IP address of the Linux machine using the hostname resolver as it is on the ESP32. However, I couldn’t find anything on that topic. Do we have a support for it right now or we’ll have to do a hack?
Thank You.

Anyone Anything?
I can see that there is a function called UDP.joinMulticast() but I am getting a compilation error saying UDP has no function named joinMulticast
If this does work, can I use this function to interact with the mDNS and acquire the IPAddress of another device?

If you could quote the entire error message that would make more sense since there is a UDP.joinMulticast() function - you just need to provide it with the correct parameters and the error message would probably tell you where your provided parameters don't meat the requirements, or you are targeting a really old device OS version :wink:

https://docs.particle.io/reference/device-os/firmware/photon/#joinmulticast-

src/application.cpp:237:6: error: ‘class UDP’ has no member named ‘joinMuticast’
udp.joinMuticast(multicastAddress);

This is the error message I am getting. I have referred the library on github for the correct parameters. The OS I am working with is 1.1.0-rc.2
And as you may know there is not much pre configuration need to be done for this function. I have initialized the udp object with udp.begin() before this call using the mDNS port 5353.

And what about this??

I have also found some support for resolving host in the lwIP library under the mdns.c
However, I couldn't find anything on how to use it. I was following the instructions given in the file but I got lost somewhere around the third step. Also, there are no comments to say what is what. I would really appreciate if you can help me understand those instructions so that I can check if that works.

I cannot replicat that error with 1.1.0-rc.2 (or anything 0.4.5 and greater) neither with a simple test project that only uses the code featured in the reference docs example for UDP.joinMulticast() nor with the example that comes with the MDNS library.

I'd advise you to double check the target you've set in your IDE.

Not sure about that. I'm not positive that mDNS provides a way to request the IP address without knowing the host name (and the host needs to have a mDNS service running too).

It is set to 1.1.0-rc.2 and I'm myself not able to understand the reason for the error.

Well, I'm not sure about the request per se as well if you meant that literally. I just mean to acquire it somehow by searching the multicast pool. And I guess it would require to send some sort of query which will return the details of the concerned mDNS domain.

Can you post a screenshot - I'm not easily convinced :wink:

BTW, why still using a RC when there already is an official releas for 1.1.0 and even some more recent official releases up to 1.2.1?


I am using the make compiler set up on a Linux desktop to do the compilation so I couldn’t show you the screenshot from the web IDE. This is a snippet from my console.

I am using the RC because we didn’t get the time to upgrade it to the latest version.
Is it possible that the RC-2 has some bug due to which this is happening?

The device OS on the device is not necessarily the device OS you are targeting.
Just build a dummy project with that make command you are trying to use for the mDNS project and run particle binary inspect <yourFirmware.bin> to see what the actual target is.


It seems to be getting compiled for 1.1.0

Strange!
How about compiling that on your local build and Web IDE both targeting 1.1.0-rc.1 (1101 would suggest rc.1 IMO)

UDP Udp;

int remotePort = 1024;
IPAddress multicastAddress(224,0,0,0);

void setup() {
  Udp.begin(remotePort);
  Udp.joinMulticast(multicastAddress);
}

void loop () { 
}

If Web IDE works (as it does for me) but not your local build, I’d suspect there might be something wrong with your local toolchain.

Before trying that, can you tell if it will help me in resolving the host IP on the mDNS? Will it join the same pool that belongs to mDNS if I enter the IP of the mDNS?

I can’t tell you that as it also depends on the other devices in your network.
There is not really a “pool” where devices “dump” their data into and others would pull that information from.
Roughly speaking mDNS just provides a standardised channel and format for participants to shout out their data or requests for others to reply. The responses have to be caught there and then as they are not centrally buffered.

Well, as this step was taking a bit longer than I expected, I am currently trying to reuse an ESP8266 library on photon and the library can’t find the matching UDP functions it needs. I tried looking through the udp library on github but I was overwhelmed by the enormour number of udp libraries scattered throughout. Can you tell me which UDP library does the photon use?

When you are building with your own make command on a local toolchaing, you should know it doesn’t use a UDP library but the device OS brings its own baked-in implementation
https://github.com/particle-iot/device-os/blob/develop/wiring/src/spark_wiring_udp.cpp

How can I use the lwIP library/functions in my application code. I see that there is a mDNS Resolver type of feature there. I’m not sure why that is not available to use!

While reusing the ESP mDNS resolver in photon, I’m stuck at a point where there is a function in Arduino named beginMulticast() and beginPacketMulticast() which is not present in Particle. I am guess this is the only part that I need right now to make this thing work but I’m not able to translate those functions for photon. The ESP Library

When you join a multicast channel and then just write a packet to that multicast channel you shouldn’t need any dedicated beginPacketMulticast() or beginMulticast().

Just try udp.sendPacket(buf, len, multicastIP, multicastPort) (multicast address:port being being 224.0.0.251:5353) instead.

That was the first thing I did, but instead of using beginPacket() instead of sendPacket() as it was closer to the original function in the ESP library. However, it didn’t work. And I’m not able to use the sendPacket() because that is the next call in the mDNS resolver library using the query structure.