I'm a total beginner to HTTP requests, but I'd like to write a Python app that uses Sony's API for controlling its Wi-Fi cameras. For now, I'm just trying to talk to the camera at all, but my get request keeps failing. I have all the docs (the UPnP documentation, SSDP doc, user's manual, etc.) but I think I'm missing something really fundamental. According to Sony's doc, I need to:
DISCOVERY_MSG = ('M-SEARCH * HTTP/1.1\r\n' +
'HOST: 126.96.36.199:1900\r\n' +
'MAN: "ssdp:discover"\r\n' +
'MX: 3\r\n' +
'ST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\n' +
'USER-AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_5) AppleWebKit/536.30.1 (KHTML, like Gecko) Version/6.0.5 Safari/536.30.1\r\n\r\n')
r = requests.get(DISCOVERY_MSG)
if __name__ == '__main__':
I think this has little to do with UPnP: Sony just happens to use SSDP for discovery, and the defacto SSDP specification happens to be in the UPnP architecture document.
As for the problem:
requests.get() does an ordinary HTTP GET (or would if you provided the correct arguments), when you should send UDP multicast message(s) and handle the responses instead.
If you really intend to do this yourself, be prepared to learn a bit of networking and understand the SSDP protocol (see UPNP UDA part 1 for that). But my suggestion is to use an SSDP library or copy working open source code -- that way you can concentrate on actually providing new things (like an implementation of the sony protocol).