mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
@ -16,6 +16,17 @@ extern "C"
|
||||
#include "debug.h"
|
||||
#include "LwipIntf.h"
|
||||
|
||||
// wifi_station_hostname is SDK's station(=global) hostname location
|
||||
// - It is never nullptr but wifi_station_get_hostname()
|
||||
// can return nullptr when STA is down
|
||||
// - Because WiFi is started in off mode at boot time,
|
||||
// wifi_station_set/get_hostname() is now no more used
|
||||
// because setting hostname firt does not work anymore
|
||||
// - wifi_station_hostname is overwritten by SDK when wifi is
|
||||
// woken up in WiFi::mode()
|
||||
//
|
||||
extern "C" char* wifi_station_hostname;
|
||||
|
||||
// args | esp order arduino order
|
||||
// ---- + --------- -------------
|
||||
// local_ip | local_ip local_ip
|
||||
@ -66,7 +77,7 @@ bool LwipIntf::ipAddressReorder(const IPAddress& local_ip, const IPAddress& arg1
|
||||
*/
|
||||
String LwipIntf::hostname(void)
|
||||
{
|
||||
return wifi_station_get_hostname();
|
||||
return wifi_station_hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,7 +86,7 @@ String LwipIntf::hostname(void)
|
||||
*/
|
||||
const char* LwipIntf::getHostname(void)
|
||||
{
|
||||
return wifi_station_get_hostname();
|
||||
return wifi_station_hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -136,12 +147,9 @@ bool LwipIntf::hostname(const char* aHostname)
|
||||
DEBUGV("hostname '%s' is not compliant with RFC952\n", aHostname);
|
||||
}
|
||||
|
||||
bool ret = wifi_station_set_hostname(aHostname);
|
||||
if (!ret)
|
||||
{
|
||||
DEBUGV("WiFi.hostname(%s): wifi_station_set_hostname() failed\n", aHostname);
|
||||
return false;
|
||||
}
|
||||
bool ret = true;
|
||||
|
||||
strcpy(wifi_station_hostname, aHostname);
|
||||
|
||||
// now we should inform dhcp server for this change, using lwip_renew()
|
||||
// looping through all existing interface
|
||||
@ -149,7 +157,7 @@ bool LwipIntf::hostname(const char* aHostname)
|
||||
for (netif* intf = netif_list; intf; intf = intf->next)
|
||||
{
|
||||
// unconditionally update all known interfaces
|
||||
intf->hostname = wifi_station_get_hostname();
|
||||
intf->hostname = wifi_station_hostname;
|
||||
|
||||
if (netif_dhcp_data(intf) != nullptr)
|
||||
{
|
||||
|
Reference in New Issue
Block a user