diff --git a/libraries/ESP8266SSDP/ESP8266SSDP.cpp b/libraries/ESP8266SSDP/ESP8266SSDP.cpp index a63441537..755021f1d 100644 --- a/libraries/ESP8266SSDP/ESP8266SSDP.cpp +++ b/libraries/ESP8266SSDP/ESP8266SSDP.cpp @@ -56,16 +56,16 @@ static const IPAddress SSDP_MULTICAST_ADDR(239, 255, 255, 250); -static const char* _ssdp_response_template = +static const char _ssdp_response_template[] PROGMEM = "HTTP/1.1 200 OK\r\n" "EXT:\r\n"; -static const char* _ssdp_notify_template = +static const char _ssdp_notify_template[] PROGMEM = "NOTIFY * HTTP/1.1\r\n" "HOST: 239.255.255.250:1900\r\n" "NTS: ssdp:alive\r\n"; -static const char* _ssdp_packet_template = +static const char _ssdp_packet_template[] PROGMEM = "%s" // _ssdp_response_template / _ssdp_notify_template "CACHE-CONTROL: max-age=%u\r\n" // SSDP_INTERVAL "SERVER: Arduino/1.0 UPNP/1.1 %s/%s\r\n" // _modelName, _modelNumber @@ -74,7 +74,7 @@ static const char* _ssdp_packet_template = "LOCATION: http://%u.%u.%u.%u:%u/%s\r\n" // WiFi.localIP(), _port, _schemaURL "\r\n"; -static const char* _ssdp_schema_template = +static const char _ssdp_schema_template[] PROGMEM = "HTTP/1.1 200 OK\r\n" "Content-Type: text/xml\r\n" "Connection: close\r\n" @@ -201,9 +201,12 @@ void SSDPClass::_send(ssdp_method_t method){ char buffer[1460]; uint32_t ip = WiFi.localIP(); - int len = snprintf(buffer, sizeof(buffer), + char valueBuffer[strlen_P(_ssdp_notify_template)+1]; + strcpy_P(valueBuffer, (method == NONE)?_ssdp_response_template:_ssdp_notify_template); + + int len = snprintf_P(buffer, sizeof(buffer), _ssdp_packet_template, - (method == NONE)?_ssdp_response_template:_ssdp_notify_template, + valueBuffer, SSDP_INTERVAL, _modelName, _modelNumber, _uuid, @@ -240,7 +243,9 @@ void SSDPClass::_send(ssdp_method_t method){ void SSDPClass::schema(WiFiClient client){ uint32_t ip = WiFi.localIP(); - client.printf(_ssdp_schema_template, + char buffer[strlen_P(_ssdp_schema_template)+1]; + strcpy_P(buffer, _ssdp_schema_template); + client.printf(buffer, IP2STR(&ip), _port, _deviceType, _friendlyName,