Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiFi Hostname is only set when changing mode to WIFI_MODE_STA #7227

Closed
1 task done
tbnobody opened this issue Sep 6, 2022 · 3 comments
Closed
1 task done

WiFi Hostname is only set when changing mode to WIFI_MODE_STA #7227

tbnobody opened this issue Sep 6, 2022 · 3 comments
Assignees
Labels
Area: BT&Wifi BT & Wifi related issues Type: Documentation Issue pertains to Documentation of Arduino ESP32

Comments

@tbnobody
Copy link

tbnobody commented Sep 6, 2022

Board

generic

Device Description

Hardware Configuration

No

Version

v2.0.4

IDE Name

VSCode with PlatformIO

Operating System

Windows 11

Flash frequency

PSRAM enabled

no

Upload speed

115200

Description

There are several issues in issue trackers out there in the internet which are stating that the hostname is not set correctly. When diving deeper into the library, it seems that the hostname is only set on one location:

err = set_esp_interface_hostname(ESP_IF_WIFI_STA, get_esp_netif_hostname());

That means set a call of WiFi.setHostname() does nothing in the first step. It's not even enough to call WiFi.mode(WIFI_MODE_STA); if the mode was already WIFI_MODE_STA. Because if current mode equals new mode:


no changes are applied.

To set the hostname correctly the following snippet has to be used:

WiFi.mode(WIFI_MODE_APSTA); // or any other mode
WiFi.setHostname("asdf");
WiFi.mode(WIFI_MODE_STA);

If the behavior is known to the user of the class it's simple to use but it's a little bit unintuitive. Does it make sense to at least document this behavior?

Sketch

-

Debug Message

-

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.
@tbnobody tbnobody added the Status: Awaiting triage Issue is waiting for triage label Sep 6, 2022
@VojtechBartoska VojtechBartoska added Area: BT&Wifi BT & Wifi related issues Type: Documentation Issue pertains to Documentation of Arduino ESP32 and removed Status: Awaiting triage Issue is waiting for triage labels Sep 19, 2022
@domdfcoding
Copy link

I've run into the same issue of the hostname being set, with internet unhelpfully guides suggesting to do it they way I was already.
I've tried the approach listed here (with the exception of WIFI_STA instead of WIFI_MODE_STA, not sure what the difference is) and it works as I would expect.

Could this be fixed, or at least the limitation documented, please?

I'm running on an ESP32-C3, if it's relevant.

@pedrominatel
Copy link
Member

Hi, @domdfcoding,

This will be added to the documentation. On the code side, I'll discuss with the team if there is something to do.

@Parsaabasi
Copy link

Hello,

Due to the overwhelming volume of issues currently being addressed, we have decided to close the previously received tickets. If you still require assistance or if the issue persists, please don't hesitate to reopen the ticket.

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: BT&Wifi BT & Wifi related issues Type: Documentation Issue pertains to Documentation of Arduino ESP32
Projects
None yet
Development

No branches or pull requests

5 participants