[beken-72xx] Keep 802.11n enabled at weak RSSI#392
Open
rmounce wants to merge 2 commits into
Open
Conversation
The rwnx blob disables the STA's HT capability before association when the join-scan result's RSSI is below a threshold defaulting to -50 dBm, falling back to an 802.11g-only association. Define the SDK's weak threshold hook (rwnx_get_noht_rssi_thresold) so the threshold can be set at build time via LT_BK_NOHT_RSSI_THRESHOLD. No behavior change by default. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
-50 dBm is a signal level most real-world devices don't reach, so in practice the vendor default leaves most BK72xx devices on 802.11g, and the racy HT recovery makes the resulting mode intermittent across reboots. Default the threshold to -100 dBm so HT stays enabled at any usable signal level. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
rmounce
force-pushed
the
fix-bk72xx-noht-rssi-threshold
branch
from
July 14, 2026 06:47
d32e21f to
500b3b2
Compare
rmounce
marked this pull request as ready for review
July 14, 2026 07:43
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
BK72xx STAs frequently associate as 802.11g-only (no HT capability in the association request) even though the chip and AP both support 802.11n. Whether a given boot ends up on 11n or 11g appears random, and power-cycling does not reliably change it. The UART logs in #297 show the same signature (
no ht in scanfollowed by a legacy association).Root cause
Disassembly of
scanu.oinlibrwnx_bk7231u.a(the same code is present in the bk7231n and bk7251 libs) shows:scanu_frame_handlerpasses the RSSI of the join-scan result frame toscanu_change_ht_supported().scanu_change_ht_supported()compares it against a threshold obtained fromrwnx_get_noht_rssi_thresold()— a weak hook declared inbeken378/ip/lmac/src/rwnx/rwnx_config.h:522and defined nowhere — falling back to a hardcoded -50 dBm. If the scan frame is weaker, it clearsme_env.ht_supported(UART log:dis ht_support), so the subsequent association request omits the HT capability IE and the STA associates as 802.11g.scanu_recover_ht_supported, called fromscanu_start), andsm_assoc_rsp_handlerseparately latches anis_n_only_modeflag that suppresses the disable path — which is why the resulting mode is racy/intermittent rather than deterministic.-50 dBm is a signal level most real-world devices don't reach, so in practice most BK72xx devices run 11g most of the time.
Fix
Define the SDK's weak threshold hook with a -100 dBm default, overridable via
-DLT_BK_NOHT_RSSI_THRESHOLD(e.g.-50to restore the vendor behavior). The blob truncates the return value to signed 8-bit, so valid values are -128..-1.The definition lives in
fixups/wlan_ui.crather than its own file: the blob's reference to the hook is weak, and a weak reference does not extract a standalone member from the fixups archive (verified — in a separate file the object compiles but is not linked). It is itself marked__attribute__((weak))so user code can still provide its own definition.Verification
Tested on a BK7231T Tuya bulb (ESPHome 2026.5.3, LibreTiny 1.13.0) at -70 dBm against OpenWrt APs (MT7622, 2.4 GHz HT20):
[WMM]only (hostapd station flags) after most reboots, 11g rates.[WMM][HT]deterministically across reboots, MCS rates in use. DTIM WiFi power save unaffected.🤖 Generated with Claude Code