Giter Site home page Giter Site logo

[BUG] WiFi problems on OpenWrt about bsb-lan HOT 14 CLOSED

WMP avatar WMP commented on June 18, 2024
[BUG] WiFi problems on OpenWrt

from bsb-lan.

Comments (14)

BraweProg avatar BraweProg commented on June 18, 2024

"WIFI_PROTOCOL_LR" is the long range protocol from espressif and only works, if both partners are of ESP32-WROOM type. Makes only sense, if the distance is too long for the other protocols.

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

I'm surprised that OpenWRT is creating these problems (@BraweProg: You were also using OpenWRT, correct?), but there are no problems when using a Fritz!Box, for example. While I would like to support the most compatible WiFi-Setting for all routers, I have no other router than a FB myself, so I cannot test any of this, so there is no way for me to help here except adding code that works for you as well as for me and then include such a solution into BSB-LAN.

If you say that you have to enable mixed WPA/WPA2 PSK in order to get it to work, this probably means that the connection falls back to WPA, right? But then I don't understand why option 4 doesn't work which is also mixed WPA/WPA2 PSK.

But as @BraweProg mentioned, remove WIFI_PROTOCOL_LR first. I will remove this probably even from in the commented-out form because the benefits probably do not outweigh the potential problems. Users with a long distance to the router should rather use an additional WiFi repeater.

from bsb-lan.

WMP avatar WMP commented on June 18, 2024

If you say that you have to enable mixed WPA/WPA2 PSK in order to get it to work, this probably means that the connection falls back to WPA, right? But then I don't understand why option 4 doesn't work which is also mixed WPA/WPA2 PSK.

In https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html?highlight=wifi_protocol_lr#lr-transmission-distance i read:

LR Transmission Distance
The reception sensitivity gain of LR is about 4 dB larger than that of the traditional 802.11b mode. Theoretically, the transmission distance is about 2 to 2.5 times the distance of 11B.

In OpenWRT versions up to 21.02, you can set:
hwmode: Specifies the hardware mode, possible values are 11b for 2.4 GHz (used for legacy 802.11b only).
As of version 21.02, this option is deprecated:
hwmode: Specifies the hardware mode, possible values are 11b for 2.4 GHz (used for legacy 802.11b only)... (DEPRECATED since 21.02.2, replaced with band)
band: Specifies the band, possible values are 2g for 2.4 GHz, 5g for 5 GHz, 6g for 6 GHz and 60g for 60 GHz. (NEW since 21.02.2, replaces hwmode)

In addition, to enable legacy 802.11b only you have to use an option (which I don't know if it works in version 22.03):
legacy_rates: 0 = Disallow legacy 802.11b data rates (default from 21.02), 1 = Allow legacy 802.11b data rates (default to 21.02).

So, as of version 21.02, by default OpenWrt does not support 802.11b, so you can't connect to the LR option.

Looking through the documentation I noticed that there is an option https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html?highlight=wifi_protocol_lr#wi-fi-protocol-mode : 802.11 BGNLR and I thinks that it is the one that should be used.

A better question is why BSB-LAN does not connect if cipher: auto is set on the router.

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

Thanks for the detailed infos, unfortunately I'm not a WiFi-tech kind of guy. However, I find it strange that a router would completely abandon an older, but still functional transmission standard. This would render quite a few older devices in my household unusable. Maybe in line with this, the ESP32 is offering a default cipher that OpenWRT does not accept (anymore) and doesn't try another one by itself.

In any case, it would be great if you and @BraweProg could figure out which setting works fastest with current OpenWRT routers. Priority here is, as mentioned before, transmission speed due to the already rather slow transmission speed for graph display etc.

from bsb-lan.

WMP avatar WMP commented on June 18, 2024

figure out which setting works fastest with current OpenWRT routers

Do you mean the settings in the BSB-LAN code? Can you provide the documentation in which the possible settings and options are described?

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

I mean the esp_wifi_set_protocol commands mentioned above. I don't know which of these protocol settings are the most reliable and fastest ones, so you two would have to come to a consensus and that will be the one I'll add to the code.

from bsb-lan.

BraweProg avatar BraweProg commented on June 18, 2024

Unfortunately I'm not using openwrt nor have any experience with that. My router is a Fritzbox, but, because of the too long distance between the router and BSB-LAN I have installed an ESP-IOT-Bridge (https://github.com/espressif/esp-iot-bridge) in between. Both, the bridge and BSB-LAN are basing on ESP32-EVB with ESP32Wroom chip. This, and only this one, supports the LR protocol. NodeMCU has the same chip. If you are running openwrt on a board with another MCU than ESP32Wroom, LR communication would not work.
Principially the wifi STA initialization applies for the AP mode as well. So, if you are choosing LR mode for STA, you would have to set it back again for the AP mode. Otherwise you cannot establish a connection to the AP from another device. That is the reason for:
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);

If you don't use the LR initialization, you would not need to go back to 11bgn. LR did not solve my wifi distance problem, so currently I'm no longer using it. With 11bgn I'm getting -69dBm from the bridge, which is not much and it is slow. The graphical log for 2 days and a sample rate of 600s takes 2 minutes (through the bridge).
Did you test the AP behaviour and the beacon values? I'm getting b11/g54/n72 and WPA2(AES/TKIP) 20Mhz. Disadvantage with the AP is that the BSB-LAN cannot draw a graphic log due to the missing internet connection.

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

