Skip to content

Commit

Permalink
Add setHostname() method to Ethernet.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
Channel59 committed Jul 9, 2024
1 parent 85f6572 commit 09ca461
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions libraries/Ethernet/src/Ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ 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(const char* hostname) {
eth_if->set_hostname(hostname);
auto ret = begin();
return ret;
}

int arduino::EthernetClass::begin(uint8_t *mac, IPAddress ip) {
IPAddress dns = ip;
dns[3] = 1;
Expand Down
4 changes: 4 additions & 0 deletions libraries/Ethernet/src/Ethernet.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,14 @@ 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
int begin(uint8_t *mac = nullptr, unsigned long timeout = 60000, unsigned long responseTimeout = 4000);
int begin(const char* hostname);
EthernetLinkStatus linkStatus();
EthernetHardwareStatus hardwareStatus();

Expand Down

0 comments on commit 09ca461

Please sign in to comment.