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

Appearance settings

Commit ec0a86b

Browse filesBrowse files
authored
Merge pull request #986 from JAndrassy/net_move_sethostname_up
networking - move setHostname to base class SocketWrapper
2 parents b33779a + b3ad8e9 commit ec0a86b
Copy full SHA for ec0a86b

File tree

Expand file treeCollapse file tree

6 files changed

+9
-16
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+9
-16
lines changed

‎libraries/Ethernet/src/Ethernet.cpp

Copy file name to clipboardExpand all lines: libraries/Ethernet/src/Ethernet.cpp
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ int arduino::EthernetClass::_begin(uint8_t *mac, unsigned long timeout, unsigned
2424
return (linkStatus() == LinkON ? 1 : 0);
2525
}
2626

27-
int arduino::EthernetClass::setHostname(const char* hostname) {
28-
eth_if->set_hostname(hostname);
29-
return 1;
30-
}
31-
3227
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip) {
3328
IPAddress dns = ip;
3429
dns[3] = 1;

‎libraries/Ethernet/src/Ethernet.h

Copy file name to clipboardExpand all lines: libraries/Ethernet/src/Ethernet.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ class EthernetClass : public MbedSocketClass {
5656
EthernetClass(EthernetInterface *_if)
5757
: eth_if(_if){};
5858

59-
// When using DHCP the hostname provided will be used.
60-
int setHostname(const char* hostname);
61-
6259
// Initialise the Ethernet shield to use the provided MAC address and
6360
// gain the rest of the configuration through DHCP.
6461
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded

‎libraries/SocketWrapper/src/SocketHelpers.cpp

Copy file name to clipboardExpand all lines: libraries/SocketWrapper/src/SocketHelpers.cpp
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ String arduino::MbedSocketClass::macAddress() {
1515
return String(getNetwork()->get_mac_address());
1616
}
1717

18+
int arduino::MbedSocketClass::setHostname(const char* hostname) {
19+
NetworkInterface* interface = getNetwork();
20+
interface->set_hostname(hostname);
21+
return 1;
22+
}
23+
1824
int arduino::MbedSocketClass::hostByName(const char* aHostname, IPAddress& aResult) {
1925
SocketAddress socketAddress = SocketAddress();
2026
nsapi_error_t returnCode = gethostbyname(getNetwork(), aHostname, &socketAddress);

‎libraries/SocketWrapper/src/SocketHelpers.h

Copy file name to clipboardExpand all lines: libraries/SocketWrapper/src/SocketHelpers.h
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ class MbedSocketClass {
5757
*/
5858
void config(IPAddress local_ip, IPAddress dns_server, IPAddress gateway, IPAddress subnet);
5959

60+
// When using DHCP the hostname provided will be used.
61+
int setHostname(const char* hostname);
62+
6063
/* Change DNS Ip configuration
6164
*
6265
* param dns_server1: ip configuration for DNS server 1

‎libraries/WiFi/src/WiFi.cpp

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFi.cpp
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@ int arduino::WiFiClass::begin(const char* ssid) {
9696
return begin(ssid, NULL, ENC_TYPE_NONE);
9797
}
9898

99-
int arduino::WiFiClass::setHostname(const char* hostname) {
100-
wifi_if->set_hostname(hostname);
101-
return 1;
102-
}
103-
10499
//Config Wifi to set Static IP && Disable DHCP
105100
void arduino::WiFiClass::config(const char* localip, const char* netmask, const char* gateway){
106101
SocketHelpers::config(IPAddress(localip), dnsIP(0), IPAddress(gateway), IPAddress(netmask));

‎libraries/WiFi/src/WiFi.h

Copy file name to clipboardExpand all lines: libraries/WiFi/src/WiFi.h
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ class WiFiClass : public MbedSocketClass {
7676
*/
7777
int begin(const char* ssid, const char* passphrase, wl_enc_type security = ENC_TYPE_UNKNOWN);
7878

79-
// When using DHCP the hostname provided will be used.
80-
int setHostname(const char* hostname);
81-
8279
// Inherit config methods from the parent class
8380
using MbedSocketClass::config;
8481

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.