Am closing this case - as I have since learnt that the hostname is sent the DHCP server in the broadcast when it asks for an IP but has no other function other than being put into a table in the DHCP server. So, one can’t use it for pinging.
I haven’t actually used mDNS since I have all my home devices set up with static routes and port forwarding. But the MDNS library seems to be the way to go.
And you’ll need the Bonjoure service running on your client machine(s).
My hostname is given “photon1”. If I create a hotspot in my windows laptop and scan for devices in advanced ip scanner, name will be listed “photon1.mshome.net”. I can ping directly using it.
If I connect my photon to common office wifi and do ip scan, there is no hostname it is just IP address instead of a name in the name column.
My need is to ping using hostname. With windows hotspot, I am able to do that, but in general case, I am unable.
To confirm that, I created a hotspot on my mobile phone and did IP scan. In this case also, there is no host name for photon, instead IP address was given as hostname.
At the same time, my laptop’s host name is always getting listed, and tcp/ping is working out.
Any specific reason photon host name is not getting listed.?
Your laptop is probably running some sort of service (e.g. Bonjoure) that knows how to interpret mDNS packets while your phone probably hasn’t (unless it’s an iPhone - I think).
All I can think of @iotbang is to concentrate on the DHCP service sitting on the network of interest (in this case, your office WiFi).
What hostname is given to your Windows laptop when you connect it to the office WiFi?
Can you login to the device that is running the DHCP service? If so, it should enable you to set a name for your photon in the DHCP service via the browser.
My move was to make the local connection a generalized one, without touching the DHCP part of the router, as I will not be able to do it always.
Except for photon, all raspberry pi’s and laptops are getting listed with respective hostnames inside the network(Even while I used android phone hotspot or office wifi).
Right now I can send back and forth data between laptop and photon since I know the local IP of the photon.
Another way was getting the IP through hostname, or RARP of mac ID, so I can hand over my photon-based-device to anyone. The RARP seems to be complex as my laptop TCP client is coded in C.
Any method to get the photon IP in a generalized manner?
(I tried wifi listening mode - softAP, but I was restricted to give wifi credentials through port 80. I dropped the method as my laptop will be offline once I connect it to a listening photon.)
@iotbang, I know exactly the issues you are having - you want to be able to have photon’s communicating on an intranet without having to configure anything.
The fact that all other devices on your network have a hostname is pointing to an issue with the Photon’s DeviceOS. Not sure how you would get that resolved without DeviceOS developers becoming interested in solving it.
Here are some other work around ideas that might work for you:
Do you have connectivity back to the Particle Cloud? If so, you could publish your IP and pick that up by whatever needs to know about it.
Perhaps you could use UDP to announce your IP to other devices interested in it?
I am currently getting the IP using reverse ARP. I am running arp -a command from my C code, and getting the IP corresponding to photon’s mac id through grep. It worked out. I am able to make seamless connections.
@UMD True!
Getting it through hostname was much easier.
But even if I find a solution around hostname, I was not sure would that be a generalized approach, since I came to know that allocating a hostname by DHCP is not a standard protocol or a mandatory thing.