Merge pull request #5489 from wled/copilot/fix-wled-discovery-issues

Fix Alexa/Hue discovery by correcting SSDP response to match UPnP spec
This commit is contained in:
Will Tatam
2026-04-10 18:25:31 +01:00
parent 8228c7eea4
commit 19947ec07e

View File

@@ -85,6 +85,7 @@ private:
IPAddress ipMulti;
uint32_t mac24; //bottom 24 bits of mac
String escapedMac=""; //lowercase mac address
String bridgeId=""; //uppercase EUI-64 bridge ID (16 hex chars)
//private member functions
const char* modeString(EspalexaColorMode m)
@@ -297,13 +298,13 @@ private:
snprintf_P(buf, sizeof(buf), PSTR("HTTP/1.1 200 OK\r\n"
"EXT:\r\n"
"CACHE-CONTROL: max-age=100\r\n" // SSDP_INTERVAL
"CACHE-CONTROL: max-age=86400\r\n" // SSDP_INTERVAL
"LOCATION: http://%s:80/description.xml\r\n"
"SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/1.17.0\r\n" // _modelName, _modelNumber
"hue-bridgeid: %s\r\n"
"ST: urn:schemas-upnp-org:device:basic:1\r\n" // _deviceType
"USN: uuid:2f402f80-da50-11e1-9b23-%s::upnp:rootdevice\r\n" // _uuid::_deviceType
"\r\n"),s,escapedMac.c_str(),escapedMac.c_str());
"ST: urn:schemas-upnp-org:device:Basic:1\r\n" // _deviceType
"USN: uuid:2f402f80-da50-11e1-9b23-%s::urn:schemas-upnp-org:device:Basic:1\r\n" // _uuid::_deviceType
"\r\n"),s,bridgeId.c_str(),escapedMac.c_str());
espalexaUdp.beginPacket(espalexaUdp.remoteIP(), espalexaUdp.remotePort());
#ifdef ARDUINO_ARCH_ESP32
@@ -333,6 +334,11 @@ public:
escapedMac.replace(":", "");
escapedMac.toLowerCase();
// Compute EUI-64 bridge ID from MAC-48: insert standard "FFFE" padding between
// the first 6 hex chars (OUI/manufacturer) and last 6 hex chars (device), then uppercase
bridgeId = escapedMac.substring(0, 6) + "fffe" + escapedMac.substring(6);
bridgeId.toUpperCase();
String macSubStr = escapedMac.substring(6, 12);
mac24 = strtol(macSubStr.c_str(), 0, 16);