@@ -71,7 +71,7 @@ static const char _ssdp_packet_template[] PROGMEM =
7171 " %s" // _ssdp_response_template / _ssdp_notify_template
7272 " CACHE-CONTROL: max-age=%u\r\n " // SSDP_INTERVAL
7373 " SERVER: Arduino/1.0 UPNP/1.1 %s/%s\r\n " // _modelName, _modelNumber
74- " USN: uuid: %s\r\n " // _uuid
74+ " USN: %s\r\n " // _uuid
7575 " %s: %s\r\n " // "NT" or "ST", _deviceType
7676 " LOCATION: http://%u.%u.%u.%u:%u/%s\r\n " // WiFi.localIP(), _port, _schemaURL
7777 " \r\n " ;
@@ -99,7 +99,7 @@ static const char _ssdp_schema_template[] PROGMEM =
9999 " <modelURL>%s</modelURL>"
100100 " <manufacturer>%s</manufacturer>"
101101 " <manufacturerURL>%s</manufacturerURL>"
102- " <UDN>uuid: %s</UDN>"
102+ " <UDN>%s</UDN>"
103103 " </device>"
104104 // "<iconList>"
105105 // "<icon>"
@@ -130,8 +130,10 @@ SSDPClass::SSDPClass() :
130130 _timer(0 ),
131131 _port(80 ),
132132 _ttl(SSDP_MULTICAST_TTL),
133+ _respondToAddr(0 ,0 ,0 ,0 ),
133134 _respondToPort(0 ),
134135 _pending(false ),
136+ _st_is_uuid(false ),
135137 _delay(0 ),
136138 _process_time(0 ),
137139 _notify_time(0 )
@@ -155,12 +157,13 @@ SSDPClass::~SSDPClass() {
155157
156158bool SSDPClass::begin () {
157159 end ();
158-
160+
159161 _pending = false ;
162+ _st_is_uuid = false ;
160163 if (strcmp (_uuid," " ) == 0 ) {
161164 uint32_t chipId = ESP.getChipId ();
162- sprintf (_uuid, " 38323636-4558-4dda-9188-cda0e6%02x%02x%02x" ,
163- (uint16_t ) ((chipId >> 16 ) & 0xff ),
165+ sprintf_P (_uuid, PSTR ( " uuid: 38323636-4558-4dda-9188-cda0e6%02x%02x%02x" ) ,
166+ (uint16_t ) ((chipId >> 16 ) & 0xff ),
164167 (uint16_t ) ((chipId >> 8 ) & 0xff ),
165168 (uint16_t ) chipId & 0xff );
166169 }
@@ -178,7 +181,9 @@ bool SSDPClass::begin() {
178181 IPAddress mcast (SSDP_MULTICAST_ADDR);
179182
180183 if (igmp_joingroup (local, mcast) != ERR_OK ) {
181- DEBUGV (" SSDP failed to join igmp group" );
184+ #ifdef DEBUG_SSDP
185+ DEBUG_SSDP.printf_P (PSTR (" SSDP failed to join igmp group\n " ));
186+ #endif
182187 return false ;
183188 }
184189
@@ -241,7 +246,7 @@ void SSDPClass::_send(ssdp_method_t method) {
241246 _modelNumber,
242247 _uuid,
243248 (method == NONE) ? " ST" : " NT" ,
244- _deviceType,
249+ (_st_is_uuid) ? _uuid : _deviceType,
245250 ip[0 ], ip[1 ], ip[2 ], ip[3 ], _port, _schemaURL
246251 );
247252
@@ -373,10 +378,19 @@ void SSDPClass::_update() {
373378#ifdef DEBUG_SSDP
374379 DEBUG_SSDP.printf (" REJECT: %s\n " , (char *)buffer);
375380#endif
381+ }else {
382+ _st_is_uuid = false ;
376383 }
377384 // if the search type matches our type, we should respond instead of ABORT
378385 if (strcasecmp (buffer, _deviceType) == 0 ) {
379386 _pending = true ;
387+ _st_is_uuid = false ;
388+ _process_time = millis ();
389+ state = KEY;
390+ }
391+ if (strcasecmp (buffer, _uuid) == 0 ) {
392+ _pending = true ;
393+ _st_is_uuid = true ;
380394 _process_time = millis ();
381395 state = KEY;
382396 }
@@ -416,6 +430,7 @@ void SSDPClass::_update() {
416430 _send (NONE);
417431 } else if (_notify_time == 0 || (millis () - _notify_time) > (SSDP_INTERVAL * 1000L )){
418432 _notify_time = millis ();
433+ _st_is_uuid = false ;
419434 _send (NOTIFY);
420435 }
421436
@@ -439,7 +454,7 @@ void SSDPClass::setDeviceType(const char *deviceType) {
439454}
440455
441456void SSDPClass::setUUID (const char *uuid) {
442- strlcpy (_uuid, uuid, sizeof (_uuid));
457+ snprintf_P (_uuid, sizeof (_uuid), PSTR ( " uuid:%s " ), uuid );
443458}
444459
445460void SSDPClass::setName (const char *name) {
0 commit comments