meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3.37k stars 824 forks source link

[Bug]: Wifi hardcoded to 40mhz channel width, wifi unstable when router doesn't support it. #3546

Closed weirdal3333 closed 6 months ago

weirdal3333 commented 6 months ago

Category

WiFi

Hardware

T-Beam

Firmware Version

2.3.2.63df972

Description

The esp32 has a hardcoded 40mhz channel width. This causes MAJOR issues when connecting to a hotspot that only supports 20mhz channels, or has 40mhz channels disabled. Some users report unstable wifi connections. My router (ddwrt) has logged over 50,000 dropped packets PER DAY for my tbeam due to this issue. THese devices don't need that much bandwidth, and routers with a 40mhz channel width know how to communicate with simpler devices that don't support it. image image

Proposed solution

Set channel width to auto, or 20mhz. Routers with a 40mhz channel width know how to talk to devices that only support 20mhz without issues.

Relevant log output

No response

caveman99 commented 6 months ago

I don't see how we (the meshtastic project) can change a value built into ESP32 silicone (or at least a binary blob wifi firmware). This part of the toolchain is not even open source.

weirdal3333 commented 6 months ago

Why did you close this? I found a working fix with the help of someone on the discord.

insert this at line 240 in file firmware/src/mesh/wifi/WiFiAPClient.cpp: esp_wifi_set_bandwidth(WIFI_IF_STA,WIFI_BW_HT20);

todd-herbert commented 6 months ago

Adding that line of code would break a lot of ESP32-S3 devices. If you were to implement 20MHz channel width, you would need to ensure that it is only set for the older ESP32 devices.

In theory that would be possible, but it makes the assumption that all existing users would be okay with the change. I myself would worry about breaking someone else's particular setup with a seemingly innocent change. If it were to go ahead, I would consider making the 20MHz channel width an opt-in config, as a precaution.

It may even be enough to wrap the line of code in a macro, allowing advanced users to easily select it when building from source. I imagine that most users aware of the 40MHz / 20MHz distinction are probably capable of building their own firmware, and may already be doing so.