Question

I have a custom embedded hardware device running Linux controlled by a Python code. I'd like to create an Android client that will automatically find any of my devices on the local network, configure the devices, and display data from them.

I'd like to keep my implementation as simple as possible and leverage as much open source software possible for a quick implementation (with a strong preference towards actively maintained/support code).

My research so far has led me to favor a UPnP implementation, using SSDP to find my devices and letting the UPnP communicate via SOAP between my Android client and Python-controlled Linux device.

  1. Is UPnP a good choice for this use case (I'm not a traditional UPNP device)? Or are there other standards-based approaches I should consider?
  2. Assuming UPnP is reasonable:
    • (a) What are reasonable libraries to use on Android and in my Python/Linux device?
    • (b) Should I implement a custom UPNP "device" or should I try to shoehorn my solution into looking like a MediaServer?

Currently I'm attempting the implementation using Cling on the Android side and Coherence on the Python side, neither of which have been as straightforward as I would have hoped, which makes me wonder if I'm taking a smart approach.

Was it helpful?

Solution

There's nothing wrong with using UPnP for this. There's two questions here -- related but still independent:

  • How do you discover services? SSDP is a valid technology but so is zeroconf: I'm not aware of an Android implementation but I assume one would exist.
  • How do you expose your API once the uri is found? UPnP is a bit old school by now but works fine and if you use a decent library it's easy yet quite powerful. Depending on your needs you could go with something like a normal REST webservice as well, or use SOAP without bothering with UPnP.

Whether the questions really are unrelated depends on the libraries you use -- I have no idea if e.g. Cling lets you use just SSDP for a non-UPnP use case.

  1. For the UPnP questions:

    • (a) I'm not very familiar with the Android side but for linux UPnP I would suggest GUPnP (I'm biased though, as I'm involved in its development): it's a stable and well tested library. Python bindings aren't as well documented as they should be but they exist: from gi.repository import GUPnP. GUPnP also let's you do just SSDP if you want: see the GSSDP library.

    • (b) Definitely custom device if you can't find a good existing match, that's what UPnP was designed for. In the GUPnP case you would write the device and service descriptions (in xml, see examples in the source) and load them with a RootDevice. That takes care of device/service discovery and hosting the description docs. Then you'd just need to implement the actions you have in your service description.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top