Skip to content

Commit 8d54646

Browse files
[SSDP] add schema(Print &) const
Supercedes esp8266#2806 Make SSDP::schema(WiFiClient&) use a by-ref (reduce stack use) Add a SSDP::schema(Print&) From @Palatis' original PR: useful when using AsyncWebServer.
1 parent 01e9d94 commit 8d54646

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

libraries/ESP8266SSDP/ESP8266SSDP.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ void SSDPClass::_send(ssdp_method_t method) {
276276
_server->send(remoteAddr, remotePort);
277277
}
278278

279-
void SSDPClass::schema(WiFiClient client) {
279+
void SSDPClass::schema(WiFiClient &client) const {
280280
IPAddress ip = WiFi.localIP();
281281
char buffer[strlen_P(_ssdp_schema_template) + 1];
282282
strcpy_P(buffer, _ssdp_schema_template);
@@ -295,6 +295,22 @@ void SSDPClass::schema(WiFiClient client) {
295295
);
296296
}
297297

298+
void SSDPClass::schema(Print &print) const {
299+
uint32_t ip = WiFi.localIP();
300+
print.printf(_ssdp_schema_template,
301+
IP2STR(&ip), _port,
302+
_deviceType,
303+
_friendlyName,
304+
_presentationURL,
305+
_serialNumber,
306+
_modelName,
307+
_modelNumber,
308+
_modelURL,
309+
_manufacturer,
310+
_manufacturerURL,
311+
_uuid
312+
);
313+
}
298314
void SSDPClass::_update() {
299315
if (!_pending && _server->next()) {
300316
ssdp_method_t method = NONE;

libraries/ESP8266SSDP/ESP8266SSDP.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ class SSDPClass{
6262
~SSDPClass();
6363
bool begin();
6464
void end();
65-
void schema(WiFiClient client);
65+
void schema(WiFiClient &client) const;
66+
void schema(Print &print) const;
6667
void setDeviceType(const String& deviceType) { setDeviceType(deviceType.c_str()); }
6768
void setDeviceType(const char *deviceType);
6869

0 commit comments

Comments
 (0)