Listening for SSDP Advertisements

developers

(codersaur) #1

I’m following the guide here to build a SmartApp that connects to UPnP devices on my local LAN.

Rather than send an M-SEARCH every so often to discover the devices, I am wondering if it is possible to listen for their SSDP advertisements (since these are being broadcast over the LAN at regular intervals already)?

I have discovered that a smartApp can listen to all LAN traffic received by the hub e.g.:

subscribe(location, null, handleLanTraffic, [filterEvents:false]) 

However, this does not seem to capture multicast traffic (SSDP NOTIFY advertisements are sent to the mutlicast destination 239.255.255.250:1900).

I have tried the following, but again, they only work for unicast traffic:

subscribe(location, "ssdpTerm.urn:codersaur-com:device:DeviceType:1", ssdpHandler) // matches responses to M-SEARCH
subscribe(location, "ssdpNTS.ssdp:alive", ssdpHandler) // matches all unicast NOTIFY packets.
subscribe(location, "ssdpNT.urn:codersaur-com:device:DeviceType:1", ssdpHandler) // matches all SSDP packets from a particular device type.

I can receive unicast SSDP packets fine, just not the multicast advertisements. Anyone know if this is possible?