Cleaning up code for runtime, installer, RMI, compiler for the Java side
[iot2.git] / iotjava / iotruntime / zigbee / IoTZigbee.java
index a08754677e6b4b17d11cece0ddaf57c152f2b369..56bd8d7744aefbc9e7dbca3bd22e83828bb605f2 100644 (file)
@@ -44,7 +44,7 @@ public final class IoTZigbee {
        private final int iSrcPort;
        private final int iDstPort;
        private DatagramSocket socket;  // the socket interface that we are guarding
-       private boolean didClose;                                                               // make sure that the clean up was done correctly
+       private boolean didClose;               // make sure that the clean up was done correctly
 
        private final IoTZigbeeAddress zigbeeAddress;
 
@@ -95,7 +95,7 @@ public final class IoTZigbee {
                }
        }
 
-       //made by changwoo
+       // Created by Changwoo
        public void sendChangeSwtichRequest(int packetId, int clusterId, int profileId, int value, int deviceEndpoint) throws IOException {
                String message = "type: zcl_change_switch_request\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -108,7 +108,7 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by Jiawei
+       // Created by Jiawei
        public void sendLockOrUnlockDoorRequest(int packetId, int clusterId, int profileId, int deviceEndpoint, int value) throws IOException {
                String message = "type: zcl_lock_or_unlock_door_request\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -121,8 +121,9 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by Jiawei
-       public void sendReadDoorStatusRequest(int packetId, int clusterId, int profileId, int deviceEndpoint, int framecontrol, int commandframe, int attribute_id) throws IOException {
+       // Created by Jiawei
+       public void sendReadDoorStatusRequest(int packetId, int clusterId, int profileId, int deviceEndpoint, int framecontrol, 
+               int commandframe, int attribute_id) throws IOException {
                String message = "type: zcl_read_door_status_request\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
                message += "framecontrol: " + String.format("%02x", framecontrol) + "\n";
@@ -136,7 +137,7 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by changwoo
+       // Created by Changwoo
        public void sendBroadcastingRouteRecordRequest(int packetId) throws IOException {
                String message = "type: zdo_broadcast_route_record_request\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -145,7 +146,7 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by changwoo
+       // Created by Changwoo
        public void sendEnrollmentResponse(int packetId, int clusterId, int profileId, int deviceEndpoint) throws IOException {
                String message = "type: zcl_enrollment_response\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -157,7 +158,7 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by changwoo
+       // Created by Changwoo
        public void sendWriteAttributesCommand(int packetId, int clusterId, int profileId, int deviceEndpoint) throws IOException {
                String message = "type: zcl_write_attributes\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -169,7 +170,7 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       //made by changwoo
+       // Created by Changwoo
        public void sendManagementPermitJoiningRequest(int packetId, int clusterId, int deviceEndpoint) throws IOException {
                String message = "type: management_permit_joining_request\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
@@ -221,7 +222,8 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       public void sendConfigureReportingCommand(int packetId, int clusterId, int profileId, int src_endpoint, int dest_endpoint, int attributeId, int dataType, int minReportingInterval, int maxReportingInterval, byte[] reportableChange) throws IOException {
+       public void sendConfigureReportingCommand(int packetId, int clusterId, int profileId, int src_endpoint, int dest_endpoint, 
+               int attributeId, int dataType, int minReportingInterval, int maxReportingInterval, byte[] reportableChange) throws IOException {
                String message = "type: zcl_configure_reporting\n";
                message += "packet_id: " + String.format("%04x", packetId) + "\n";
                message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
@@ -246,8 +248,10 @@ public final class IoTZigbee {
                socket.send(sendPacket);
        }
 
-       public void sendConfigureReportingCommand(int packetId, int clusterId, int profileId, int dest_endpoint, int attributeId, int dataType, int minReportingInterval, int maxReportingInterval, byte[] reportableChange) throws IOException {
-               sendConfigureReportingCommand(packetId, clusterId, profileId, 0x00, dest_endpoint, attributeId, dataType, minReportingInterval, maxReportingInterval, reportableChange);
+       public void sendConfigureReportingCommand(int packetId, int clusterId, int profileId, int dest_endpoint, int attributeId, int dataType, 
+           int minReportingInterval, int maxReportingInterval, byte[] reportableChange) throws IOException {
+               sendConfigureReportingCommand(packetId, clusterId, profileId, 0x00, dest_endpoint, attributeId, dataType, minReportingInterval, 
+                   maxReportingInterval, reportableChange);
        }
 
        public void registerCallback(IoTZigbeeCallback callbackTo) {
@@ -320,7 +324,7 @@ public final class IoTZigbee {
                                } else {
                                        IoTZigbeeMessage callbackMessage = null;
 
-                                       //made by changwoo
+                                       // Created by Changwoo
                                        if (packetData.get("type").equals("zcl_zone_status_change_notification")){
                                                int packetId = Integer.parseInt(packetData.get("packet_id"), 16);
                                                int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16);
@@ -330,7 +334,7 @@ public final class IoTZigbee {
                                                if(packetData.get("attributes").equals("success")) successOrFail=true;
                                                callbackMessage = new IoTZigbeeMessageZclZoneStatusChangeNotification(packetId, clusterId, profileId, status, successOrFail);
 
-                                       //made by changwoo
+                                       // Created by Changwoo
                                        } else if (packetData.get("type").equals("zcl_write_attributes_response")) {
 
                                                int packetId = Integer.parseInt(packetData.get("packet_id"), 16);
@@ -346,7 +350,8 @@ public final class IoTZigbee {
                                                int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16);
                                                int profileId = Integer.parseInt(packetData.get("profile_id"), 16);
 
-                                               List<IoTZigbeeMessageZclReadAttributesResponse.Attribute> attrList = new ArrayList<IoTZigbeeMessageZclReadAttributesResponse.Attribute>();
+                                               List<IoTZigbeeMessageZclReadAttributesResponse.Attribute> attrList = new 
+                                                   ArrayList<IoTZigbeeMessageZclReadAttributesResponse.Attribute>();
 
                                                String[] attributes = packetData.get("attributes").split(";");
                                                for (String attr : attributes) {
@@ -357,14 +362,17 @@ public final class IoTZigbee {
                                                                parts[0] = parts[0].trim();
                                                                parts[1] = parts[1].trim();
 
-                                                               IoTZigbeeMessageZclReadAttributesResponse.Attribute at = new IoTZigbeeMessageZclReadAttributesResponse.Attribute(Integer.parseInt(parts[0], 16), 0, false, null);
+                                                               IoTZigbeeMessageZclReadAttributesResponse.Attribute at = new 
+                                                                   IoTZigbeeMessageZclReadAttributesResponse.Attribute(Integer.parseInt(parts[0], 16), 0, false, null);
                                                                attrList.add(at);
                                                        } else {
                                                                parts[0] = parts[0].trim();
                                                                parts[1] = parts[1].trim();
                                                                parts[2] = parts[2].trim();
                                                                parts[3] = parts[3].trim();
-                                                               IoTZigbeeMessageZclReadAttributesResponse.Attribute at = new IoTZigbeeMessageZclReadAttributesResponse.Attribute(Integer.parseInt(parts[0], 16), Integer.parseInt(parts[1], 16), true, hexStringToByteArray(parts[3]));
+                                                               IoTZigbeeMessageZclReadAttributesResponse.Attribute at = new 
+                                                                   IoTZigbeeMessageZclReadAttributesResponse.Attribute(Integer.parseInt(parts[0], 16), 
+                                                                   Integer.parseInt(parts[1], 16), true, hexStringToByteArray(parts[3]));
                                                                attrList.add(at);
                                                        }
                                                }
@@ -379,7 +387,8 @@ public final class IoTZigbee {
                                                if (packetData.get("attributes").equals("all_success")) {
                                                        callbackMessage = new IoTZigbeeMessageZclConfigureReportingResponse(packetId, clusterId, profileId, true, null);
                                                } else {
-                                                       List<IoTZigbeeMessageZclConfigureReportingResponse.Attribute> attrList = new ArrayList<IoTZigbeeMessageZclConfigureReportingResponse.Attribute>();
+                                                       List<IoTZigbeeMessageZclConfigureReportingResponse.Attribute> attrList = new 
+                                                           ArrayList<IoTZigbeeMessageZclConfigureReportingResponse.Attribute>();
 
                                                        String[] attributes = packetData.get("attributes").split(";");
                                                        for (String attr : attributes) {
@@ -388,7 +397,9 @@ public final class IoTZigbee {
                                                                parts[0] = parts[0].trim();
                                                                parts[1] = parts[1].trim();
                                                                parts[2] = parts[2].trim();
-                                                               IoTZigbeeMessageZclConfigureReportingResponse.Attribute at = new IoTZigbeeMessageZclConfigureReportingResponse.Attribute(Integer.parseInt(parts[0], 16), parts[1].equals("success"), parts[2].equals("reported"));
+                                                               IoTZigbeeMessageZclConfigureReportingResponse.Attribute at = new 
+                                                                   IoTZigbeeMessageZclConfigureReportingResponse.Attribute(Integer.parseInt(parts[0], 16), 
+                                                                   parts[1].equals("success"), parts[2].equals("reported"));
                                                                attrList.add(at);
                                                        }
                                                        callbackMessage = new IoTZigbeeMessageZclConfigureReportingResponse(packetId, clusterId, profileId, false, attrList);
@@ -409,7 +420,9 @@ public final class IoTZigbee {
                                                        parts[0] = parts[0].trim();
                                                        parts[1] = parts[1].trim();
                                                        parts[2] = parts[2].trim();
-                                                       IoTZigbeeMessageZclReportAttributes.Attribute at = new IoTZigbeeMessageZclReportAttributes.Attribute(Integer.parseInt(parts[0], 16), Integer.parseInt(parts[1], 16), hexStringToByteArray(parts[2]));
+                                                       IoTZigbeeMessageZclReportAttributes.Attribute at = new 
+                                                           IoTZigbeeMessageZclReportAttributes.Attribute(Integer.parseInt(parts[0], 16), 
+                                                           Integer.parseInt(parts[1], 16), hexStringToByteArray(parts[2]));
                                                        attrList.add(at);
                                                }
 
@@ -464,8 +477,6 @@ public final class IoTZigbee {
                                        }
                                }
 
-
-
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
@@ -501,17 +512,3 @@ public final class IoTZigbee {
 }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-