Skip to content

Commit bcdf0ce

Browse files
netmindzsofthack007
authored andcommitted
Merge pull request wled#5489 from wled/copilot/fix-wled-discovery-issues
Fix Alexa/Hue discovery by correcting SSDP response to match UPnP spec
1 parent 6ed771b commit bcdf0ce

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

wled00/src/dependencies/espalexa/Espalexa.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class Espalexa {
8585
IPAddress ipMulti;
8686
uint32_t mac24; //bottom 24 bits of mac
8787
String escapedMac=""; //lowercase mac address
88+
String bridgeId=""; //uppercase EUI-64 bridge ID (16 hex chars)
8889

8990
//private member functions
9091
const char* modeString(EspalexaColorMode m)
@@ -297,13 +298,13 @@ class Espalexa {
297298

298299
snprintf_P(buf, sizeof(buf), PSTR("HTTP/1.1 200 OK\r\n"
299300
"EXT:\r\n"
300-
"CACHE-CONTROL: max-age=100\r\n" // SSDP_INTERVAL
301+
"CACHE-CONTROL: max-age=86400\r\n" // SSDP_INTERVAL
301302
"LOCATION: http://%s:80/description.xml\r\n"
302303
"SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/1.17.0\r\n" // _modelName, _modelNumber
303304
"hue-bridgeid: %s\r\n"
304-
"ST: urn:schemas-upnp-org:device:basic:1\r\n" // _deviceType
305-
"USN: uuid:2f402f80-da50-11e1-9b23-%s::upnp:rootdevice\r\n" // _uuid::_deviceType
306-
"\r\n"),s,escapedMac.c_str(),escapedMac.c_str());
305+
"ST: urn:schemas-upnp-org:device:Basic:1\r\n" // _deviceType
306+
"USN: uuid:2f402f80-da50-11e1-9b23-%s::urn:schemas-upnp-org:device:Basic:1\r\n" // _uuid::_deviceType
307+
"\r\n"),s,bridgeId.c_str(),escapedMac.c_str());
307308

308309
espalexaUdp.beginPacket(espalexaUdp.remoteIP(), espalexaUdp.remotePort());
309310
#ifdef ARDUINO_ARCH_ESP32
@@ -333,6 +334,11 @@ class Espalexa {
333334
escapedMac.replace(":", "");
334335
escapedMac.toLowerCase();
335336

337+
// Compute EUI-64 bridge ID from MAC-48: insert standard "FFFE" padding between
338+
// the first 6 hex chars (OUI/manufacturer) and last 6 hex chars (device), then uppercase
339+
bridgeId = escapedMac.substring(0, 6) + "fffe" + escapedMac.substring(6);
340+
bridgeId.toUpperCase();
341+
336342
String macSubStr = escapedMac.substring(6, 12);
337343
mac24 = strtol(macSubStr.c_str(), 0, 16);
338344

0 commit comments

Comments
 (0)