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 5f153308a991de0750d6a1aee4e95a5f6b605b17..ee96322c0f2efb515a2d9212fa3dd9e4d78e0924 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 06424393743cc77a97017c8aeba48df8bde9c72a..d738f3f9130a121d6d1177546fd394b231c6131c 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 5d9d2b7d743ad87cc1e494d676d28cf22f9a0363..c364c4e4d6f3473549ed5e34b0586110a418139a 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 d020b75052dad189feebfaac07d18a86ba9d2dfa..42764a3239cae8565c7ecfedcba315f6bd704d75 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