【发布时间】:2022-06-20 00:19:04
【问题描述】:
我正在处理试图通过 Wifi 和以太网连接到 dhcp 服务器的 ESP32 模块 (ESP-IDF)。关键是,我正在尝试获取 DHCP 选项,但我失败了……
我尝试使用 LWIP 和 ESP-NETIF。 (我还要猜XXXX和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");
有没有人有源代码示例显示连接后如何获取选项?
提前谢谢你。
【问题讨论】: