jasoncoon / esp8266-fastled-webserver

GNU General Public License v3.0
714 stars 359 forks source link

How can I identify different devices in a network without their IPs? #148

Closed jemd15 closed 2 years ago

jemd15 commented 4 years ago

I put you in context. I have 3 different devices in my wifi and I want to make a single general client to manage everything, but I can't identify which device I'm configuring without seeing it, because I only see many IPs.

Do you have a solution to identify devices in REST services? I don't want to set static IPs for them.

jasoncoon commented 4 years ago

Yes, I actually just solved this problem recently!

For my RGB LED Micro Quadrotor Race Gate installation, each gate had it's own ESP8266 controller. I needed a quick and easy way to manage multiple controllers at once. I implemented a new 'multi' web page. You put in start and end ip addresses, click a discover button, and it sends a /all REST request to each address with a two second timeout. If the controller responds with a valid JSON response, it adds it to the list. I also added a name field to the sketch, and each controller provides a unique name using a portion of its MAC address.

Here's the code, let me know if you have any other questions: https://github.com/jasoncoon/esp8266-fastled-webserver/blob/racegate/data/js/multi.js#L60

jemd15 commented 4 years ago

Good to know that you worked already on it. Now, I cloned the repo and changed to racegate branch, but when I try to compile, I get this error message:

error.txt

jasoncoon commented 4 years ago

I see you're using Arduino:1.9.0-beta. It compiles fine for me on 1.8.9 and 1.8.10 (current latest version).

jasoncoon commented 4 years ago

I get the same errors using Arduino 1.9.0 beta. Looks like the code with need rearranged, or a bunch of stuff will need predefined.

jemd15 commented 4 years ago

Yes, I'm using the beta version because it works on Mac OS Catalina. Well, it looks that I'll have to use the current version on another OS to work with this code. Thanks for the help!!

jasoncoon commented 4 years ago

It's been a while, but I just added a new "ping" optional, opt-in feature, and I would appreciate your thoughts on it: https://github.com/jasoncoon/esp8266-fastled-webserver/blob/main/Ping.h

Assuming your device is on a wi-fi network with internet access, it pings my server with it's local IP address, device name, etc. You can go to https://discover.evilgeniuslabs.org and see a list of devices on the same network, with a link to open the device.

As I noted in the comments in that file, I added it because I needed it, but made it opt-in in case anyone had any privacy concerns with it.

jemd15 commented 4 years ago

First of all, thanks for letting me know about this new feature. It's always a pleasure to be helpful in this project. I used it and worked pretty well. Maybe I'd put an on/off switch for each connected device but in general, this looks good.

image

henrygab commented 2 years ago

Would the use of mDNS to scan for your devices work? It avoids reliance on the internet, and seems to be more common nowadays.

(I'm closing this issue due to age, but feel free to re-open if you add information)