Skip to content

Conversation

@bdraco
Copy link
Contributor

@bdraco bdraco commented Jan 25, 2026

Fix WiFi connection delays and watchdog resets on Realtek

Some users have been experiencing watchdog resets during WiFi connection. After investigating, found that wifi_connect_bssid() was scanning all channels even when we already know the target channel from the prior scan.

Changes

  • Use wifi_set_pscan_chan() to limit the SDK's internal scan to just the target channel when known
  • Add watchdog feeds before/after the blocking connect and DHCP calls

Before/After

Connect time dropped from ~2.8s to ~1.5s, total blocking from ~4s to ~2s. The watchdog feeds ensure no single blocking period exceeds ~1.5s.

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

before
[15:22:58.657]Interface 0 IP address : 192.168.107.178[W][component:546]: wifi took a long time for an operation (3785 ms)
after

[16:08:30.286]Interface 0 IP address : 192.168.107.178[W][component:546]: wifi took a long time for an operation (2686 ms)

Lot better now and no watchdog resets on the bad case

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

just need to boot it off the wifi and make sure it can still scan

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

all good, reconnects to a different bssid when I reboot the ap

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

looks like we have a bug in ESPHome on scan after forced disconnect 🙈

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

reconnect scan bug in esphome fixed as well esphome/esphome#13514

@bdraco bdraco marked this pull request as ready for review January 25, 2026 02:41
@kuba2k2
Copy link
Member

kuba2k2 commented Jan 25, 2026

The realtek-amb core is used on both RTL8720C and RTL8710B. I'll need to first check if it at least compiles on BN, since IIRC you're only able to test on BW15 (CF).

@bdraco
Copy link
Contributor Author

bdraco commented Jan 25, 2026

compiles ok with

esphome:
  name: wr2-test
  friendly_name: WR2 Test

rtl87xx:
  board: wr2
  framework:
    version: 1.10.0
    source: /Users/bdraco/libretiny

logger:
  level: VERBOSE

api:

ota:
  - platform: esphome

debug:
  update_interval: 5s

sensor:
  - platform: debug
    free:
      name: "Free Heap"
    min_free:
      name: "Min Free Heap"
    loop_time:
      name: "Loop Time"

text_sensor:
  - platform: debug
    reset_reason:
      name: "Reset Reason"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:

But don't have the hardware to validate on

@kuba2k2 kuba2k2 changed the title realtek-amb: Fix WiFi connection delays and watchdog resets Jan 25, 2026
@kuba2k2 kuba2k2 changed the title [realtek-amb] Fix WiFi connection delays and watchdog resets Jan 25, 2026
@kuba2k2 kuba2k2 added enhancement New feature or request RTL8710B Realtek RTL87xxB family labels Jan 25, 2026
@kuba2k2 kuba2k2 merged commit e28777d into libretiny-eu:master Jan 25, 2026
2 checks passed
@kuba2k2 kuba2k2 added the RTL8720C Realtek RTL87xxC family label Jan 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request RTL8710B Realtek RTL87xxB family RTL8720C Realtek RTL87xxC family

2 participants