Skip to content

Commit 82efdd9

Browse files
committed
Set up hostname earlier in WiFi init to ensure it is applied to DHCP client name
1 parent ea7f3bc commit 82efdd9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/sensesp/net/networking.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#include "sensesp.h"
2+
13
#include "networking.h"
24

35
#include <esp_wifi.h>
46

5-
#include "sensesp.h"
67
#include "sensesp/system/led_blinker.h"
78
#include "sensesp_app.h"
89

@@ -53,11 +54,14 @@ Networking::Networking(String config_path, String client_ssid,
5354
// complicated with enforced WPA2. BAD Raspberry Pi! BAD!
5455
WiFi.setMinSecurity(WIFI_AUTH_WPA_PSK);
5556

57+
// Try setting hostname already here.
58+
String hostname = SensESPBaseApp::get_hostname();
59+
WiFi.setHostname(hostname.c_str());
60+
5661
// Start WiFi with a bogus SSID to initialize the network stack but
5762
// don't connect to any network.
5863
WiFi.begin("0", "0", 0, nullptr, false);
5964

60-
6165
// If both saved AP settings and saved client settings
6266
// are available, start in STA+AP mode.
6367

0 commit comments

Comments
 (0)