@@ -16,6 +16,17 @@ extern "C"
1616#include " debug.h"
1717#include " LwipIntf.h"
1818
19+ // wifi_station_hostname is SDK's station(=global) hostname location
20+ // - It is never nullptr but wifi_station_get_hostname()
21+ // can return nullptr when STA is down
22+ // - Because WiFi is started in off mode at boot time,
23+ // wifi_station_set/get_hostname() is now no more used
24+ // because setting hostname firt does not work anymore
25+ // - wifi_station_hostname is overwritten by SDK when wifi is
26+ // woken up in WiFi::mode()
27+ //
28+ extern " C" char * wifi_station_hostname;
29+
1930// args | esp order arduino order
2031// ---- + --------- -------------
2132// local_ip | local_ip local_ip
@@ -66,7 +77,7 @@ bool LwipIntf::ipAddressReorder(const IPAddress& local_ip, const IPAddress& arg1
6677*/
6778String LwipIntf::hostname (void )
6879{
69- return wifi_station_get_hostname () ;
80+ return wifi_station_hostname ;
7081}
7182
7283/* *
@@ -75,7 +86,7 @@ String LwipIntf::hostname(void)
7586*/
7687const char * LwipIntf::getHostname (void )
7788{
78- return wifi_station_get_hostname () ;
89+ return wifi_station_hostname ;
7990}
8091
8192/* *
@@ -136,20 +147,17 @@ bool LwipIntf::hostname(const char* aHostname)
136147 DEBUGV (" hostname '%s' is not compliant with RFC952\n " , aHostname);
137148 }
138149
139- bool ret = wifi_station_set_hostname (aHostname);
140- if (!ret)
141- {
142- DEBUGV (" WiFi.hostname(%s): wifi_station_set_hostname() failed\n " , aHostname);
143- return false ;
144- }
150+ bool ret = true ;
151+
152+ strcpy (wifi_station_hostname, aHostname);
145153
146154 // now we should inform dhcp server for this change, using lwip_renew()
147155 // looping through all existing interface
148156 // harmless for AP, also compatible with ethernet adapters (to come)
149157 for (netif* intf = netif_list; intf; intf = intf->next )
150158 {
151159 // unconditionally update all known interfaces
152- intf->hostname = wifi_station_get_hostname () ;
160+ intf->hostname = wifi_station_hostname ;
153161
154162 if (netif_dhcp_data (intf) != nullptr )
155163 {
0 commit comments