Hardware: ESP12e
Core Version: V1.7
Development Env: platformio
Operating System: WIN10
Settings in IDE
Module: Wemos D1 mini r2
Flash Mode: dio
Flash Size: 4MB/1MB
lwip Variant: [v1.4|v2 Lower Memory|Higher Bandwidth]
Reset Method: nodemcu
Flash Frequency: [40Mhz]
CPU Frequency: [80Mhz|160MHz]
Upload Using: [OTA|SERIAL]
Upload Speed: [115200|other] (serial upload only)
Problem Description
Hi,
I try to implement a switchable access point. WiFi debug is enabled. I'm wondering why WiFi.softAPConfig and WiFi.softAP returns false while AP ist going startet.
Sometimes WiFi.softAPConfig and WiFi.softAP returns true.
The STA-Mode is enabled an the ESP is connectet to my home network while the AP shoud be switched ON/OFF.
What is the right way to implement a switchable AP in one function, while STA-connection is established?
I simplyfied the Sketch to this function:
String startAP(int state) {
if (state) {
//WiFi.mode(WIFI_AP_STA);
//delay(1000);
const char* apSSID = "MyAccessPoint";
const char* apPassword = "1234567890";
IPAddress apIP(192,168,4,1);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);
Serial.println(WiFi.softAPConfig(apIP, gateway, subnet));
Serial.println(WiFi.softAP(apSSID, apPassword));
Serial.println(WiFi.softAPIP());
return "AP is on";
} else {
//WiFi.mode(WIFI_STA);
WiFi.softAPdisconnect(true);
return "AP is off";
}
}
Debug:
[APConfig] local_ip: 192.168.4.1 gateway: 192.168.4.1 subnet: 255.255.255.0
[APConfig] wifi_softap_dhcps_stop failed!
[APConfig] wifi_set_ip_info failed!
[APConfig] DHCP IP start: 192.168.4.100
[APConfig] DHCP IP end: 192.168.4.200
[APConfig] wifi_set_ip_info failed!
[APConfig] wifi_softap_set_dhcps_lease_time failed!
[APConfig] wifi_softap_dhcps_start failed!
[APConfig] IP config Invalid?!
0
[AP] set_config failed!
0
0.0.0.0
AP is on
mode : sta(a0:20:a6:16:a3:22) + softAP(a2:20:a6:16:a3:22)
add if1
pm close 7
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
wifi evt: 7