-->
Page 1 of 1

Strange ESP8266 WiFi connection failure with Unifi AP-AC-PRO

PostPosted: Thu Aug 06, 2020 12:08 pm
by konbaasiang
I have a total of around 50 ESP8266 based WiFi lights of a few different types, and lots of ESP8266's performing various tasks, every single one with my own firmware based on the Arduino core. All my projects use hardcoded WiFi settings (primary and fallback) so there are no per-device settings to screw up.

Everything has worked great with all access points I've tried.

But, recently, I have now upgraded from various consumer grade access points to Unifi AP-AC-PRO's.

The vast majority of my ESP8266 devices migrated to the new network just fine.

But out of the 10 Zemismart E14 ESP8266 that I have... two out of these ten absolutely refuse to connect to the Unifi APs -- even though they connect to every other access point I have.

They were all purchased at the same time and appear identical.

I've tried with both WPA2 and completely OPEN. The access point is only a meter away. After failing to connect to the Unifi access points, they fall back to my old access points and connect just fine. I probably have close to 100 ESP8266 devices and only these two are failing to connect to the Unifi APs, but connect fine to other APs, and work perfectly fine otherwise!

It's not that I care this much about these two bulbs, but I am building a new house that will have hundreds of WiFi bulbs, and I have a feeling this will come up again, so I would like to get to the bottom of it.

Here are the 10 mac addresses for my 10 zemismart E14 bulbs:

Code: Select all      const char * mac[]=
      {
         "CC:50:E3:DA:35:94",   //172.22.21.200
         "D8:BF:C0:C6:0E:A6",   //172.22.21.201
         "D8:BF:C0:C6:76:D6",   //172.22.21.202                              
         "68:C6:3A:ED:4E:0E",   //172.22.21.203      //can't connect to unifi
         "D8:BF:C0:C6:0E:B0",   //172.22.21.204      //can't connect to unifi

         "CC:50:E3:DA:36:10",   //172.22.21.205
         "CC:50:E3:DA:42:D0",   //172.22.21.206
         "CC:50:E3:DA:35:FF",   //172.22.21.207
         "CC:50:E3:DA:42:4E",   //172.22.21.208
         "D8:BF:C0:C6:0E:9A",   //172.22.21.209
      };


As you can see it's .203 and .204 that cannot connect. .203 has an odd MAC address (OUI 68), but 204 has a similar mac address to 201, 202 and 209 (OUI D8), and they connect just fine!

I tried SSH'ing into my access point and ran tail -f /var/log/messages | grep <mac> and got the following for a SUCCESSFUL connection from D8:BF:C0:C6:76:D6:

Code: Select all
Thu Aug  6 21:43:49 2020 user.info : wevent[1906]: wevent.ubnt_custom_event(): EVENT_STA_LEAVE ath3: d8:bf:c0:c6:76:d6 / 1
Thu Aug  6 21:43:49 2020 kern.info kernel: [978556.840457] ieee80211_sta_leave: d8:bf:c0:c6:76:d6
Thu Aug  6 21:43:49 2020 kern.info kernel: [978556.844340] ieee80211_sta_leave: d8:bf:c0:c6:76:d6
Thu Aug  6 21:43:49 2020 daemon.info hostapd: ath3: STA d8:bf:c0:c6:76:d6 IEEE 802.11: sta_stats
Thu Aug  6 21:43:49 2020 daemon.info hostapd: ath3: STA d8:bf:c0:c6:76:d6 IEEE 802.11: disassociated
Thu Aug  6 21:43:49 2020 daemon.info hostapd: ath3: STA 96:83:c2:41:56:d8 DRIVER: Sead AUTH addr=d8:bf:c0:c6:76:d6 status_code=0
Thu Aug  6 21:43:49 2020 daemon.info hostapd: ath3: STA d8:bf:c0:c6:76:d6 IEEE 802.11: associated
Thu Aug  6 21:43:49 2020 daemon.info hostapd: ath3: STA d8:bf:c0:c6:76:d6 RADIUS: starting accounting session 4DC51325442392F0
Thu Aug  6 21:43:49 2020 user.info : wevent[1906]: wevent.ubnt_custom_event(): EVENT_STA_JOIN ath3: d8:bf:c0:c6:76:d6 / 1
Thu Aug  6 21:43:49 2020 user.info : stahtd[1907]: [STA-TRACKER].stahtd_dump_event(): {"event_type":"sta_leave","message_type":"STA_ASSOC_TRACKER","mac":"d8:bf:c0:c6:76:d6","assoc_status":"0","vap":"ath3","event_id":"1"}
Thu Aug  6 21:43:49 2020 user.info : wevent[1906]: wevent.ubnt_custom_event(): EVENT_STA_IP ath3: d8:bf:c0:c6:76:d6 / 172.22.21.202



