Skip to content

WiFi hostname set/get is not working correctly #4752

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

Closed
miksumin opened this issue Jan 28, 2021 · 11 comments
Closed

WiFi hostname set/get is not working correctly #4752

miksumin opened this issue Jan 28, 2021 · 11 comments

Comments

@miksumin
Copy link

miksumin commented Jan 28, 2021

Hardware:

Board: ESP32 Dev Module
Core Installation version: 1.0.5-rc1
IDE name: Arduino IDE 1.8.7
Flash Frequency: 40Mhz
PSRAM enabled: no
Upload Speed: 115200
Computer OS: Windows 7

Description:

Starting core version 1.0.5-rc1 and up to core version 1.0.5-rc6 WiFi hostname set/get is not working correctly.
Anything you set by calling WiFi.setHostname("Hostname") then you call WiFi.getHostname() and you get "espressif".

Sketch: (leave the backquotes for code formatting)

//Change the code below by your sketch
#include <Arduino.h>
#include <WiFi.h>

void setup() {
  WiFi.mode(WIFI_STA);
  WiFi.setHostname("Hostname");
  WiFi.begin(WIFI_SSID, WIFI_PASS);
    if (WiFi.status() == WL_CONNECTED) {
      Serial.println(WiFi.getHostname());
    }
}

void loop() {
}

Debug Messages:

Enable Core debug level: Debug on tools menu of Arduino IDE, then put the serial output here 
@kapyaar
Copy link

kapyaar commented Jan 28, 2021

Can you try
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
WiFi.setHostname("hostName");
//#2537 (comment)

@me-no-dev
Copy link
Member

This has been fixed here: ad4cf14

next RC will have it

@heisenberg2980
Copy link

heisenberg2980 commented Feb 18, 2022

@me-no-dev I am still having this issue, and if I use the workaround mentioned by @kapyar I get hostname "esp32-arduino" instead of "espressif", but not the hostname I assign with the WiFi.setHostname command.
I am using Visual Studio Code, how can I check if my sketch is using the version of arduino-esp32 that contains that fix?

@me-no-dev
Copy link
Member

@heisenberg2980 any chance you can try this with github version of master instead?

@heisenberg2980
Copy link

heisenberg2980 commented Feb 22, 2022

@me-no-dev what do you mean with "github version of master"? At the moment my sketch is using these two arduino libraries:

#include <ArduinoJson.h>
#include <ArduinoOTA.h>

And these are all the libraries being used:

#include <WiFi.h>
extern "C" {
	#include "freertos/FreeRTOS.h"
	#include "freertos/timers.h"
}
#include "soc/timer_group_struct.h"
#include "soc/timer_group_reg.h"
#include <AsyncTCP.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <AsyncMqttClient.h>
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include "BLEBeacon.h"
#include "BLEEddystoneTLM.h"
#include "BLEEddystoneURL.h"
#include <Adafruit_BME280.h>

@me-no-dev
Copy link
Member

@heisenberg2980 seems that you are using a quite old esp core (1.0.5-rc1). We are on version 2.0.2 now and 2.0.3 is coming up (which will include the fix). If you want to try it now, you need to install arduino-esp32 from git and not from the board manager. If this sounds complicated, just hold on for a few days for 2.0.3 to be out.

@heisenberg2980
Copy link

heisenberg2980 commented Feb 22, 2022

@me-no-dev thank you for the info, how do you know the version of the esp core I am using, is it inside of one of the libraries I mentioned?
I am happy to wait a few days for the 2.0.3 to be out, but I am not sure what I will need to update to start using that version rather than 1.0.5-rc1, any hint you can give me will be really helpful

@me-no-dev
Copy link
Member

Sorry @heisenberg2980 I thought you also posted the issue and up there it's said that 1.0.5-rc1 is used. I do not know which version you are using. Updates happen through ArduinoIDE's board manager

@heisenberg2980
Copy link

heisenberg2980 commented Feb 22, 2022

@me-no-dev right, the version I have in Arduino IDE is 1.0.4, but for this sketch I am using Visual Studio Code instead, and it is weird because I am not able to find the ESP32 library anywhere in Visual Studio Code, any idea where it could be hiding? EDIT: Answering my own question, my sketch doesn´t use library ESP32 but it uses library WiFi.h instead (which is part of ESP32), so I will see if I can download the wifi library from latest version of ESP32 which includes the fix, and use that version instead of the one Visual Studio Code is using at the moment.

Regarding the Arduino IDE, do you know by any change why it is just offering me versions up to 1.0.6 and not the versions 2.0.0 and above that are available from August 2021 (https://github.com/espressif/arduino-esp32/releases)?

image

@me-no-dev
Copy link
Member

You are probably using the old json link that is no longer updated :)
Check here: https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html#installing-using-boards-manager

@heisenberg2980
Copy link

@me-no-dev You are completely right!! version 2.0.2 installed now in Arduino IDE, thank you very much for your help.

I just need to figure out how to use it on my sketch in VS Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants