From 82efdd955b4b4214a54434617346cc6f22fe4e9a Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Sat, 13 Jul 2024 20:16:25 +0200 Subject: [PATCH] Set up hostname earlier in WiFi init to ensure it is applied to DHCP client name --- src/sensesp/net/networking.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/sensesp/net/networking.cpp b/src/sensesp/net/networking.cpp index 117108e99..da2171d61 100644 --- a/src/sensesp/net/networking.cpp +++ b/src/sensesp/net/networking.cpp @@ -1,8 +1,9 @@ +#include "sensesp.h" + #include "networking.h" #include -#include "sensesp.h" #include "sensesp/system/led_blinker.h" #include "sensesp_app.h" @@ -53,11 +54,14 @@ Networking::Networking(String config_path, String client_ssid, // complicated with enforced WPA2. BAD Raspberry Pi! BAD! WiFi.setMinSecurity(WIFI_AUTH_WPA_PSK); + // Try setting hostname already here. + String hostname = SensESPBaseApp::get_hostname(); + WiFi.setHostname(hostname.c_str()); + // Start WiFi with a bogus SSID to initialize the network stack but // don't connect to any network. WiFi.begin("0", "0", 0, nullptr, false); - // If both saved AP settings and saved client settings // are available, start in STA+AP mode.