Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
manage hostname with sdk string
  • Loading branch information
d-a-v committed Jul 4, 2022
commit 154a41bef15e48ea9f2fcedd9a81596af53bc605
15 changes: 12 additions & 3 deletions cores/esp8266/LwipIntf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ extern "C"
#include "debug.h"
#include "LwipIntf.h"

extern "C" char* wifi_station_hostname; // sdk's hostname location
extern "C" char* wifi_station_default_hostname; // sdk's hostname location

// args | esp order arduino order
// ---- + --------- -------------
// local_ip | local_ip local_ip
Expand Down Expand Up @@ -66,7 +69,7 @@ bool LwipIntf::ipAddressReorder(const IPAddress& local_ip, const IPAddress& arg1
*/
String LwipIntf::hostname(void)
{
return wifi_station_get_hostname();
return wifi_station_hostname; //wifi_station_get_hostname();
}

/**
Expand All @@ -75,7 +78,7 @@ String LwipIntf::hostname(void)
*/
const char* LwipIntf::getHostname(void)
{
return wifi_station_get_hostname();
return wifi_station_hostname; //wifi_station_get_hostname();
}

/**
Expand Down Expand Up @@ -136,20 +139,26 @@ bool LwipIntf::hostname(const char* aHostname)
DEBUGV("hostname '%s' is not compliant with RFC952\n", aHostname);
}

#if 0
bool ret = wifi_station_set_hostname(aHostname);
if (!ret)
{
DEBUGV("WiFi.hostname(%s): wifi_station_set_hostname() failed\n", aHostname);
return false;
}
#else
bool ret = true;

strcpy(wifi_station_hostname, aHostname);
strcpy(wifi_station_default_hostname, aHostname);
#endif
// now we should inform dhcp server for this change, using lwip_renew()
// looping through all existing interface
// harmless for AP, also compatible with ethernet adapters (to come)
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; //wifi_station_get_hostname();

if (netif_dhcp_data(intf) != nullptr)
{
Expand Down