Auto discovery esp32 IP connected to WiFi

tsctrl
Posts: 30
Joined: Tue Dec 08, 2020 1:37 pm

Auto discovery esp32 IP connected to WiFi

Postby tsctrl » Thu Dec 30, 2021 7:08 pm

I have issue with auto ip discovery for esp32 device connected to wifi.

i am not using mDNS as i am not able to use the service reliably on discovering the device in network. I guess there is some limitation on devices that could discover the esp mDNS and require some configuration on the client devices to able to discover the device.

i am also not using fix ip for esp32 as i did not have control on wifi network dns and gateway that the esp will be connecting.

the option i have is to store custom ip for user to insert in the esp before the wifi initialize and the device that want to discover will require the same ip to be able to connect. this approach require user to be familiar with network configuration which will require overhead on usability and complexity.

is there any way i could set the last device 3 STA digit ip without using a static ip. something like STAIP(AUTO,AUTO,AUTO,128)
or is the static configuration will only static the last 3 digit ip number and the rest to follow network router configuration? since network router will have specific gateway.
with the above capabilities at least i could fixed the last 3 digits ip with the other ip is from the router depending on gateway configuration. so client will also have the fix last 3 digit ip precoded and the rest is follow gateway ip so no configuration required from the user. the approach is to chop last 3 digits device ip with the fix ip set in esp. so that was the prconfigured esp sta ip.

of cause it will not work if the last 3 digit ip has conflict or the router has auto dhcp range. but that rare cases for dynamic ip allocated by the router and if this case happens mean the admin of the network can configure the router.

for now on dynamic ip configuration for wifi sta config. the esp will have random ip assigned by the router.

i hope there will be a solution or existing approach for this scenario and someone help to answer those 2 question. thank you for your time to read this queries and answer in advance.

thanks!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Auto discovery esp32 IP connected to WiFi

Postby WiFive » Fri Dec 31, 2021 2:50 pm

Doesn't sound like a good idea. Would suggest you try something else like

- get mdns working
- use nbns/ssdp/upnp
- use a custom device discovery broadcast protocol over udp
- use a cloud server
- use Mac/IP address scanning
- tell the user the IP during onboarding (ap+sta mode or bluetooth)

tsctrl
Posts: 30
Joined: Tue Dec 08, 2020 1:37 pm

Re: Auto discovery esp32 IP connected to WiFi

Postby tsctrl » Sun Jan 16, 2022 7:43 am

hi WiFive, thanks for the reply,

- get mdns working
this is not an option as configuration need to be done on client side. mdns last check only discoverable on mac os and linux, not android and windows clients.
- use nbns/ssdp/upnp
this looks to be more complex but i will try to understand the above to see what feasible.
- use a custom device discovery broadcast protocol over udp
this look promising, i not sure how udp can help? is it broadcasting a signal every 5second to network to see what client ip will reply?
- use a cloud server
this require internet. need to have it works on local network. since the cloud server might not know if the ip is a private or public ips. the esp need to register it self to the cloud and the client need to know about it. i not sure how that will work without user settings.
- use Mac/IP address scanning
this will require mac to be registered in client. it is possible to scan ips in network and check each if it will reply. but this is require quite large delay. probably will have to filter by device name, not sure how.
- tell the user the IP during onboarding (ap+sta mode or bluetooth)
this is what is the issue, where user know the ips and need to manually register to the client to connect. it takes manual invocation and quite a bit learning to users.

i guess ip scanning will be handled by client which is not resource consuming to the esp with addition of name filtering could be a good solution. where such udp broadcast will need additional resource to execute in esp.

thats is what i understand. hope you could feedback, help to correct and suggest the approach you recommend.

thanks!

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: Auto discovery esp32 IP connected to WiFi

Postby WiFive » Sun Jan 16, 2022 9:46 pm

tsctrl wrote:
Sun Jan 16, 2022 7:43 am
- get mdns working
this is not an option as configuration need to be done on client side. mdns last check only discoverable on mac os and linux, not android and windows clients.
Mdns can work on all platforms just not in all web browsers. If you are using a custom app it can work.
tsctrl wrote:
Sun Jan 16, 2022 7:43 am
- use a custom device discovery broadcast protocol over udp
this look promising, i not sure how udp can help? is it broadcasting a signal every 5second to network to see what client ip will reply?
Yes both client and server can broadcast and listen on the same port to find each other, similar to mdns.
tsctrl wrote:
Sun Jan 16, 2022 7:43 am
- use Mac/IP address scanning
this will require mac to be registered in client. it is possible to scan ips in network and check each if it will reply. but this is require quite large delay. probably will have to filter by device name, not sure how.
Yes, filter based on Mac prefix. It probably is not that slow unless it is a large network.

You can combine the approaches to make sure it will cover all cases.

Who is online

Users browsing this forum: Google [Bot] and 126 guests