Fix ESP-IDF server-initiated discovery#70
Open
kyvaith wants to merge 3 commits into
Open
Conversation
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.
Summary
Fixes two closely related discovery/connection problems seen with an ESP32-P4 ESP-IDF 6.0.1 device using Sendspin as an ESPHome component.
client/hellofrom the accepted-connection path, not only from the later HTTP GET callback.SendspinClientConfig::client_idempty, the client now falls back to the detected local network interface MAC address, matching the value advertised indevice_info.mac_address.Root cause
On ESP-IDF HTTPD, the WebSocket upgrade can complete and the connection can be accepted before the initial HTTP GET path reliably drives the existing
on_connected_cbpath. In that state the server gets a valid WebSocket connection, but noclient/hello, so discovery appears flaky or the speaker appears only transiently.For ESP32-P4 boards using hosted Wi-Fi, the active network interface MAC can also differ from the chip base MAC. Using the active interface MAC as the fallback client identity avoids requiring each integration to duplicate platform-specific MAC detection.
Validation
Tested on an ESP32-P4 ESPHome device with ESP-IDF 6.0.1:
ws://device:8928/sendspinreturnsclient/helloimmediately after WebSocket upgrade.client_idanddevice_info.mac_addressuse the hosted Wi-Fi STA MAC.Host CMake tests were not run locally because this Windows environment does not have a host C++ compiler on PATH. The available ESPHome firmware build using this branch compiled and ran on-device.
Documentation
No docs change: this is a transport/identity fallback fix and does not add a user-facing configuration option.