public boolean getIsDstPortWildcard() {\r
return isDstPortWildCard;\r
}\r
+\r
+\r
+ /**\r
+ * getUrl() method\r
+ *\r
+ * @return String\r
+ */\r
+ public String getURL(String strURLComplete) {\r
+\r
+ //e.g. http:// + inetAddress.getHostAddress() + strURLComplete\r
+ // http://192.168.2.254/cgi-bin/mjpg/video.cgi?\r
+ return "http://" + inetAddress.getHostAddress() + ":" + iDstPort + strURLComplete;\r
+ \r
+ }\r
}\r
-
public void turnOff() throws IOException {
IoTHTTP httpConnection = null;
try {
httpConnection.openConnection();
httpConnection.setDoOutput(true);
httpConnection.setRequestMethod("POST");
+ httpConnection.setRequestProperty("Connection", "close");
httpConnection.setRequestProperty("Content-type", "text/xml; charset=\"utf-8\"");
httpConnection.setRequestProperty("SOAPACTION", "\"urn:Belkin:service:basicevent:1#SetBinaryState\"");
- httpConnection.setRequestProperty("Accept", "");
+
+ httpConnection.setRequestProperty("User-Agent", "Java/1.8.0");
+ httpConnection.setRequestProperty("Host", "\"192.168.1.5:49153");
+ httpConnection.setRequestProperty("Accept", "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2");
String reqXML = "<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\" s:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><s:Body><u:SetBinaryState xmlns:u=\"urn:Belkin:service:basicevent:1\"><BinaryState>0</BinaryState></u:SetBinaryState></s:Body></s:Envelope>\n";
--- /dev/null
+class WemoController {
+ public static void main(String[] args) throws Exception {
+ IoTDeviceAddress devAddr = new IoTDeviceAddress("192.168.1.5", 49153, 49153, false, false);
+ Wemo wemo = new Wemo(devAddr);
+
+ wemo.turnOn();
+ }
+
+}
\ No newline at end of file