..and the following from a FAILED Connection from 68:C6:3A:ED:4E:0E

Code: Select all
Thu Aug  6 21:44:51 2020 daemon.info hostapd: ath3: STA 96:83:c2:41:56:d8 DRIVER: Sead AUTH addr=68:c6:3a:ed:4e:0e status_code=0
Thu Aug  6 21:44:51 2020 kern.info kernel: [978619.657003] ieee80211_sta_leave: 68:c6:3a:ed:4e:0e
Thu Aug  6 21:44:59 2020 user.info : stahtd[1907]: [STA-TRACKER].stahtd_dump_event(): {"event_type":"failure","message_type":"STA_ASSOC_TRACKER","mac":"68:c6:3a:ed:4e:0e","assoc_status":"2048","vap":"ath0","event_id":"1","auth_ts":"978618.281021"} - n2whtctrl, flags: 0x800
Thu Aug  6 21:45:01 2020 user.info : stahtd[1907]: [STA-TRACKER].stahtd_dump_event(): {"event_type":"failure","message_type":"STA_ASSOC_TRACKER","mac":"68:c6:3a:ed:4e:0e","assoc_status":"0","vap":"ath3","auth_ts":"978619.633593","auth_failures":"1","event_id":"1"}
Thu Aug  6 21:45:06 2020 daemon.info hostapd: ath3: STA 96:83:c2:41:56:d8 DRIVER: Sead AUTH addr=68:c6:3a:ed:4e:0e status_code=0
Thu Aug  6 21:45:06 2020 kern.info kernel: [978634.708374] ieee80211_sta_leave: 68:c6:3a:ed:4e:0e



This was with an open network.

WiFiEventStationModeDisconnected says WIFI_DISCONNECT_REASON_ASSOC_FAIL


This is so strange to me. Why do these two ESP8266's behave differently with the same software? And, why can they connect to other access points but not these ones?

I also tried soft-setting the MAC address of the failing bulb on a NodeMCU, and the NodeMCU connected fine with that mac address.

I've also tried connecting to a different Unifi access point in a different room. Same exact issue -- all other bulbs connect fine to the other Unifi access point, but not these two.

I don't know how to proceed at this point, I've tried all I can think of. Any suggestions? Help would be much appreciated. :)

///Leif

Re: Strange ESP8266 WiFi connection failure with Unifi AP-AC

PostPosted: Fri Aug 07, 2020 11:43 am
by konbaasiang
I forgot to mention, I'm building with Sloeber, using ESP8266 Arduino Core version 2.7.1 and Espressif nonos-sdk 2.2.1+119 (191122).

Re: Strange ESP8266 WiFi connection failure with Unifi AP-AC

PostPosted: Tue Nov 17, 2020 10:24 am
by brunoricci
Well, it's never too late for a reply.

I have a similar problem with 2 out of 6 modules (i'm using WeMos D1 by the way, but the core is the same, ESP8266).
All of them connected OK in my home router, which is where I developed the firmware. When the devices were installed in the remote lab where they operate, the connection issues started. To begin with, the dedicated virtual AP wouldn't assign the IP to any device, which didn't happen in my home router.
Then, I changed some things and only got 3 of 5 devices properly connecting to the remote lab AP. The 6th device is here with me for testing and bug fixing purposes.

What I can tell you is that some WiFi libraries save the network credentials in a "reserved" memory region and every time you call WiFi.begin(); those values are stacked (yes, every single time) so the device will try all of them when it can't connect. I don't know how many different credentials are stored (i guess there's a maximum) but this could lead to errors.
Wait, there's more: you can disable this stacking feature with a command (look for it because i don't recall right now). I'm sure this will help.
Also, I recommend you to erase the flash and re-load the firmware. To do this, use esptool.py (you can install it from pip). Open the command prompt, go to the directory where Python is installed in your PC and then enter the folder "scripts", where the esptool.py is installed.

just like: cd "C:\user\appdata\Local\Python\Python37\Scripts"

and then, with the device connected to USB, put:

esptool.py erase_flash

it will take a few seconds. Then, put

esptool.py -b1000000 write_flash 0 "your_firmware.bin_directory"

(note that you should put YOUR firmware.bin directory; look where your compiler/IDE saves it)
-------
This procedure will erase all the flash, and then upload just the firmware real quick, removing all the possible "trash" in the memory which could come from the factory.

I hope being useful.