Fixed hostname for esp32

This commit is contained in:
Gunnar Skjold 2022-03-11 19:21:27 +01:00
parent 724768afc4
commit 5cfcc015f4
2 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
#ifndef _AMSTOMQTTBRIDGE_H
#define _AMSTOMQTTBRIDGE_H
#define WIFI_CONNECTION_TIMEOUT 60000;
#define WIFI_CONNECTION_TIMEOUT 30000;
#define INVALID_BUTTON_PIN 0xFFFFFFFF

View File

@ -1031,6 +1031,11 @@ void WiFi_connect() {
wifiReconnectCount++;
#if defined(ESP32)
if(strlen(wifi.hostname) > 0) {
WiFi.setHostname(wifi.hostname);
}
#endif
WiFi.mode(WIFI_STA);
#if defined(ESP32)
if(wifi.power >= 195)
@ -1082,13 +1087,11 @@ void WiFi_connect() {
// WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // Workaround to make DHCP hostname work for ESP32. See: https://github.com/espressif/arduino-esp32/issues/2537
#endif
}
if(strlen(wifi.hostname) > 0) {
#if defined(ESP8266)
WiFi.hostname(wifi.hostname);
#elif defined(ESP32)
WiFi.setHostname(wifi.hostname);
#endif
}
#if defined(ESP8266)
if(strlen(wifi.hostname) > 0) {
WiFi.hostname(wifi.hostname);
}
#endif
WiFi.setAutoReconnect(true);
WiFi.persistent(true);
if(WiFi.begin(wifi.ssid, wifi.psk)) {