WifiManager: name the setup AP as it is turned on (#25169)

WifiManagerBegin() turned the AP on with WifiSetMode() and named it with
WiFi.softAP() only after WifiSetMode()'s delay(100): for that time the AP
beaconed under the SDK's default name, ESP_ and the AP MAC, which a phone
or computer then lists beside the real name, often for a minute after.

WiFi.softAP() turns the AP on and names it at once, so it now comes first;
WifiSetMode() then sets the station side as before.
This commit is contained in:
Adam Matthews authored and GitHub committed 2026-10-22 10:38:47 +02:00
1 parent 9515f82b23
commit 805fc7cb01
1 file changed
+8 -6
@@ -730,6 +730,14 @@ void WebserverStartSocket(void) {
void WifiManagerBegin(bool reset_only) {
// setup AP
if (!Web.initial_config) { AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_WIFI D_WCFG_2_WIFIMANAGER " " D_ACTIVE_FOR_3_MINUTES)); }
int channel = WIFI_SOFT_AP_CHANNEL;
if ((channel < 1) || (channel > 13)) { channel = 1; }
// Name the AP as it is turned on: WifiSetMode() first would bring it up under
// the SDK default name (ESP_ and the AP MAC) for its delay(100)
// bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
WiFi.softAP(TasmotaGlobal.hostname, WIFI_AP_PASSPHRASE, channel, 0, 1);
if (!TasmotaGlobal.global_state.wifi_down) {
WifiSetMode(WIFI_AP_STA);
AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_WIFI D_WIFIMANAGER_SET_ACCESSPOINT_AND_STATION));
@@ -741,12 +749,6 @@ void WifiManagerBegin(bool reset_only) {
//StopWebserver();
DnsServer = new DNSServer();
int channel = WIFI_SOFT_AP_CHANNEL;
if ((channel < 1) || (channel > 13)) { channel = 1; }
// bool softAP(const char* ssid, const char* passphrase = NULL, int channel = 1, int ssid_hidden = 0, int max_connection = 4);
WiFi.softAP(TasmotaGlobal.hostname, WIFI_AP_PASSPHRASE, channel, 0, 1);
delay(500); // Without delay I've seen the IP address blank
/* Setup the DNS server redirecting all the domains to the apIP */
DnsServer->setErrorReplyCode(DNSReplyCode::NoError);