cybergarage / cybergarage-upnp

cybergarage-upnp is a development package for UPnP™ developers. cybergarage-upnp controls these protocols automatically, and supports to create your devices and control points quickly.

Home Page:http://www.cybergarage.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to getAction for Wemo devices

kgodett opened this issue · comments

I have been using this code to control Wemo devices, however run into an issue when calling Device.getAction(); which returns null and results in an inability to control the device.

The root of the issue appears to be in org.cybergarage.upnp.Device in the getAbsoluteURL(String, String, String) method. The method is called with:
urlString="/timesyncservice.xml"
baseURLString=""
locationURLStr="http://:49153/setup.xml"

The method returns a string: "http://:49153/setup.xml/timesyncservice.xml", which is incorrect. It should return "http://:49153/timesyncservice.xml". It appears the only validation that is being performed is to look for a MalformedURLException. My fix on the local copy of my code (attached) is to attempt to open the URL prior to returning the string to check for a response code of 200. Doing so appears to resolve my issue, though this approach breaks the test in org.cybergarage.upnp.DeviceTest as the testDeviceAbsoluteURL() method need to be able to connect to an actual device.
Device.txt