SSDP for the Photon Core

Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail

The guys at Particle.IO have this nifty little device that has built in WiFi. Trouble is, it is a bit annoying trying to find the IP on a dynamic network.

SSDP stands for Simple Service Discovery Protocol. It was a little tricky to get a really quick understanding of the protocol; most of the documents available are pretty big (ie, the UPnP spec).

There wasn’t a port for the particle, so I made one on GitHub: https://github.com/smpickett/particle_ssdp_server

Let’s break it down:

  • Someone searching for devices will broadcast a ‘SEARCH’ message to the IP 239.255.255.250:1900

M-SEARCH * HTTP/1.1
HOST:239.255.255.250:1900
MAN:"ssdp:discover"
MX:[seconds to delay response]
ST:[search target]

  • Next, all devices will broadcast a ‘SEARCH Response’ directly to the IP that pinged for devices

HTTP/1.1 200 OK
CACHE-CONTROL:max-age=[seconds until advertisement expires]
EXT:
LOCATION:http://[location where the xml description file is hosted]
SERVER:[OS/version UPnP/1.1 product/version]
ST:[search target]
USN:[composite identifier for the advertisement]

  • The host where the ‘SEARCH’ request came from will then open a TCP connection to the ‘LOCATION’ specified in the response

GET /upnp/description.xml HTTP/1.1
...

  • Then, of course, the device must provide back the XML file that describes its operation

There are some other things the device should do:

  • provide a device update ‘NOTIFY ALIVE’ message when it connects, and periodically send it to keep the device advertisement alive
  • provide a device update ‘NOTIFY BYEBYE’ message when leaving the network

Simple!

Once implemented, the device can be easily discovered in Windows:

readme_example_network

 

Facebooktwittergoogle_plusredditpinterestlinkedinmailFacebooktwittergoogle_plusredditpinterestlinkedinmail