feat: enhance UDPClient initialization with local port binding and add WebServerHandler for HTTP server management
This commit is contained in:
@@ -539,3 +539,23 @@ EventBits_t WifiHandler::wait_for_connection(TickType_t ticks_to_wait) {
|
||||
ticks_to_wait
|
||||
);
|
||||
}
|
||||
|
||||
std::string WifiHandler::get_current_ip() const {
|
||||
esp_netif_t* netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
|
||||
if (!netif) {
|
||||
ESP_LOGW(TAG, "Failed to get netif handle");
|
||||
return "";
|
||||
}
|
||||
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_err_t err = esp_netif_get_ip_info(netif, &ip_info);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Failed to get IP info: %s", esp_err_to_name(err));
|
||||
return "";
|
||||
}
|
||||
|
||||
// Convert IP address to string
|
||||
char ip_str[16];
|
||||
snprintf(ip_str, sizeof(ip_str), IPSTR, IP2STR(&ip_info.ip));
|
||||
return std::string(ip_str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user