Skip to content

Custom Device Type, Appropriate Responses, Custom TTL, and uint32_t Serial Number #1399

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
Jan 10, 2016

Conversation

wyattearp
Copy link
Contributor

This PR addresses 3 major things that I ran into while building an SSDP based device using the esp8266 (and 1 ease of use)

  1. Custom TTL: Based on the upnp 1.1 specification that is being advertised, the TTL should be set to 2 by default and be configurable. so the default is now defined by SSDP_MULTICAST_TTL 2 and a helper function to set the TTL, setMulticastTTL() is now included. This should allow the user to customize responses when needed.
  2. Custom deviceType attribute: The default device type of urn:schemas-upnp-org:device:Basic:1 is great but it covers a lot of things and when in down, you should be more specific than not. The default is still the same; however, a setDeviceType() now exists allowing the user to specify a custom URN for the device type, just like the basic one. Based on the upnp 1.1 specification, this should technically be unlimited in length; however, that's not really reasonable with the way the rest of the library is written so I've set the max size to SSDP_DEVICE_TYPE_SIZE 64 to keep consistent with the rest of the code and should fit the 80% case in the device type descriptors I looked up.
  3. Along with the custom device type, I've corrected the code to actually respond to ST requests so that the device can actually be found and will only respond their specific types of searches (avoiding ssdp:all ... although, we might want to consider responding to ssdp:discover since it appears we should be ... but that might be too much traffic so this seemed like a good compromise for now). Now when the ST: matches the deviceType set by setDeviceType() or the default, we will correctly respond with an HTTP 200 OK packet (allowing things like SmartThings to successfully discover us).
  4. Added a wrapper so that setSerialNumber() can directly take the input from ESP.getChipId()

the v1.1 upnp spec indicates that the default TTL should be set to 2
(and should also be configurable):

* http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf
* can now specify the TTL programmatically
* can now define the device type urn (up to 64 chars)
** still defaults to `Basic:1`
* can now set the serial number using a `uint32_t`, formatted as %08X
silly goof, it's a string
also a small formatting fix. this should now allow the system to
actually respond to SSDP discoveries that are issued on the network ...
i'm still not 100% certain if this is right due to the way that the
switch() statement is setup; it could be processing more than it should
igrr added a commit that referenced this pull request Jan 10, 2016
Custom Device Type, Appropriate Responses, Custom TTL, and uint32_t Serial Number
@igrr igrr merged commit fe55854 into esp8266:master Jan 10, 2016
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.

2 participants