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

networking - move setHostname to base class SocketWrapper#986

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
pennam merged 1 commit intoarduino:mainfromJAndrassy:net_move_sethostname_up
Jan 20, 2025
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
5 changes: 0 additions & 5 deletionslibraries/Ethernet/src/Ethernet.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -24,11 +24,6 @@ int arduino::EthernetClass::_begin(uint8_t *mac, unsigned long timeout, unsigned
return (linkStatus() == LinkON ? 1 : 0);
}

int arduino::EthernetClass::setHostname(const char* hostname) {
eth_if->set_hostname(hostname);
return 1;
}

int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip) {
IPAddress dns = ip;
dns[3] = 1;
Expand Down
3 changes: 0 additions & 3 deletionslibraries/Ethernet/src/Ethernet.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,9 +56,6 @@ class EthernetClass : public MbedSocketClass {
EthernetClass(EthernetInterface *_if)
: eth_if(_if){};

// When using DHCP the hostname provided will be used.
int setHostname(const char* hostname);

// Initialise the Ethernet shield to use the provided MAC address and
// gain the rest of the configuration through DHCP.
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded
Expand Down
6 changes: 6 additions & 0 deletionslibraries/SocketWrapper/src/SocketHelpers.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,12 @@ String arduino::MbedSocketClass::macAddress() {
return String(getNetwork()->get_mac_address());
}

int arduino::MbedSocketClass::setHostname(const char* hostname) {
NetworkInterface* interface = getNetwork();
interface->set_hostname(hostname);
return 1;
}

int arduino::MbedSocketClass::hostByName(const char* aHostname, IPAddress& aResult) {
SocketAddress socketAddress = SocketAddress();
nsapi_error_t returnCode = gethostbyname(getNetwork(), aHostname, &socketAddress);
Expand Down
3 changes: 3 additions & 0 deletionslibraries/SocketWrapper/src/SocketHelpers.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,6 +57,9 @@ class MbedSocketClass {
*/
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);

// When using DHCP the hostname provided will be used.
int setHostname(const char* hostname);

/* Change DNS Ip configuration
*
* param dns_server1: ip configuration for DNS server 1
Expand Down
5 changes: 0 additions & 5 deletionslibraries/WiFi/src/WiFi.cpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -96,11 +96,6 @@ int arduino::WiFiClass::begin(const char* ssid) {
return begin(ssid, NULL, ENC_TYPE_NONE);
}

int arduino::WiFiClass::setHostname(const char* hostname) {
wifi_if->set_hostname(hostname);
return 1;
}

//Config Wifi to set Static IP && Disable DHCP
void arduino::WiFiClass::config(const char* localip, const char* netmask, const char* gateway){
SocketHelpers::config(IPAddress(localip), dnsIP(0), IPAddress(gateway), IPAddress(netmask));
Expand Down
3 changes: 0 additions & 3 deletionslibraries/WiFi/src/WiFi.h
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -76,9 +76,6 @@ class WiFiClass : public MbedSocketClass {
*/
int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_UNKNOWN);

// When using DHCP the hostname provided will be used.
int setHostname(const char* hostname);

// Inherit config methods from the parent class
using MbedSocketClass::config;

Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp