change default STA hostname to "arduino-XXYY"

This commit is contained in:
Sandeep Mistry
2018-06-28 13:00:07 +02:00
parent 4e2b214daf
commit 1acd9258d7

View File

@@ -579,6 +579,12 @@ void WiFiClass::handleSystemEvent(system_event_t* event)
case SYSTEM_EVENT_STA_START: { case SYSTEM_EVENT_STA_START: {
struct netif* staNetif; struct netif* staNetif;
uint8_t mac[6];
char defaultHostname[13];
esp_wifi_get_mac(ESP_IF_WIFI_STA, mac);
sprintf(defaultHostname, "arduino-%.2x%.2x", mac[4], mac[5]);
tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, defaultHostname);
if (tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, (void**)&staNetif) == ESP_OK) { if (tcpip_adapter_get_netif(TCPIP_ADAPTER_IF_STA, (void**)&staNetif) == ESP_OK) {
if (staNetif->input != WiFiClass::staNetifInputHandler) { if (staNetif->input != WiFiClass::staNetifInputHandler) {