Skip to content

Commit 1f6d782

Browse files
committed
Refactor generateDefaultHostName
1 parent 9773b5b commit 1f6d782

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

src/Ethernet.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,8 @@ void EthernetClass::setRetransmissionCount(uint8_t num)
232232
}
233233

234234
void EthernetClass::generateDefaultHostName(uint8_t *mac) {
235-
// Copy the default host name base
236-
strcpy(_hostName, DEFAULT_HOST_NAME);
237-
238-
// Append the last 3 bytes of the MAC (HEX'd)
239-
char macAddrStr[3];
240-
sprintf(macAddrStr, "%02X", mac[3]);
241-
strcat(_hostName, macAddrStr);
242-
sprintf(macAddrStr, "%02X", mac[4]);
243-
strcat(_hostName, macAddrStr);
244-
sprintf(macAddrStr, "%02X", mac[5]);
245-
strcat(_hostName, macAddrStr);
235+
// Generate a default host name based on the MAC address
236+
sprintf_P(_hostName, PSTR("%s%02X%02X%02X"), DEFAULT_HOST_NAME, mac[3], mac[4], mac[5]);
246237
}
247238

248239
void EthernetClass::setHostName(const char *dhcpHost) {

0 commit comments

Comments
 (0)