Skip to content

Default hostname non unique ? #6099

Closed
Closed
@tablatronix

Description

@tablatronix

Board

esp32 wroom32d

Device Description

Custom

Hardware Configuration

no

Version

latest master

IDE Name

pio

Operating System

osx

Flash frequency

40

PSRAM enabled

no

Upload speed

921600

Description

I expected default hostnames to be ESP-deviceid but I see this instead ?

[WIFI] HOST: esp32-arduino

Other stuff like ota is as expected [OTA] Hostname: esp32-f008d1be63ac
etc.

static bool hostname(const String& aHostname) { return setHostname(aHostname.c_str()); }
...
static char default_hostname[32] = {0,};
static const char * get_esp_netif_hostname(){
	if(default_hostname[0] == 0){
	    uint8_t eth_mac[6];
	    esp_wifi_get_mac((wifi_interface_t)WIFI_IF_STA, eth_mac);
	    snprintf(default_hostname, 32, "%s%02X%02X%02X", CONFIG_IDF_TARGET "-", eth_mac[3], eth_mac[4], eth_mac[5]);
	}
	return (const char *)default_hostname;
}
static void set_esp_netif_hostname(const char * name){
	if(name){
		snprintf(default_hostname, 32, "%s", name);
	}
}

Is this an expected change, or documented?
I could not debug or find how this is set or init..

Sketch

#include <WiFi.h>

const char* ssid = "..........";
const char* password = "..........";

void setup() {
  Serial.begin(115200);
  Serial.println("Booting");
  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  while (WiFi.waitForConnectResult() != WL_CONNECTED) {
    Serial.println("Connection Failed! Rebooting...");
    delay(5000);
    ESP.restart();
}

  Serial.println("Ready");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
  Serial.print("Hostname: ");
  Serial.print(WiFi.getHostname());
}

void loop() {
}

Debug Message

[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 4 - STA_CONNECTED
[D][WiFiGeneric.cpp:374] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:419] _eventCallback(): STA IP: 192.168.1.39, MASK: 255.255.255.0, GW: 192.168.1.1

[WIFI] CONNECTED
[WIFI] IP: 192.168.1.39
[WIFI] HOST: esp32-arduino

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions