-
-
Notifications
You must be signed in to change notification settings - Fork 97
Dual AP and wifi client mode #187
Comments
I spent some time before researching this and to be honest have no idea why it happens. The easiest way is to disable AP completely in the code, perhaps with a compile option called -DNO_AP. If you want a quick hack comment out the line:
in the function MyESP.cpp._wifi_setup() |
Could you turn on serial, connect it via USB to your PC and look at the serial monitor when it boots up? I'd like to see what is happening. If the EMS-ESP is unable to join the wifi network it will go back to AP mode. I'll also add some more debug statements in the next beta build |
Here's the serial output after restarting: restart
Exception (9):
ets Jan 8 2013,rst cause:2, boot mode:(3,7) load 0x4010f000, len 1384, room 16
It takes a few minutes before the ems-esp appears on the LAN, despite the serial output showing that it connected immediately with the correct IP address set by a reserved rule in the router. |
I really don't know what is causing the AP to be alive while its still been given a fixed IP on your LAN. |
Unfortunately commenting out the jw.enableAPFallback(true) line in the MyESP.cpp._wifi_setup() function (and recompiling and reflashing of course) didn't help, the ems-esp soft AP was still active after the client reconnected. |
So you still see both ems-esp as a wifi AP in your router and at the same time ems-esp as a hostname on your network with IP 192.168.x.x which you can telnet into Can you use a laptop/pc and connect to the ems-esp wifi Access Point as well? If so which IP does it have? Just to rule out its not a ghost entry in your router. I still don't see how a device can be an AP with 192.168.4.1 and also on the network with another IP address. Unless you have DHCP enabled and using the range 192.168.4.x/24 which would be very odd ! |
Almost: I see ems-esp as a wifi AP in my PC's list (not router). If I connect to it, the ems-esp AP IP is 192.168.4.1 and the DHCP server gives my PC's network card an IP a few numbers higher, all as expected. The ems-esp is concurrently connected to my LAN which is definitely on a different subnet, not 4.1. With the PC back on the LAN, I can connect to the ems-esp with telnet or the new web interface using the IP address that I reserved for it in my router, again all as expected. A scanner such as Acrylic or the Android Wifi Analyzer shows that the ems-esp AP is on the same channel as the LAN AP that it's also connected to. So it's acting like something half way between a router and mesh. |
EMS-ESP uses the justwifi library. I suggest spending a few minutes creating a new PlatformIO project with the example code here and see if you can recreate the problem. If that works then it's something buggy in my code and we can do another deep dive. |
I tried a merge of the basic.ino and utils.ino in the Arduino IDE with a static IP. The results were exactly as expected: my spare, test d1 mini connected to the network and no dual open AP appeared. So it looks to me like the justwifi library is OK. Just to be sure, I then unplugged my live ems-esp and uploaded v1.9.0 to the test board. The results were repeatable: the dual mode reappeared. So it doesn't look like a hardware issue or upload glitch. |
wow, didn't expect that. ok, then I need to compare both and see what the problem is. |
made a really small change so the initializing sequence is exactly the same as JustWifi's basic demo which worked on your environment. Can you test? Latest 1.9.1b11 |
After uploading, firstly it proved very difficult to change the settings. Here's one example from a telnet session: set serial on Type 'restart' to activate Serial mode. Unknown set command or wrong number of arguments. I tried a second board but the results were the same. When after many attempts I finally succeeded in setting the wifi mode, ssid and password, it then proved very difficult to connect to the LAN wifi. The ems-esp just kept saying unable to connect and fell back to AP mode, despite being only 2m away from a LAN AP with a signal of around -40dBm. After many resets this also eventually succeeded. The good news is: when all was running as it should, the ems-esp AP did not reappear! |
well that's some good news. I've noticed on some Wemos boards with PlatformIO that the reset doesn't work too well and it needs a hard reset (the little button on the side). The problem with telnet and # commands, can you reproduce this? What are you using as the Telnet client? Again there are so many variations for example putty on Windows behaves differently to the Telnet native client on Windows10 and Termius on OSX and telnet with Ubuntu etc. Or did you just use the serial monitor from pio? |
The issue with changing the settings is fully reproducible. My default telnet client is PuTTY on Windows 10, but the results were the same with the web interface on Windows 10, Linux and Android. |
can you describe again the problem? |
The problem is now: difficulty changing the settings in v1.9.1b11. Example
system ESP8266 System stats: [APP] EMS-ESP version: 1.9.1b11 set Note: please 'restart' to apply new WiFi settings Unknown set command or wrong number of arguments. Note: please 'restart' to apply new WiFi settings Unknown set command or wrong number of arguments. Note: please 'restart' to apply new WiFi settings Unknown set command or wrong number of arguments. restart
set The behaviour through the web interface is similar: after saving the changes, hitting restart and logging in again, nothing has changed. Let me know if you think this is unrelated to the fix for the original #187 and needs a new issue. |
try:
BTW I trust you have a genuine Wemos D1 (and not a clone with a dodgy flash chip) and that the board parameter is correctly set in the platformio.ini file. |
All of my Wemos D1 minis and pros came from their official AliExpress store. This time it took only one attempt to change the wifi settings, but getting a connection to my LAN WAP is still difficult, even after resetting the board with pio run -t erase and uploading again. When it finally did connect, the ems-esp AP disappeared, so the original #187 is (still) fixed, no regression. BTW, I didn't mention this earlier because I thought it was unrelated, but for completeness: to get the code to compile I need to add lib_ignore = Time to my platformio.ini. Here are the relevant lines from the serial port.
Current settings: wifi_mode=ap set wifi_mode client
Exception (9):
ets Jan 8 2013,rst cause:2, boot mode:(3,6) load 0x4010f000, len 1384, room 16
Current settings: wifi_mode=ap
|
It remains a mystery. Perhaps more time is needed for the wifi to connect.
Try increasing the #define MYESP_WIFI_CONNECT_TIMEOUT in MyESP.h. It’s
currently 10 seconds.
The Time lib is odd. Should not be needed.
…On Wed, 9 Oct 2019 at 16:13, mrfixit1 ***@***.***> wrote:
All of my Wemos D1 minis and pros came from their official AliExpress
store.
This time it took only one attempt to change the wifi settings, but
getting a connection to my LAN WAP is still difficult, even after resetting
the board with pio run -t erase and uploading again.
When it finally did connect, the ems-esp AP disappeared, so the original
#187 <#187> is (still) fixed, no
regression.
BTW, I didn't mention this earlier because I thought it was unrelated, but
for completeness: to get the code to compile I need to add lib_ignore =
Time to my platformio.ini.
Here are the relevant lines from the serial port.
1. After initial upload - as expected:
* EMS-ESP version 1.9.2b3
[FS] Checking file /myesp.json (326 bytes)
[FS] Serial is forced
[FS] System config loaded
[FS] Checking file /customconfig.json (202 bytes)
[FS] Custom config loaded
[FS] Checking file /eventlog.json (264/20840 bytes)
[FS] Event log is healthy
[WIFI] Creating access point
[WIFI] MODE AP
[WIFI] SSID ems-esp
[WIFI] IP 192.168.4.1
[WIFI] MAC aa:bb:cc:dd:ee:ff
[SYSTEM] Serial port communication is enabled.
[WEB] Web server started
Warning! EMS bus communication disabled when Serial mode enabled. Use
'set serial off' to start communication.
[TELNET] in AP mode
[TELNET] Telnet server started
set
Current settings:
wifi_mode=ap
wifi_ssid=
wifi_password=
mqtt_enabled=off
...
serial=on (this is always when compiled with -DFORCE_SERIAL)
ntp_enabled=off
set wifi_mode client
Please 'restart' to apply new settings.
wifi_mode changed.
[FS] system config saved
set wifi_ssid MyLANSSID
Please 'restart' to apply new settings.
wifi_ssid changed.
[FS] system config saved
set wifi_password MyLANPW
Please 'restart' to apply new settings.
wifi_password changed.
[FS] system config saved
1. Soft restart:
restart
- Restart ESP...
Exception (9):
epc1=0x40201fcc epc2=0x00000000 epc3=0x00000000 excvaddr=0x040602de
depc=0x00000000
>>>stack>>>
ctx: cont
sp: 3ffffd70 end: 3fffffc0 offset: 01a0
3fffff10: 3fff6bec 3fff26f8 3fff2078 40202c47
3fffff20: 0000000d 3fff26f8 00000001 4020a2dc
3fffff30: 00000001 0000000a 3fff2674 4022bbdb
3fffff40: 4021b424 3fff3eb0 3fff2674 3fff2078
3fffff50: 0000000d 3fff2674 0000000d 4020d798
3fffff60: 3fff2674 00000000 3fff3eb0 40237dd6
3fffff70: 3fffdad0 00000000 3fff2078 3fff408c
3fffff80: 3fffdad0 3fff3f4c 3fff2078 4020d8aa
3fffff90: 3fffdad0 00000000 3fff2d44 40215d41
3fffffa0: 3fffdad0 00000000 3ffe8594 4022e246
3fffffb0: feefeffe feefeffe feefeffe 40100b65
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16
tail 8
chksum 0x2d
csum 0x2d
v8b899c12
~ld
- EMS-ESP version 1.9.2b3
[FS] Checking file /myesp.json (341 bytes)
[FS] Serial is forced
[FS] System config loaded
[FS] Checking file /customconfig.json (202 bytes)
[FS] Custom config loaded
[FS] Checking file /eventlog.json (622/20808 bytes)
[FS] Event log is healthy
[WEB] Web server started
Warning! EMS bus communication disabled when Serial mode enabled. Use
'set serial off' to start communication.
[WIFI] Connecting to SSID: MyLANSSID
[WIFI] Could not connect to MyLANSSID
[WIFI] Creating access point
[WIFI] MODE AP
[WIFI] SSID ems-esp
[WIFI] IP 192.168.4.1
[WIFI] MAC aa:bb:cc:dd:ee:ff
[SYSTEM] Serial port communication is enabled.
[TELNET] in AP mode
[TELNET] Telnet server started
set
Current settings:
wifi_mode=ap
wifi_ssid=MyLANSSID
wifi_password=************
mqtt_enabled=off
...
serial=on (this is always when compiled with -DFORCE_SERIAL)
ntp_enabled=off
1.
Same again after subsequent hard resets:
* EMS-ESP version 1.9.2b3
[FS] Checking file /myesp.json (341 bytes)
[FS] Serial is forced
[FS] System config loaded
[FS] Checking file /customconfig.json (202 bytes)
[FS] Custom config loaded
[FS] Checking file /eventlog.json (696/21776 bytes)
[FS] Event log is healthy
[WEB] Web server started
Warning! EMS bus communication disabled when Serial mode enabled. Use
'set serial off' to start communication.
[WIFI] Connecting to SSID: MyLANSSID
[WIFI] Could not connect to MyLANSSID
[WIFI] Creating access point
[WIFI] MODE AP
[WIFI] SSID ems-esp
[WIFI] IP 192.168.4.1
[WIFI] MAC aa:bb:cc:dd:ee:ff
[SYSTEM] Serial port communication is enabled.
[TELNET] in AP mode
[TELNET] Telnet server started
2.
Until after +/-5 hard resets it finally connected:
- EMS-ESP version 1.9.2b3
[FS] Checking file /myesp.json (341 bytes)
[FS] Serial is forced
[FS] System config loaded
[FS] Checking file /customconfig.json (202 bytes)
[FS] Custom config loaded
[FS] Checking file /eventlog.json (1288/21776 bytes)
[FS] Event log is healthy
[WEB] Web server started
Warning! EMS bus communication disabled when Serial mode enabled. Use
'set serial off' to start communication.
[WIFI] Connecting to SSID: MyLANSSID
[WIFI] SSID MyLANSSID
[WIFI] CH 11
[WIFI] RSSI -46
[WIFI] IP 192.168.nnn.nn
[WIFI] MAC aa:bb:cc:dd:ee:ff
[WIFI] GW 192.168.xxx.xx
[WIFI] MASK 255.255.255.0
[WIFI] DNS aa.bbb.cc.dd
[WIFI] HOST ems-esp
[OTA] listening to ems-esp.local:8266
[MQTT] is disabled
[SYSTEM] Serial port communication is enabled.
[TELNET] Telnet server started
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#187>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJMO6AFYQFXPGBMZXEMFTTQNXRI7ANCNFSM4IY225JQ>
.
|
Increasing the connect timeout to 30s has solved the connection issue. The ems-esp now connects reliably first time after every reset. Thanks for your help with this, much appreciated. FYI these are the compile errors without the lib_ignore = Time: Compiling .pio\build\debug\lib110\ESP Async WebServer\WebRequest.cpp.o |
re-opening so I can change the timeout for the wifi in case others have a similar issue. @mrfixit1 which value worked for you? 20 seconds? |
I tried 30s initially, but 20s also works OK with my config. |
Regression of issue 152 in v1.9.0. After setting the wifi client parameters and restarting, the AP is still active.
Wifi mode from system command:
ESP8266 System stats:
[APP] EMS-ESP version: 1.9.0
[APP] MyESP version: 1.2.0
[APP] Build timestamp: 2019-09-20 20:13:04
[APP] Uptime: 0 days 1 hour 3 minutes 48 seconds
[APP] System Load: 6%
[WIFI] Device is in AP mode with SSID ems-esp
Wifi mode and parameters from set command:
Stored settings:
wifi_mode=client
wifi_ssid=xxxxxxxx
wifi_password=************
The open ems-esp shows in the PC's list of wifi networks. Anyone know how to turn it off for better security?
The text was updated successfully, but these errors were encountered: