'Getting DHCP options using ESP32
I've dealing with an ESP32 module (ESP-IDF) trying to connect via Wifi and ethernet to a dhcp server. The point is, I'm trying to get the DHCP options, but I failed...
I tried using LWIP and also ESP-NETIF. (I have also to guess whats XXXX and YYYY)
// Create an esp_netif pointer to store current interface
esp_netif_t* ifscan = esp_netif_next(NULL);
// Stores the unique interface descriptor, such as "PP1", etc
char ifdesc[7];
ifdesc[6] = 0; // Ensure null terminated string
uint32_t value = 0;
while (ifscan != NULL)
{
esp_netif_get_netif_impl_name(ifscan, ifdesc);
Serial.printf("IF NAME: %s\n", ifdesc);
esp_err_t code = esp_netif_dhcpc_option(ifscan, ESP_NETIF_OP_GET, ESP_NETIF_DOMAIN_NAME_SERVER, XXXX, YYYY);
Serial.printf("RES: %s - OPTION: %s\n", esp_err_to_name(code), XXXXX);
// Get the next interface
ifscan = esp_netif_next(ifscan);
}
Serial.printf("Done listing network interfaces");
Does anyone have an example of sourcecode showing how to get the options after connecting?
Thank you in advance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|