Skip to content

Commit

Permalink
V2.x compatible to ESP32 Core 2.x (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathertel authored Jun 18, 2024
1 parent c4e4919 commit ee4d42c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/ESP32SSDP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,22 @@ void SSDPClass::end() {
}

IPAddress SSDPClass::localIP() {

#if (ESP_ARDUINO_VERSION_MAJOR < 3)
// Arduino ESP32 2.x board version
tcpip_adapter_ip_info_t ip;
if (WiFi.getMode() == WIFI_STA) {
if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip)) {
return IPAddress();
}
} else if (WiFi.getMode() == WIFI_OFF) {
if (tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)) {
return IPAddress();
}
}

#else
// Arduino ESP32 3.x board version
esp_netif_ip_info_t ip;
if (WiFi.getMode() == WIFI_STA) {
if (esp_netif_get_ip_info(get_esp_interface_netif(ESP_IF_WIFI_STA), &ip)) {
Expand All @@ -163,9 +179,13 @@ IPAddress SSDPClass::localIP() {
return IPAddress();
}
}

#endif

return IPAddress(ip.ip.addr);
}


void SSDPClass::setUUID(const char *uuid, bool rootonly) {
// no sanity check is done - TBD
if (rootonly) {
Expand Down

0 comments on commit ee4d42c

Please sign in to comment.