-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose netif DNS setting functions #495
base: master
Are you sure you want to change the base?
Conversation
I need this for captive portal use.
I already had a homemade wrapper around this, throwing it into this PR.
@jothan Just to make sure I understand the need for this: In general, the This struct has a variant, So, would you elaborate why do you need to have these APIs as public in the first place? |
I want the DHCP client hostname to contain the device name and a part of the serial number. For the DNS, it is my understanding that the primary DNS of the AP interface is sent out by the DHCP server to clients to use as their DNS. I want the clients to use the ESP32 as DNS server to redirect them via captive portal techniques to the configuration page. Hope that explains my use cases. |
Also, the netif is created by the Wi-Fi calls. Should I create the interface configuration I want and hot-swap the netif in ? |
It does. However it does not explain, why you need mutating operations to achieve this. Namely:
Sure. Just use a Note that the hostname you are setting on the netif anyway only has any use when you use a DHCP configuration, and in no other cases. I.e. using a statically configured IP and hoping that somehow your esp client will be pingable by its hostname is just not possible. For such cases, the only solution is
Assuming your clients use DHCP, they will use whatever DNS the DHCP server sends them. So you need to configure the DNS IPs on the router. Wouldn't a router |
Hot-swapping is one option, but we also have |
I mostly use the DHCP hostname because it makes my devices easy to spot in the DHCP server log and Wi-Fi access point page. I also consider it a courtesy to customers for network admin reasons. I did not know wrap_all existed, I'm going to have a look at it and report back on my use cases. |
Is there a way to grab the STA mac address before using the wrap_all call ? |
Can't recall off the top of my head, but for setting the MAC I think we have a mutating method on |
If you know the base mac address, its always the same schema. STA is always +0 offset. |
Ok, so I'm getting the default AP netif config like this: let mut ap_cfg = NetifConfiguration::wifi_default_router(); Nowhere in that struct do I have a way to get the IP that will be assigned to the ESP32 SoftAp. I would like to fill https://docs.esp-rs.org/esp-idf-svc/esp_idf_svc/ipv4/struct.RouterConfiguration.html with this IP. |
Unless that IP is subnet.gateway ???? |
Ok, so I managed to do what I need to do using the mainline esp-idf-svc. I did the manual chain with configuration of going from Driver to AsyncWifi, which is non-obvious but got me what I needed. I also managed to grab the STA MAC from WifiDriver in that chain. Should we close this PR then ? |
Let me think about this overnight. Not sure - would it work in all cases? |
I'm using this to make a captive portal using the DNS method (edge_captive made it really simple).