Skip to content

Commit 66209a4

Browse files
Channel59pennam
authored andcommitted
Add setHostname() method to Ethernet.cpp
1 parent 78c1511 commit 66209a4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

libraries/Ethernet/src/Ethernet.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ 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+
2732
int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip) {
2833
IPAddress dns = ip;
2934
dns[3] = 1;

libraries/Ethernet/src/Ethernet.h

+3
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ 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+
5962
// Initialise the Ethernet shield to use the provided MAC address and
6063
// gain the rest of the configuration through DHCP.
6164
// Returns 0 if the DHCP configuration failed, and 1 if it succeeded

0 commit comments

Comments
 (0)