Skip to content

Commit d33bfcd

Browse files
committed
NAT re-init after band switch
1 parent 434d9db commit d33bfcd

4 files changed

Lines changed: 11 additions & 2 deletions

File tree

firmware_esp32c5/bootloader.bin

0 Bytes
Binary file not shown.

firmware_esp32c5/build_info.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ESP32 NAT Router Build Information
22
=================================
33
Target: ESP32-C5 (esp32c5)
4-
Build Time: 2026-05-27 11:35:32
5-
Git Hash: f0d5a14
4+
Build Time: 2026-05-28 17:47:33
5+
Git Hash: 434d9db
66
Binary Files: 4
77
Build Directory: build
48 Bytes
Binary file not shown.

main/esp32_nat_router.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,13 +692,22 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
692692
xTaskCreate(vpn_connect_task, "vpn_connect", 4096, NULL, 5, NULL);
693693
}
694694

695+
/* Re-enable NAPT here in case the AP cycled (channel change from
696+
* band-aware scan) after the initial ip_napt_enable in app_main. */
697+
if (ap_nat_enabled)
698+
ip_napt_enable(my_ap_ip, 1);
699+
695700
xEventGroupSetBits(wifi_event_group, WIFI_CONNECTED_BIT);
696701
}
697702
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_START)
698703
{
699704
ESP_LOGI(TAG, "AP started");
700705
// Initialize AP netif hooks now that interface is ready
701706
init_ap_netif_hooks();
707+
/* Re-enable NAPT on every AP start: covers the initial start and any
708+
* restart caused by the band-aware scan forcing a channel change. */
709+
if (ap_nat_enabled && my_ap_ip != 0)
710+
ip_napt_enable(my_ap_ip, 1);
702711
}
703712
else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_AP_STACONNECTED)
704713
{

0 commit comments

Comments
 (0)