Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix hostname management#8626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
d-a-v merged 7 commits intoesp8266:masterfromd-a-v:hostname
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletionscores/esp8266/LwipIntf.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -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
Expand DownExpand Up@@ -66,7 +77,7 @@ bool LwipIntf::ipAddressReorder(const IPAddress& local_ip, const IPAddress& arg1
*/
String LwipIntf::hostname(void)
{
returnwifi_station_get_hostname();
returnwifi_station_hostname;
}

/**
Expand All@@ -75,7 +86,7 @@ String LwipIntf::hostname(void)
*/
const char* LwipIntf::getHostname(void)
{
returnwifi_station_get_hostname();
returnwifi_station_hostname;
}

/**
Expand DownExpand Up@@ -136,20 +147,17 @@ 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
// 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;

if (netif_dhcp_data(intf) != nullptr)
{
Expand Down
9 changes: 9 additions & 0 deletionslibraries/ESP8266WiFi/src/ESP8266WiFiGeneric.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,6 +49,9 @@ extern "C" {
#include "debug.h"
#include "include/WiFiState.h"

// see comments on wifi_station_hostname in LwipIntf.cpp
extern "C" char* wifi_station_hostname; // sdk's hostname location

// -----------------------------------------------------------------------------------------------------------------------
// ------------------------------------------------- Generic WiFi function -----------------------------------------------
// -----------------------------------------------------------------------------------------------------------------------
Expand DownExpand Up@@ -419,7 +422,10 @@ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m) {
return true;
}

char backup_hostname [33] { 0 }; // hostname is 32 chars long (RFC)

if (m != WIFI_OFF && wifi_fpm_get_sleep_type() != NONE_SLEEP_T) {
memcpy(backup_hostname, wifi_station_hostname, sizeof(backup_hostname));
// wifi starts asleep by default
wifi_fpm_do_wakeup();
wifi_fpm_close();
Expand DownExpand Up@@ -452,6 +458,9 @@ bool ESP8266WiFiGenericClass::mode(WiFiMode_t m) {
}
}

if (backup_hostname[0])
memcpy(wifi_station_hostname, backup_hostname, sizeof(backup_hostname));

return ret;
}

Expand Down
8 changes: 5 additions & 3 deletionstests/host/common/user_interface.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -309,10 +309,12 @@ extern "C"
return wifi_station_get_config(config);
}

char wifi_station_get_hostname_str[128];
const char* wifi_station_get_hostname(void)
extern "C" char* wifi_station_hostname; // exists in nonosdk
char wifi_station_hostname_str[33] { "esposix" };
char* wifi_station_hostname = wifi_station_hostname_str;
const char* wifi_station_get_hostname(void)
{
returnstrcpy(wifi_station_get_hostname_str, "esposix");
returnwifi_station_hostname;
}

bool wifi_station_get_reconnect_policy()
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp