Hostname does not show up in network scans

I want to be able to use a name hostname.local when trying to TCP/IP connect to a Photon within a Wireless LAN.

I understand that the Photon’s hostname is by default its device id, or as set by WiFi.setHostname().

Another way of putting this is: I want to ping hostname.local

Using a common network scanning tool such as Fing, the device shows up with DHCP name of “Generic” instead of the configured hostname.

This is a common use case and have seen others wanting to perform this without having to resort to fixed IP’s.

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.

This is where Bonjoure and/or mDNS would be used.
There are some discussions about that in the forum.

1 Like

Thanks @ScruffR, came to that conclusion once I realised I was going down the wrong track.

Can you recommend which way to go? Would like to have the simplest and lowest overhead solution (like everybody else).

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).

Yet to investigate, but the client machine in this case is another Photon…

@ScruffR, for the record, have good news.

  • fixed the OpenWRT router issue which was not serving DHCP properly when there was no WAN connection (can you believe it?)
  • the router is running the dnsmasq DHCP service
  • Used WiFi.setHostname() to set a hostname, say DEVICE1 on a device running TCPServer
  • Another Photon using TCPClient could then access DEVICE1 using the name DEVICE1.lan
  • Conclusion: no need for fixed IP’s!

Case closed!

3 Likes

Hi @UMD @ScruffR

I am experiencing a similar issue.

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.

Any workaround to get my need working?

It’s likely your company’s network policies that prevent the required packets (UDP multicast) to traverse.

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.

Hi @ScruffR @UMD

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.)

Thanks

@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?

1 Like

Hi @UMD

I tried another workaround.

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.

I hope this will work fine without any issues!?

(Have to try UDP method also)

@iotbang, good workaround, but pity you could not use the hostname.

@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.

RARP approach is working fine so far!

Marking Case - Closed!

Thanks @UMD, @ScruffR

1 Like