Fixes and improvements for ESP32 in AP mode:#295
Conversation
- Now correctly reports the device's IP in AP mode for UDP discovery requests. Previously reported as 0.0.0.0. - Split logic between AP mode and Infra modes since WiFi.status() returns a meaningless value in AP mode. AP mode now immediately establishes TCP/UDP servers. Server establishment moved to own function. - Also adds null-pointer guards to tcp/udp loop while servers are not established yet. Not relevant for AP mode, but included here due to simplicity. Tested on ESP32 in WIFI_MODE_AP_ONLY. This PR does NOT address the infrastructure modes or the WIFI_MODE_ATTEMPT_INFRASTRUCTURE_FAIL_TO_AP mode in particular, which has some issues in the failover trigger. Local changes are ready and can be included in future PRs if desired.
Code Review — "Fixes and improvements for ESP32 in AP mode"Scope: ESP32 Wi-Fi in Overview
The core AP-mode fix is correct and complete, and the refactor is clean. One real regression for the failover path, plus a couple of minor loose ends. Strengths
Issues & Risks1. [Important] Failover is now edge-triggered — likely regression for
|
- 1: Was included due to a bad reversion of local changes to the Infra mode. Suggested fix was applied. - 2: getStatus() now neither uses WiFi.status() nor WIFI_INFRASTRUCTURE_MODE_SSID in AP mode (both skipped) - 3: Not addressed in this PR. Will be included in future PR addressing infra modes. - 4: Now uses a DEFINE as the UDP port placeholder
- The tcpLoop now tracks the data sent across loop calls and only starts processing if the '#' character is received. - _mount->loop() is now called after every byte - Prevents memory overconsumption by defining a maximum size that should likely be large enough for commands. - Skips all '\n' and '\r' characters from the command string to prevent them from being processed. Should not influence the functionality since the Meade LX200 protocol does not seem to use them in any command. - 2: Added a log message if the softAP call fails to improve debugging.
ClutchplateDude
left a comment
There was a problem hiding this comment.
Thanks for your submission and fixes!
Tested on ESP32 in WIFI_MODE_AP_ONLY. This PR does NOT address the infrastructure modes or the WIFI_MODE_ATTEMPT_INFRASTRUCTURE_FAIL_TO_AP mode in particular, which has some issues in the failover trigger. Local changes are ready and can be included in future PRs if desired.