@@ -71,7 +71,7 @@ static const char _ssdp_packet_template[] PROGMEM =
71
71
" %s" // _ssdp_response_template / _ssdp_notify_template
72
72
" CACHE-CONTROL: max-age=%u\r\n " // SSDP_INTERVAL
73
73
" 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
75
75
" %s: %s\r\n " // "NT" or "ST", _deviceType
76
76
" LOCATION: http://%u.%u.%u.%u:%u/%s\r\n " // WiFi.localIP(), _port, _schemaURL
77
77
" \r\n " ;
@@ -99,7 +99,7 @@ static const char _ssdp_schema_template[] PROGMEM =
99
99
" <modelURL>%s</modelURL>"
100
100
" <manufacturer>%s</manufacturer>"
101
101
" <manufacturerURL>%s</manufacturerURL>"
102
- " <UDN>uuid: %s</UDN>"
102
+ " <UDN>%s</UDN>"
103
103
" </device>"
104
104
// "<iconList>"
105
105
// "<icon>"
@@ -130,8 +130,10 @@ SSDPClass::SSDPClass() :
130
130
_timer(0 ),
131
131
_port(80 ),
132
132
_ttl(SSDP_MULTICAST_TTL),
133
+ _respondToAddr(0 ,0 ,0 ,0 ),
133
134
_respondToPort(0 ),
134
135
_pending(false ),
136
+ _st_is_uuid(false ),
135
137
_delay(0 ),
136
138
_process_time(0 ),
137
139
_notify_time(0 )
@@ -155,12 +157,13 @@ SSDPClass::~SSDPClass() {
155
157
156
158
bool SSDPClass::begin () {
157
159
end ();
158
-
160
+
159
161
_pending = false ;
162
+ _st_is_uuid = false ;
160
163
if (strcmp (_uuid," " ) == 0 ) {
161
164
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 ),
164
167
(uint16_t ) ((chipId >> 8 ) & 0xff ),
165
168
(uint16_t ) chipId & 0xff );
166
169
}
@@ -178,7 +181,9 @@ bool SSDPClass::begin() {
178
181
IPAddress mcast (SSDP_MULTICAST_ADDR);
179
182
180
183
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
182
187
return false ;
183
188
}
184
189
@@ -241,7 +246,7 @@ void SSDPClass::_send(ssdp_method_t method) {
241
246
_modelNumber,
242
247
_uuid,
243
248
(method == NONE) ? " ST" : " NT" ,
244
- _deviceType,
249
+ (_st_is_uuid) ? _uuid : _deviceType,
245
250
ip[0 ], ip[1 ], ip[2 ], ip[3 ], _port, _schemaURL
246
251
);
247
252
@@ -373,10 +378,19 @@ void SSDPClass::_update() {
373
378
#ifdef DEBUG_SSDP
374
379
DEBUG_SSDP.printf (" REJECT: %s\n " , (char *)buffer);
375
380
#endif
381
+ }else {
382
+ _st_is_uuid = false ;
376
383
}
377
384
// if the search type matches our type, we should respond instead of ABORT
378
385
if (strcasecmp (buffer, _deviceType) == 0 ) {
379
386
_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 ;
380
394
_process_time = millis ();
381
395
state = KEY;
382
396
}
@@ -416,6 +430,7 @@ void SSDPClass::_update() {
416
430
_send (NONE);
417
431
} else if (_notify_time == 0 || (millis () - _notify_time) > (SSDP_INTERVAL * 1000L )){
418
432
_notify_time = millis ();
433
+ _st_is_uuid = false ;
419
434
_send (NOTIFY);
420
435
}
421
436
@@ -439,7 +454,7 @@ void SSDPClass::setDeviceType(const char *deviceType) {
439
454
}
440
455
441
456
void SSDPClass::setUUID (const char *uuid) {
442
- strlcpy (_uuid, uuid, sizeof (_uuid));
457
+ snprintf_P (_uuid, sizeof (_uuid), PSTR ( " uuid:%s " ), uuid );
443
458
}
444
459
445
460
void SSDPClass::setName (const char *name) {
0 commit comments