diff --git a/libraries/ESP8266SSDP/ESP8266SSDP.cpp b/libraries/ESP8266SSDP/ESP8266SSDP.cpp index 900c2059fe..aed49929d5 100644 --- a/libraries/ESP8266SSDP/ESP8266SSDP.cpp +++ b/libraries/ESP8266SSDP/ESP8266SSDP.cpp @@ -73,7 +73,7 @@ static const char _ssdp_packet_template[] PROGMEM = "SERVER: Arduino/1.0 UPNP/1.1 %s/%s\r\n" // _modelName, _modelNumber "USN: %s\r\n" // _uuid "%s: %s\r\n" // "NT" or "ST", _deviceType - "LOCATION: http://%u.%u.%u.%u:%u/%s\r\n" // WiFi.localIP(), _port, _schemaURL + "LOCATION: http://%s:%u/%s\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n"; static const char _ssdp_schema_template[] PROGMEM = @@ -88,7 +88,7 @@ static const char _ssdp_schema_template[] PROGMEM = "1" "0" "" - "http://%u.%u.%u.%u:%u/" // WiFi.localIP(), _port + "http://%s:%u/" // WiFi.localIP(), _port "" "%s" "%s" @@ -247,7 +247,7 @@ void SSDPClass::_send(ssdp_method_t method) { _uuid, (method == NONE) ? "ST" : "NT", (_st_is_uuid) ? _uuid : _deviceType, - ip[0], ip[1], ip[2], ip[3], _port, _schemaURL + ip.toString().c_str(), _port, _schemaURL ); _server->append(buffer, len); @@ -276,12 +276,12 @@ void SSDPClass::_send(ssdp_method_t method) { _server->send(remoteAddr, remotePort); } -void SSDPClass::schema(WiFiClient client) { +void SSDPClass::schema(Print &client) const { IPAddress ip = WiFi.localIP(); char buffer[strlen_P(_ssdp_schema_template) + 1]; strcpy_P(buffer, _ssdp_schema_template); client.printf(buffer, - ip[0], ip[1], ip[2], ip[3], _port, + ip.toString().c_str(), _port, _deviceType, _friendlyName, _presentationURL, diff --git a/libraries/ESP8266SSDP/ESP8266SSDP.h b/libraries/ESP8266SSDP/ESP8266SSDP.h index 5fbbf59364..ec7c86e2b5 100644 --- a/libraries/ESP8266SSDP/ESP8266SSDP.h +++ b/libraries/ESP8266SSDP/ESP8266SSDP.h @@ -62,7 +62,8 @@ class SSDPClass{ ~SSDPClass(); bool begin(); void end(); - void schema(WiFiClient client); + void schema(WiFiClient client) const { schema((Print&)std::ref(client)); } + void schema(Print &print) const; void setDeviceType(const String& deviceType) { setDeviceType(deviceType.c_str()); } void setDeviceType(const char *deviceType);