@@ -16,6 +16,17 @@ extern "C"
16
16
#include " debug.h"
17
17
#include " LwipIntf.h"
18
18
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
+
19
30
// args | esp order arduino order
20
31
// ---- + --------- -------------
21
32
// local_ip | local_ip local_ip
@@ -66,7 +77,7 @@ bool LwipIntf::ipAddressReorder(const IPAddress& local_ip, const IPAddress& arg1
66
77
*/
67
78
String LwipIntf::hostname (void )
68
79
{
69
- return wifi_station_get_hostname () ;
80
+ return wifi_station_hostname ;
70
81
}
71
82
72
83
/* *
@@ -75,7 +86,7 @@ String LwipIntf::hostname(void)
75
86
*/
76
87
const char * LwipIntf::getHostname (void )
77
88
{
78
- return wifi_station_get_hostname () ;
89
+ return wifi_station_hostname ;
79
90
}
80
91
81
92
/* *
@@ -136,20 +147,17 @@ bool LwipIntf::hostname(const char* aHostname)
136
147
DEBUGV (" hostname '%s' is not compliant with RFC952\n " , aHostname);
137
148
}
138
149
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);
145
153
146
154
// now we should inform dhcp server for this change, using lwip_renew()
147
155
// looping through all existing interface
148
156
// harmless for AP, also compatible with ethernet adapters (to come)
149
157
for (netif* intf = netif_list; intf; intf = intf->next )
150
158
{
151
159
// unconditionally update all known interfaces
152
- intf->hostname = wifi_station_get_hostname () ;
160
+ intf->hostname = wifi_station_hostname ;
153
161
154
162
if (netif_dhcp_data (intf) != nullptr )
155
163
{
0 commit comments