Skip to content

Fix ssdp #5750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 21, 2019
Merged

Fix ssdp #5750

merged 9 commits into from
Mar 21, 2019

Conversation

Lan-Hekary
Copy link
Contributor

Hello,
I noticed that the SSDP library always respond to the M-Search Packet with its Device type ..
and does not respond to UUID Search ..
such behavior prevents the other devices from querying the specific device (Such as Windows Network Discovery)
the Properties was returning an error beacuse of this bug
image

I fixed it without breaking compatibility and tested it thoroughly ..

Fix SSDP bug: The response to M-Search Packet with ST field set to UUID should be with the UUID not the Device Type
Integrated 'uuid:' prefix into the char array of the _uuid
Fix SSDP bug: The response to M-Search Packet with ST field set to UUID should be with the UUID not the Device Type
Integrated 'uuid:' prefix into the char array of the _uuid
@Lan-Hekary
Copy link
Contributor Author

I was thinking of using Dynamic allocation or Strings to store the parameters instead of Fixed size array ..
I can start on that too ..
But I need to know if you will accept it ..

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 11, 2019

But I need to know if you will accept it ..

I can't know.
What buffer, the 64 bytes declared in ::_update()'s stack ?

@Lan-Hekary
Copy link
Contributor Author

no .. I mean
char _schemaURL[SSDP_SCHEMA_URL_SIZE]; char _uuid[SSDP_UUID_SIZE]; char _deviceType[SSDP_DEVICE_TYPE_SIZE]; char _friendlyName[SSDP_FRIENDLY_NAME_SIZE]; char _serialNumber[SSDP_SERIAL_NUMBER_SIZE]; char _presentationURL[SSDP_PRESENTATION_URL_SIZE]; char _manufacturer[SSDP_MANUFACTURER_SIZE]; char _manufacturerURL[SSDP_MANUFACTURER_URL_SIZE]; char _modelName[SSDP_MODEL_NAME_SIZE]; char _modelURL[SSDP_MODEL_URL_SIZE]; char _modelNumber[SSDP_MODEL_VERSION_SIZE];

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 11, 2019

no .. I mean

Yes, maybe in another pull-request so one fix doesn't delay the other

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 11, 2019

Using String will be a good idea, especially since #5690 (just merged)

@Lan-Hekary
Copy link
Contributor Author

Using String will be a good idea, especially since #5690 (just merged)

OK.. I will make another pull request after this pull request is merged with the new modifications ..

@d-a-v d-a-v requested a review from devyte February 16, 2019 21:53
@@ -71,7 +71,7 @@ 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
"USN: uuid:%s\r\n" // _uuid
"USN: %s\r\n" // _uuid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the prefix moved out of the template? it increases permanent heap use by 10 bytes due to the increased _uuid size, and I don't see a good reason for it. I prefer to keep the prefix here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check this review :
#5750 (review)

@@ -99,7 +99,7 @@ static const char _ssdp_schema_template[] PROGMEM =
"<modelURL>%s</modelURL>"
"<manufacturer>%s</manufacturer>"
"<manufacturerURL>%s</manufacturerURL>"
"<UDN>uuid:%s</UDN>"
"<UDN>%s</UDN>"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above comment for USN.

@devyte
Copy link
Collaborator

devyte commented Feb 18, 2019

If you make a PR with Strings replacing the fixed-size arrays, please try to avoid concatenation, use direct construction or assignment when possible, and use ::reserve().

@@ -241,7 +246,7 @@ void SSDPClass::_send(ssdp_method_t method) {
_modelNumber,
_uuid,
(method == NONE) ? "ST" : "NT",
_deviceType,
(_st_is_uuid) ? _uuid : _deviceType,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the the prefix uuid: to the _uuid to avoid concatenating it in the line 249
alternative proposal would be
(_st_is_uuid) ? String("uuid:" + String(_uuid)).c_str() : _deviceType,
but this will introduce a bigger overhead I guess ..

do you have any other thoughts or alternatives I can use ??

@d-a-v d-a-v requested a review from devyte March 21, 2019 12:57
@d-a-v d-a-v merged commit e829221 into esp8266:master Mar 21, 2019
@Lan-Hekary Lan-Hekary deleted the Fix-SSDP branch March 21, 2019 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants