Search code examples
javaandroidupnpsmart-tvssdp

Which devices are replying to a SSDP discovery datagram


I've created a simple Android app to scan my local network; I've used a M-SEARCH with this search target:

  String sentence = "M-SEARCH * HTTP/1.1\r\n"
      + "HOST: 239.255.255.250:1900\r\n"
      + "MAN: \"ssdp:discover\"\r\n"
      + "MX: 10\r\n"
      + "ST: ssdp:all\r\n"
      + "\r\n";

I just need to take care of the TVs on the network, so:

  • How could I know, from the M-SEARCH response, which of kind of device is replying?

  • Is there any search target that can match all the TV devices?

Thanks!


Solution

  • You can search for specific device types (and service types) by setting the ST header to the device or service type urn (e.g. "urn:schemas-upnp-org:device:MediaRenderer:1"). Likewise in the reply, the ST header will tell you what the device/service type is.

    There is no search target that can match all TVs because "TV" is not a device defined by UPnP Forum or DLNA: A TV that "supports DLNA" might be just a MediaPlayer and not show up on M-SEARCH at all. If you want to search for UPnP MediaRenderers (a device often implemented by TVs), then the ST I gave above should be useful.