esp-idf: Assign specific IPs?

Dumbledore
Posts: 17
Joined: Thu Oct 10, 2019 7:55 pm

esp-idf: Assign specific IPs?

Postby Dumbledore » Sat Apr 18, 2020 4:13 pm

Hi!

I have one ESP32 board working as an Access Point, several others as stations connecting to this AP.
Is there a way to assign them specific IPs? E.g., I have a list of MACs from the stations and whenever a specific board joins the WiFi, I'd like to assign it an IP corresponding to its index in this list, so that they're "ordered" in the same way for easier processing.

I'm using esp-idf. I wasn't able to find an API to assign IPs, would be cool if you could help me out.

Thanks in advance.

edit: alternatively, is the AP board able to read an IP (inside the event handler or something) and the MAC to create some sort of IP/MAC dictionary?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: esp-idf: Assign specific IPs?

Postby PeterR » Tue Apr 21, 2020 5:58 pm

I bet you could peek into the DHCP server code or similar, however....

mDNS or multicast are the standard approaches. mDNS would be the better choice if you have an mDNS library - which you do!
Your stations create an mDNS advert containing a text record which holds their unique identifier (be that MAC, name, count etc).
Your access point may then use mDNS to check who is out there.

I have used mDNS on ESP32 extensively wired without issue.
& I also believe that IDF CAN should be fixed.

Who is online

Users browsing this forum: markkuk and 302 guests