* @version 1.0
* @since 2016-04-12
*/
-public class IoTZigbee {
+public final class IoTZigbee {
public final int SOCKET_SEND_BUFFER_SIZE = 1024;
public final int SOCKET_RECEIVE_BUFFER_SIZE = 1024;
}
}
+ //made 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";
+ message += "value: " + String.format("%01x", value) + "\n";
+ message += "cluster_id: " + String.format("%04x", clusterId) + "\n";
+ message += "profile_id: " + String.format("%04x", profileId) + "\n";
+ message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
+ message += "device_endpoint: " + String.format("%02x", deviceEndpoint) + "\n";
+ DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort);
+ socket.send(sendPacket);
+ }
+
+ //made 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";
+ message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
+ DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort);
+ socket.send(sendPacket);
+ }
+
+ //made 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";
+ message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
+ message += "cluster_id: " + String.format("%04x", clusterId) + "\n";
+ message += "profile_id: " + String.format("%04x", profileId) + "\n";
+ message += "device_endpoint: " + String.format("%02x", deviceEndpoint) + "\n";
+ DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort);
+ socket.send(sendPacket);
+ }
+
+ //made 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";
+ message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
+ message += "cluster_id: " + String.format("%04x", clusterId) + "\n";
+ message += "profile_id: " + String.format("%04x", profileId) + "\n";
+ message += "device_endpoint: " + String.format("%02x", deviceEndpoint) + "\n";
+ DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort);
+ socket.send(sendPacket);
+ }
+
+ //made 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";
+ message += "device_address_long: " + zigbeeAddress.getAddress() + "\n";
+ message += "cluster_id: " + String.format("%04x", clusterId) + "\n";
+ message += "device_endpoint: " + String.format("%02x", deviceEndpoint) + "\n";
+ DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort);
+ socket.send(sendPacket);
+ }
public void sendBindRequest(int packetId, int clusterId, int deviceEndpoint) throws IOException {
String message = "type: zdo_bind_request\n";
} else {
IoTZigbeeMessage callbackMessage = null;
- if (packetData.get("type").equals("zcl_read_attributes_response")) {
+ //made 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);
+ int profileId = Integer.parseInt(packetData.get("profile_id"), 16);
+ int status = Integer.parseInt(packetData.get("status"), 10);
+ boolean successOrFail = false;
+ if(packetData.get("attributes").equals("success")) successOrFail=true;
+ callbackMessage = new IoTZigbeeMessageZclZoneStatusChangeNotification(packetId, clusterId, profileId, status, successOrFail);
+
+ //made by changwoo
+ } else if (packetData.get("type").equals("zcl_write_attributes_response")) {
+
+ int packetId = Integer.parseInt(packetData.get("packet_id"), 16);
+ int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16);
+ int profileId = Integer.parseInt(packetData.get("profile_id"), 16);
+ boolean successOrFail = false;
+ if(packetData.get("attributes").equals("success")) successOrFail=true;
+
+ callbackMessage = new IoTZigbeeMessageZclWriteAttributesResponse(packetId, clusterId, profileId, successOrFail);
+
+ } else if (packetData.get("type").equals("zcl_read_attributes_response")) {
int packetId = Integer.parseInt(packetData.get("packet_id"), 16);
int clusterId = Integer.parseInt(packetData.get("cluster_id"), 16);
int profileId = Integer.parseInt(packetData.get("profile_id"), 16);