Benchmark
authorAli Younis <ayounis@uci.edu>
Tue, 25 Apr 2017 05:50:43 +0000 (22:50 -0700)
committerAli Younis <ayounis@uci.edu>
Tue, 25 Apr 2017 05:50:43 +0000 (22:50 -0700)
version2/src/java/light_fan_benchmark/IoTAddress.java
version2/src/java/light_fan_benchmark/IoTDeviceAddress.java
version2/src/java/light_fan_benchmark/IoTHTTP.java
version2/src/java/light_fan_benchmark/Wemo.java
version2/src/java/light_fan_benchmark/WemoController.java [new file with mode: 0644]
version2/src/java/light_fan_benchmark/run3.bash [new file with mode: 0755]

index 5f15330..ee96322 100644 (file)
@@ -61,7 +61,7 @@ public class IoTAddress {
                //e.g. http:// + inetAddress.getHostAddress() + strURLComplete\r
                //     http://192.168.2.254/cgi-bin/mjpg/video.cgi?\r
                return "http://" + inetAddress.getHostAddress() + strURLComplete;\r
-\r
+               \r
        }\r
 \r
        /**\r
index 0642439..d738f3f 100644 (file)
@@ -134,4 +134,18 @@ public class IoTDeviceAddress extends IoTAddress {
        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
index 5d9d2b7..c364c4e 100644 (file)
@@ -46,6 +46,7 @@ public class IoTHTTP {
        public void setURL(String strUrlComplete) throws MalformedURLException {\r
 \r
                url = new URL(iotDevAdd.getURL(strUrlComplete));\r
+               System.out.println(url.toString());\r
 \r
        }\r
 \r
index d020b75..42764a3 100644 (file)
@@ -27,7 +27,6 @@ public class Wemo {
 
 
 
-
     public void turnOff() throws IOException {
         IoTHTTP httpConnection = null;
         try {
@@ -37,9 +36,13 @@ public class Wemo {
             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";
 
diff --git a/version2/src/java/light_fan_benchmark/WemoController.java b/version2/src/java/light_fan_benchmark/WemoController.java
new file mode 100644 (file)
index 0000000..16db7ae
--- /dev/null
@@ -0,0 +1,9 @@
+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
diff --git a/version2/src/java/light_fan_benchmark/run3.bash b/version2/src/java/light_fan_benchmark/run3.bash
new file mode 100755 (executable)
index 0000000..4db8a37
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+java -cp .:/Users/Ali/Desktop/iotcloud/version2/src/java/iotcloud/bin WemoController
\ No newline at end of file