Integrating D-Link alarm into Home Security benchmark
authorrtrimana <rtrimana@uci.edu>
Wed, 29 Nov 2017 21:22:29 +0000 (13:22 -0800)
committerrtrimana <rtrimana@uci.edu>
Wed, 29 Nov 2017 21:22:29 +0000 (13:22 -0800)
benchmarks/Java/HomeSecurityController/HomeSecurityController.java
benchmarks/drivers/Java/DlinkAlarm/DlinkAlarm.java
iotjava/iotruntime/master/IoTMaster.java
iotjava/iotruntime/master/ProcessJailConfig.java
localconfig/mysql/alarmSet.config
localconfig/mysql/alm_Addresses.config
localconfig/mysql/camSet.config
localconfig/mysql/cameraSet.config
others/Mysql/IoTMain.gz

index 3b7cf53..09c0527 100644 (file)
@@ -43,7 +43,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
        private static final int MOTION_TIME_THRESHOLD = 60;    // in seconds
        private static final int CAMERA_FPS = 15;
        private static final int CHECK_TIME_WAIT = 1;                   // in seconds
-       private static final int SECOND_TO_TURN_ON = 60;                // in seconds
+       private static final int SECOND_TO_TURN_ON = -1;                // in seconds
        private static final int SECOND_TO_TURN_OFF = 1;                // in seconds
        private static final int LOCK_DOOR = 0;
        private static final int UNLOCK_DOOR = 1;
@@ -477,7 +477,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                // Get and init the alarm (this single alarm set can serve multiple zones / rooms)
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
-               alm.setZone(zoneId, true, SECOND_TO_TURN_OFF);
+               alm.setZone(zoneId, true, SECOND_TO_TURN_ON);
                updateIoTCloud("alarm", ACTIVE);
        }
 
@@ -492,7 +492,7 @@ public class HomeSecurityController implements SmartthingsSensorCallback, Smartt
                Iterator alarmIt = alarmSet.iterator();
                AlarmSmart alm = (AlarmSmart) alarmIt.next();
                // Turn this alarm off indefinitely
-               alm.setZone(zoneId, false, SECOND_TO_TURN_ON);
+               alm.setZone(zoneId, false, SECOND_TO_TURN_OFF);
                updateIoTCloud("alarm", NOT_ACTIVE);
        }
 
index 6b0ee18..e19b375 100644 (file)
@@ -454,27 +454,6 @@ public class DlinkAlarm implements Alarm {
         // Return time since January 1, 1970 00:00:00 UTC in seconds
         return System.currentTimeMillis()/1000;
     }
-    
-    /*public static void main(String[] args) throws Exception {
-
-        String ipAddress = "192.168.1.183";
-        String devicePin = "215530";
-        IoTDeviceAddress iotAddress = new IoTDeviceAddress(ipAddress, 12345, 80, false, false);
-        Set<IoTDeviceAddress> setAddress = new HashSet<IoTDeviceAddress>();
-        setAddress.add(iotAddress);
-        IoTSet<IoTDeviceAddress> iotSetAddress = new IoTSet<IoTDeviceAddress>(setAddress);
-        
-        DlinkAlarm alarm = new DlinkAlarm(iotSetAddress, devicePin);
-        alarm.init();
-        // Set alarm
-        alarm.setZone(0, true, -1);
-        // Set alarm
-        alarm.setZone(0, false, 0);
-        // Set alarm
-        alarm.setZone(0, true, -1);
-        // Set alarm
-        alarm.setZone(0, false, 0);
-    }*/
 }
 
 
index 7dc41d7..3ce672d 100644 (file)
@@ -740,7 +740,7 @@ public final class IoTMaster {
                                routerConfig.configureHostHTTPPolicies(strIoTSlaveObjectHostAdd, strIoTSlaveObjectHostAdd, strDeviceAddress);
                                // Configure MAC policies
                                if (STR_ACTIVATE_SANDBOXING.equals("Yes"))
-                                       processJailConfig.configureProcessJailGWDevicePolicies(strIoTSlaveObjectHostAdd, STR_ROUTER_ADD, INT_DNS_PORT);
+                                       processJailConfig.configureProcessJailGWDevicePolicies(strIoTSlaveObjectHostAdd, STR_ROUTER_ADD, strDeviceAddress, INT_DNS_PORT);
                        } else {
                                // Other port numbers...
                                commHan.addDevicePort(iDestDeviceDriverPort);
index 757313a..e19ee15 100644 (file)
@@ -46,6 +46,9 @@ public final class ProcessJailConfig {
        private static final String STR_DEV_IP_ADDRESS          = "<dev-ip-address>";
        private static final String STR_DEV_COM_PORT            = "<dev-com-port>";
        private static final String STR_DEV_PORT                        = "<dev-port>";
+       
+    private static final int INT_HTTP_PORT = 80;
+    private static final int INT_DNS_PORT  = 53;
 
 
        /**
@@ -326,12 +329,13 @@ public final class ProcessJailConfig {
         * @param   iPort                                       Integer port
         * @return  void
         */
-       public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, int iPort) {
+       public void configureProcessJailGWDevicePolicies(String strConfigHost, String strRouterAddress, String strDeviceIPAddress, int iPort) {
 
                PrintWriter pwConfig = getPrintWriter(strConfigHost);
                pwConfig.println("file read /home/iotuser/iot2/iotjava/iotruntime/\\*.jks");
                pwConfig.println("file read /etc/resolv.conf");
                pwConfig.println("file read /etc/hosts");
+       pwConfig.println("network inet stream connect ::ffff:" + strDeviceIPAddress + " " + String.valueOf(INT_HTTP_PORT));     // HTTP access for this address
                pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(iPort));
        }
 
@@ -351,8 +355,8 @@ public final class ProcessJailConfig {
                pwConfig.println("file read /etc/resolv.conf");
                pwConfig.println("file read /etc/hosts");
                pwConfig.println("file read /etc/host.conf");
-               pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(53));     // TCP/UDP access through router
-               pwConfig.println("network inet stream connect ::ffff:" + strAddress + " " + String.valueOf(80));        // HTTP access for this address
+               pwConfig.println("network inet dgram send " + strRouterAddress + " " + String.valueOf(INT_DNS_PORT));   // TCP/UDP access through router
+               pwConfig.println("network inet stream connect ::ffff:" + strAddress + " " + String.valueOf(INT_HTTP_PORT));     // HTTP access for this address
        }
 
 
index 40e745a..c1d125a 100644 (file)
@@ -1,3 +1,5 @@
 SELECT * FROM
 AlarmSmart
+WHERE
+ID='AL2'
 ;
index 2564492..8ab9893 100644 (file)
@@ -1,5 +1,5 @@
 SELECT * FROM
 IoTDeviceAddress
 WHERE
-TYPE='EspAlarmAdd'
+TYPE='DlinkAlarmAdd'
 ;
index 083ca82..9b21ecd 100644 (file)
@@ -1,3 +1,5 @@
 SELECT * FROM
 CameraSmart
+WHERE
+ID='CM4'
 ;
index a061abc..4233b23 100644 (file)
@@ -1,5 +1,5 @@
 SELECT * FROM\r
 CameraSmart\r
 WHERE\r
-ID='CM1'\r
+ID='CM3'\r
 ;\r
index 5f0d373..123e17b 100644 (file)
Binary files a/others/Mysql/IoTMain.gz and b/others/Mysql/IoTMain.gz differ