Skip to content

Commit 58966ec

Browse files
committed
Fix WiFi::setHostname
1 parent 0e8096c commit 58966ec

File tree

4 files changed

+2
-37
lines changed

4 files changed

+2
-37
lines changed

libraries/WiFi/src/WiFiGeneric.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ esp_err_t WiFiGenericClass::_eventCallback(arduino_event_t *event)
800800
} else if(event->event_id == ARDUINO_EVENT_WIFI_STA_START) {
801801
WiFiSTAClass::_setStatus(WL_DISCONNECTED);
802802
setStatusBits(STA_STARTED_BIT);
803-
tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, WiFiSTAClass::_hostname.c_str());
804803
if(esp_wifi_set_ps(_sleepEnabled) != ESP_OK){
805804
log_e("esp_wifi_set_ps failed");
806805
}

libraries/WiFi/src/WiFiGeneric.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ class WiFiGenericClass
172172

173173
static const char * getHostname();
174174
static bool setHostname(const char * hostname);
175+
static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
175176

176177
static esp_err_t _eventCallback(arduino_event_t *event);
177178

libraries/WiFi/src/WiFiSTA.cpp

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ static void wifi_sta_config(wifi_config_t * wifi_config, const char * ssid=NULL,
104104

105105
bool WiFiSTAClass::_autoReconnect = true;
106106
bool WiFiSTAClass::_useStaticIp = false;
107-
String WiFiSTAClass::_hostname = "esp32-arduino";
108107

109108
static wl_status_t _sta_status = WL_NO_SHIELD;
110109
static EventGroupHandle_t _sta_status_group = NULL;
@@ -614,36 +613,6 @@ int8_t WiFiSTAClass::RSSI(void)
614613
return 0;
615614
}
616615

617-
/**
618-
* Get the station interface Host name.
619-
* @return char array hostname
620-
*/
621-
const char * WiFiSTAClass::getHostname()
622-
{
623-
const char * hostname = NULL;
624-
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
625-
return hostname;
626-
}
627-
if(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_STA, &hostname)){
628-
return NULL;
629-
}
630-
return hostname;
631-
}
632-
633-
/**
634-
* Set the station interface Host name.
635-
* @param hostname pointer to const string
636-
* @return true on success
637-
*/
638-
bool WiFiSTAClass::setHostname(const char * hostname)
639-
{
640-
_hostname = hostname;
641-
if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){
642-
return false;
643-
}
644-
return tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, hostname) == 0;
645-
}
646-
647616
/**
648617
* Enable IPv6 on the station interface.
649618
* @return true on success

libraries/WiFi/src/WiFiSTA.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class WiFiSTAClass
7575
bool enableIpV6();
7676
IPv6Address localIPv6();
7777

78-
const char * getHostname();
79-
bool setHostname(const char * hostname);
80-
bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
81-
8278
// STA WiFi info
8379
static wl_status_t status();
8480
String SSID() const;
@@ -90,7 +86,7 @@ class WiFiSTAClass
9086
int8_t RSSI();
9187

9288
static void _setStatus(wl_status_t status);
93-
static String _hostname;
89+
9490
protected:
9591
static bool _useStaticIp;
9692
static bool _autoReconnect;

0 commit comments

Comments
 (0)