Ok, I'll then remove the LR settings from the code if it is only used in this configuration and will keep the 20MHz in place.

from bsb-lan.

WMP avatar WMP commented on June 18, 2024

I, on the other hand, have a server room in a boiler room, so the distance from ap to bsb-lan is 3m. I am not able to test the speed, at my place everything is very fast. In theory, the younger the wifi protocol and the higher the MHz range the faster.

I am most interested in encryption, why only AES works. Where is the code that is responsible for encryption? Bsb-lan uses esp-idf or Arduino?

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

It uses the Arduino-Framework of ESP. BSB-LAN just uses the standard libraries and function calls, so such specific details would have to be addressed elsewhere.

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

@WMP and @BraweProg: I now also have an issue with my WiFi here which seems kind of strange and possibly related to the issues raised here:
My setup is that I have a router in the basement (FritzBox 7590 AX, just a 2 meters through a wall from BSB-LAN), a repeater (FritzRepeater 1750E) on the ground floor and a second router (FritzBox 7590) on the first floor. All are working together in a Mesh. The signal strength of the basement router is -33 dBm, the one on the top floor is -71 dBm and the repeater on the ground floor is -72 dBm (although it's quite a bit closer to BSB-LAN than the router on the first floor).

Sometimes the connection to the basement router is lost and the ESP32 automatically reconnects to the next available network which sometimes happens to be the repeater. It immediately gets the (same) IP and is associated, but no IP traffic is possible. In case it connects to the router on the first floor, there is no problem accessing BSB-LAN.

I'm now wondering whether the fact that just 1 dBm difference can result in such a behaviour or whether there is something similiar going on as we have discussed here. I will add a function for BSB-LAN to connect to the strongest network available, but if it's a repeater-related issue, then this may just be an individual workaround.

Do you have any ideas?

from bsb-lan.

WMP avatar WMP commented on June 18, 2024

What encryption do you have, which WiFi standard? Any logs?

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

This is the log of a connection to the repeater:

[   324][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[   420][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1                       
[   420][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started               
[   427][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START 
Setting up WiFi interface
[   453][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: Holst, BSSID: f0:b0:14:5e:49:cb, Reason: 202             
[   454][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED                                                                          
[   461][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 202 - AUTH_FAIL      
[   468][D][WiFiGeneric.cpp:966] _eventCallback(): WiFi Reconnect Running.
[   549][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: Holst, BSSID: f0:b0:14:5e:49:cb, Channel: 1, Auth: WPA2_PSK                         
[   550][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED                                                                             
[   554][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.50                                                                               
[   565][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[   572][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1                                                   .                                                                               
Attempting to connect to WPA SSID: Holst
[   647][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: Holst, BSSID: f0:b0:14:5e:49:cb, Reason: 8
[   650][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED                                                                          
[   657][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 8 - ASSOC_LEAVE      
[   703][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: Holst, BSSID: f0:b0:14:5e:49:cb, Channel: 1, Auth: WPA2_PSK                          
[   706][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED                                                                             
[   710][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got Same IP:192.168.1.50                                                                              
[   719][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[   726][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1                                                   

and this is a log when connecting to the router:

[   324][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[   420][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1                       
[   420][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started               
[   427][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START 
Setting up WiFi interface
[   505][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: Holst, BSSID: 1c:ed:6f:ff:71:3e, Channel: 11, Auth: WPA2_PSK
[   507][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED                                                                             
[   510][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.50                                                                               
[   521][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[   528][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1   
Attempting to connect to WPA SSID: Holst
[  7236][V][WiFiGeneric.cpp:360] _arduino_event_cb(): STA Disconnected: SSID: Holst, BSSID: 1c:ed:6f:ff:71:3e, Reason: 8
[  7242][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 5 - STA_DISCONNECTED                                                                          
[  7245][W][WiFiGeneric.cpp:950] _eventCallback(): Reason: 8 - ASSOC_LEAVE      
[  7280][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: Holst, BSSID: 1c:ed:6f:ff:71:3e, Channel: 11, Auth: WPA2_PSK                         
[  7281][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED                                                                             
[  7284][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got Same IP:192.168.1.50                                                                              
[  7296][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[  7303][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.50, MASK: 255.255.255.0, GW: 192.168.1.1                                                   

So it's pretty much the same except for the different BSSID...

from bsb-lan.

fredlcore avatar fredlcore commented on June 18, 2024

WiFi security is set to WPA2 (CCMP), which is one of the two options available on the FritzBox. I'm not sure why I don't use the better one, WPA2 + WPA3, could be because of the ESP32, but also some of the other, sometimes quite old devices I have running here in my home...
EDIT: I think I remember now: WPA2 + WPA3 requires also for WPA2 devices to support Protected Management Frames. At least one of the devices I'm using (could be one of the ESP32 devices, I have a few Shellys here as well in addition to BSB-LAN) does not support Protected Management Frames and thus I had to take the less secure WPA2 (CCMP) option. Have you checked if Protected Management Frames could be an issue with you as well?

from bsb-lan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.