From: rtrimana Date: Wed, 21 Jun 2017 17:51:49 +0000 (-0700) Subject: Adding changes and files for doorlock driver X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=79a07095edcd2818516d3608302323e0c37d1f81;p=iot2.git Adding changes and files for doorlock driver --- diff --git a/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.config b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.config new file mode 100644 index 0000000..73b43f1 --- /dev/null +++ b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.config @@ -0,0 +1,7 @@ +# Skeleton/original interface +INTERFACE_CLASS=SmartthingsSensor +# Stub +INTERFACE_STUB_CLASS=SmartthingsSensorSmart + +# Language +LANGUAGE=Java diff --git a/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java new file mode 100644 index 0000000..a3ea772 --- /dev/null +++ b/benchmarks/drivers/Java/DoorlockSensor/DoorlockSensor.java @@ -0,0 +1,282 @@ +package iotcode.DoorlockSensor; + +// Standard Java Packages +import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.Semaphore; + +// Checker annotations +//import iotchecker.qual.*; +import iotcode.annotation.*; + +// IoT Packages +import iotruntime.slave.*; +import iotcode.interfaces.*; +import iotruntime.zigbee.*; + +/** Class Smartthings sensor driver for Smartthings sensor devices. + * + * @author Changwoo Lee, Rahmadi Trimananda + * @version 1.0 + * @since 2016-12-01 + */ +public class DoorlockSensor implements IoTZigbeeCallback, SmartthingsSensor { + + private final int TIMEOUT_FOR_RESEND_MSEC = 900; + + private IoTZigbee zigConnection = null; + private boolean didClose; // make sure that the clean up was done correctly + private boolean detectStatus = false; + + private int detectedValue = 0; + private Date timestampOfLastDetecting = null; + + private AtomicBoolean didAlreadyClose = new AtomicBoolean(true); + private AtomicBoolean didAlreadyInit = new AtomicBoolean(false); + private AtomicBoolean didWriteAttrb = new AtomicBoolean(false); + private AtomicBoolean didMatchDscr = new AtomicBoolean(false); + private AtomicBoolean didBind = new AtomicBoolean(false); + private AtomicBoolean didDoorLockConfigureReporting = new AtomicBoolean(false); //made by Jiawei + static Semaphore gettingLatestDataMutex = new Semaphore(1); + + private List < SmartthingsSensorSmartCallback > callbackList = new CopyOnWriteArrayList < SmartthingsSensorSmartCallback > (); + + private int sensorId = 0; + + @config private IoTSet DoorlockSensorUdpAddress; + @config private IoTSet DoorlockSensorZigbeeAddress; + + public DoorlockSensor(IoTSet dSet, IoTSet zigSet) { + DoorlockSensorUdpAddress = dSet; + DoorlockSensorZigbeeAddress = zigSet; + } + + public DoorlockSensor() { + } + + public void init() { + + if (didAlreadyInit.compareAndSet(false, true) == false) { + return; // already init + } + + didAlreadyClose.set(false); + + try { + Iterator itrUdp = DoorlockSensorUdpAddress.iterator(); + Iterator itrZig = DoorlockSensorZigbeeAddress.iterator(); + + zigConnection = new IoTZigbee((IoTDeviceAddress)itrUdp.next(), (IoTZigbeeAddress)itrZig.next()); + + // DEBUG + System.out.println("DEBUG: Allocate iterators to print out addresses!"); + Iterator itrDebugUdp = DoorlockSensorUdpAddress.iterator(); + IoTDeviceAddress iotaddDebug = (IoTDeviceAddress)itrDebugUdp.next(); + System.out.println("IP address: " + iotaddDebug.getCompleteAddress()); + System.out.println("Source port: " + iotaddDebug.getSourcePortNumber()); + System.out.println("Destination port: " + iotaddDebug.getDestinationPortNumber()); + + Iterator itrDebugZig = DoorlockSensorZigbeeAddress.iterator(); + IoTZigbeeAddress iotzbaddDebug = (IoTZigbeeAddress)itrDebugZig.next(); + System.out.println("Zigbee address: " + iotzbaddDebug.getAddress()); + + zigConnection.registerCallback(this); + System.out.println("Register callback!"); + zigConnection.init(); + System.out.println("Initialized!"); + + + + //made by changwoo + sleep(10); + + // System.out.println("BroadcastingRouteRecordRequest "); + // zigConnection.sendBroadcastingRouteRecordRequest(0x0001); + // sleep(6); + + System.out.println("Sending Management Permit Joining Request"); + // for(int z=0; z<3; z++){ + zigConnection.sendManagementPermitJoiningRequest(0x0002, 0x0036, 0x00); + sleep(0); + // } + + + while(!didBind.get()){ + System.out.println("Sending Bind Request"); + zigConnection.sendBindRequest(0x0003, 0x0101, 0x02); + sleep(0); + } + + while(!didDoorLockConfigureReporting.get()){ + System.out.println("Sending Door Lock: Configure Reporting"); + zigConnection.sendConfigureReportingCommand(0x0004, 0x0101, 0x0104, 0x01, 0x02, 0x0000, 0x30, 0x0000, 0x100E, null); + sleep(0); + } + + while(true){ + Scanner in = new Scanner(System.in); + System.out.println("\nUnlock door: 0"); + System.out.println("Lock door: 1"); + System.out.println("Read status: 2 (or anything else)"); + String str = in.next(); + if(str.equals("1")) { + System.out.println("the doorlock sensor is locking"); + zigConnection.sendLockOrUnlockDoorRequest(0x0005, 0x0101, 0x0104, 0x02, 0); + sleep(0); + }else if(str.equals("0")){ + System.out.println("the doorlock sensor is unlocking"); + zigConnection.sendLockOrUnlockDoorRequest(0x0005, 0x0101, 0x0104, 0x02, 1); + sleep(0); + }else{ + System.out.println("Let's see the doorlock sensor's status currently"); + zigConnection.sendReadDoorStatusRequest(0x0005, 0x0101, 0x0104, 0x02, 0x10, 0x00, 0x0000); + sleep(0); + } + } + + + } catch (Exception e) { + e.printStackTrace(); + } + } + + //made by changwoo + private void sleep(int multipleTime){ + if(multipleTime<=0){ + multipleTime=1; + } + try{ + Thread.sleep(TIMEOUT_FOR_RESEND_MSEC*multipleTime); + } catch(Exception e){ + e.printStackTrace(); + } + } + + // made by Jiawei + //public int getStatus() { + public int getValue() { + int tmp = 0; + + try { + gettingLatestDataMutex.acquire(); + tmp = detectedValue; + + } catch (Exception e) { + e.printStackTrace(); + } + gettingLatestDataMutex.release(); + + return tmp; + } + + public boolean isActiveValue() { + + int tmp = getValue(); + if (tmp == 1) + detectStatus = true; // Door is locked + else + detectStatus = false; // Door is not locked/not fully locked + return detectStatus; + } + + public void close() { + + if (didAlreadyClose.compareAndSet(false, true) == false) { + return; // already init + } + + didAlreadyInit.set(false); + + + try { + zigConnection.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void Finalize() { + if (!didClose) { + close(); + } + } + + public void setId(int id) { + + sensorId = id; + + } + + public int getId() { + + return sensorId; + + } + + + public long getTimestampOfLastReading() { + + Date tmp = null; + try { + gettingLatestDataMutex.acquire(); + tmp = (Date)timestampOfLastDetecting.clone(); + + } catch (Exception e) { + e.printStackTrace(); + } + gettingLatestDataMutex.release(); + long retLong = tmp.getTime(); + + return retLong; + } + + public void newMessageAvailable(IoTZigbeeMessage _zm) { + + //made by yuting + if (_zm instanceof IoTZigbeeMessageZdoBindResponse) { + IoTZigbeeMessageZdoBindResponse message = (IoTZigbeeMessageZdoBindResponse)_zm; + if (message.getSucceeded()) { + didBind.set(true); + } + } + else if (_zm instanceof IoTZigbeeMessageZclConfigureReportingResponse){ + IoTZigbeeMessageZclConfigureReportingResponse message = (IoTZigbeeMessageZclConfigureReportingResponse)_zm; + if (message.getAllSuccess()) { + didDoorLockConfigureReporting.set(true); + } + } + else if (_zm instanceof IoTZigbeeMessageZclReadAttributesResponse) { + IoTZigbeeMessageZclReadAttributesResponse message = (IoTZigbeeMessageZclReadAttributesResponse)_zm; + List attrList = message.getAttributes(); + + if (attrList.size() == 1) { + if(attrList.get(0).getAttributeId() == 0) { + byte[] data = attrList.get(0).getData(); + int value = data[0]; + + try { + gettingLatestDataMutex.acquire(); + detectedValue = value; + timestampOfLastDetecting = new Date(); + } catch (Exception e) { + e.printStackTrace(); + } + gettingLatestDataMutex.release(); + + try { + for (SmartthingsSensorSmartCallback cb : callbackList) { + cb.newReadingAvailable(this.getId(), this.getValue(), this.isActiveValue()); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + } + } + } + + public void registerCallback(SmartthingsSensorSmartCallback _callbackTo) { + callbackList.add(_callbackTo); + } +} diff --git a/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensorSmartCallback_Stub.java b/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensorSmartCallback_Stub.java new file mode 100644 index 0000000..df26eb4 --- /dev/null +++ b/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensorSmartCallback_Stub.java @@ -0,0 +1,47 @@ +package iotcode.DoorlockSensor; + +import java.io.IOException; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import iotrmi.Java.IoTRMIComm; +import iotrmi.Java.IoTRMICommClient; +import iotrmi.Java.IoTRMICommServer; +import iotrmi.Java.IoTRMIUtil; + +import iotcode.interfaces.*; + +public class SmartthingsSensorSmartCallback_Stub implements SmartthingsSensorSmartCallback { + + private int objectId = 3; + private IoTRMIComm rmiComm; + // Synchronization variables + + + public SmartthingsSensorSmartCallback_Stub(int _localPortSend, int _localPortRecv, int _portSend, int _portRecv, String _skeletonAddress, int _rev) throws Exception { + if (_localPortSend != 0 && _localPortRecv != 0) { + rmiComm = new IoTRMICommClient(_localPortSend, _localPortRecv, _portSend, _portRecv, _skeletonAddress, _rev); + } else + { + rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev); + } + IoTRMIUtil.mapStub.put(objectId, this); + } + + public SmartthingsSensorSmartCallback_Stub(IoTRMIComm _rmiComm, int _objectId) throws Exception { + rmiComm = _rmiComm; + objectId = _objectId; + } + + public void newReadingAvailable(int _sensorId, int _value, boolean _activeValue) { + int methodId = 0; + Class retType = void.class; + Class[] paramCls = new Class[] { int.class, int.class, boolean.class }; + Object[] paramObj = new Object[] { _sensorId, _value, _activeValue }; + rmiComm.remoteCall(objectId, methodId, paramCls, paramObj); + } + +} diff --git a/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensor_Skeleton.java b/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensor_Skeleton.java new file mode 100644 index 0000000..b64ea4e --- /dev/null +++ b/benchmarks/drivers/Java/DoorlockSensor/SmartthingsSensor_Skeleton.java @@ -0,0 +1,276 @@ +package iotcode.DoorlockSensor; + +import java.io.IOException; +import java.util.List; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Map; +import java.util.HashMap; +import java.util.concurrent.atomic.AtomicBoolean; +import iotrmi.Java.IoTRMIComm; +import iotrmi.Java.IoTRMICommClient; +import iotrmi.Java.IoTRMICommServer; +import iotrmi.Java.IoTRMIUtil; + +import iotcode.interfaces.*; + +public class SmartthingsSensor_Skeleton implements SmartthingsSensor { + + private SmartthingsSensor mainObj; + private int objectId = 3; + // Communications and synchronizations + private IoTRMIComm rmiComm; + private AtomicBoolean didAlreadyInitWaitInvoke; + private AtomicBoolean methodReceived; + private byte[] methodBytes = null; + // Permissions + private static Integer[] object2Permission = { 3, 2, 5, 6, 1, 4, 0 }; + private static List set2Allowed; + + + public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, int _portSend, int _portRecv) throws Exception { + mainObj = _mainObj; + rmiComm = new IoTRMICommServer(_portSend, _portRecv); + set2Allowed = new ArrayList(Arrays.asList(object2Permission)); + IoTRMIUtil.mapSkel.put(_mainObj, this); + IoTRMIUtil.mapSkelId.put(_mainObj, objectId); + didAlreadyInitWaitInvoke = new AtomicBoolean(false); + methodReceived = new AtomicBoolean(false); + rmiComm.registerSkeleton(objectId, methodReceived); + Thread thread1 = new Thread() { + public void run() { + try { + ___waitRequestInvokeMethod(); + } + catch (Exception ex) + { + ex.printStackTrace(); + } + } + }; + thread1.start(); + } + + public SmartthingsSensor_Skeleton(SmartthingsSensor _mainObj, IoTRMIComm _rmiComm, int _objectId) throws Exception { + mainObj = _mainObj; + rmiComm = _rmiComm; + objectId = _objectId; + set2Allowed = new ArrayList(Arrays.asList(object2Permission)); + didAlreadyInitWaitInvoke = new AtomicBoolean(false); + methodReceived = new AtomicBoolean(false); + rmiComm.registerSkeleton(objectId, methodReceived); + } + + public boolean didAlreadyInitWaitInvoke() { + return didAlreadyInitWaitInvoke.get(); + } + + public void init() { + mainObj.init(); + } + + public int getValue() { + return mainObj.getValue(); + } + + public boolean isActiveValue() { + return mainObj.isActiveValue(); + } + + public long getTimestampOfLastReading() { + return mainObj.getTimestampOfLastReading(); + } + + public void setId(int id) { + mainObj.setId(id); + } + + public int getId() { + return mainObj.getId(); + } + + public void registerCallback(SmartthingsSensorSmartCallback _callbackTo) { + mainObj.registerCallback(_callbackTo); + } + + public void ___init() { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); + init(); + } + + public void ___getValue() throws IOException { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); + Object retObj = getValue(); + rmiComm.sendReturnObj(retObj, localMethodBytes); + } + + public void ___isActiveValue() throws IOException { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); + Object retObj = isActiveValue(); + rmiComm.sendReturnObj(retObj, localMethodBytes); + } + + public void ___getTimestampOfLastReading() throws IOException { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); + Object retObj = getTimestampOfLastReading(); + rmiComm.sendReturnObj(retObj, localMethodBytes); + } + + public void ___setId() { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { int.class }, new Class[] { null }, localMethodBytes); + setId((int) paramObj[0]); + } + + public void ___getId() throws IOException { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { }, new Class[] { }, localMethodBytes); + Object retObj = getId(); + rmiComm.sendReturnObj(retObj, localMethodBytes); + } + + public void ___registerCallback() { + byte[] localMethodBytes = methodBytes; + rmiComm.setGetMethodBytes(); + Object[] paramObj = rmiComm.getMethodParams(new Class[] { int[].class }, new Class[] { null }, localMethodBytes); + try { + int[] stubIdArray0 = (int[]) paramObj[0]; + int objIdRecv0 = stubIdArray0[0]; + SmartthingsSensorSmartCallback newStub0 = null; + if(!IoTRMIUtil.mapStub.containsKey(objIdRecv0)) { + newStub0 = new SmartthingsSensorSmartCallback_Stub(rmiComm, objIdRecv0); + IoTRMIUtil.mapStub.put(objIdRecv0, newStub0); + rmiComm.setObjectIdCounter(objIdRecv0); + rmiComm.decrementObjectIdCounter(); + } + else { + newStub0 = (SmartthingsSensorSmartCallback_Stub) IoTRMIUtil.mapStub.get(objIdRecv0); + } + SmartthingsSensorSmartCallback stub0 = newStub0; + registerCallback(stub0); + } catch(Exception ex) { + ex.printStackTrace(); + throw new Error("Exception from callback object instantiation!"); + } + } + + public void ___waitRequestInvokeMethod() throws IOException { + didAlreadyInitWaitInvoke.compareAndSet(false, true); + while (true) { + if (!methodReceived.get()) { + continue; + } + methodBytes = rmiComm.getMethodBytes(); + methodReceived.set(false); + int _objectId = IoTRMIComm.getObjectId(methodBytes); + int methodId = IoTRMIComm.getMethodId(methodBytes); + if (_objectId == objectId) { + if (!set2Allowed.contains(methodId)) { + throw new Error("Object with object Id: " + _objectId + " is not allowed to access method: " + methodId); + } + } + else { + continue; + } + switch (methodId) { + case 0: + new Thread() { + public void run() { + try { + ___init(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 1: + new Thread() { + public void run() { + try { + ___getValue(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 2: + new Thread() { + public void run() { + try { + ___isActiveValue(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 3: + new Thread() { + public void run() { + try { + ___getTimestampOfLastReading(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 4: + new Thread() { + public void run() { + try { + ___setId(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 5: + new Thread() { + public void run() { + try { + ___getId(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + case 6: + new Thread() { + public void run() { + try { + ___registerCallback(); + } + catch (Exception ex) { + ex.printStackTrace(); + } + } + }.start(); + break; + default: + throw new Error("Method Id " + methodId + " not recognized!"); + } + } + } + +} diff --git a/benchmarks/drivers/Java/Makefile b/benchmarks/drivers/Java/Makefile index cc4b4a7..92ab192 100644 --- a/benchmarks/drivers/Java/Makefile +++ b/benchmarks/drivers/Java/Makefile @@ -115,6 +115,12 @@ waterleak: #cd $(BIN_DIR)/iotcode/WaterLeakSensor; $(JAR) $(JARFLAGS) WaterLeakSensor.jar ../../iotcode/WaterLeakSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class ../../IrrigationController/MotionDetection*.class cd $(BIN_DIR)/iotcode/WaterLeakSensor; $(JAR) $(JARFLAGS) WaterLeakSensor.jar ../../iotcode/WaterLeakSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class +PHONY += doorlock +doorlock: + $(JAVAC) $(JFLAGS) DoorlockSensor/*.java + cp DoorlockSensor/DoorlockSensor.config $(BIN_DIR)/iotcode/DoorlockSensor + cd $(BIN_DIR)/iotcode/DoorlockSensor; $(JAR) $(JARFLAGS) DoorlockSensor.jar ../../iotcode/DoorlockSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class + # Compile - with checker # PHONY += check-light @@ -208,4 +214,10 @@ check-waterleak: cp WaterLeakSensor/WaterLeakSensor.config $(BIN_DIR)/iotcode/WaterLeakSensor cd $(BIN_DIR)/iotcode/WaterLeakSensor; $(JAR) $(JARFLAGS) WaterLeakSensor.jar ../../iotcode/WaterLeakSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class ../../IrrigationController/MotionDetection*.class +PHONY += check-doorlock +check-doorlock: + $(JAVAC) $(JFLAGS) $(CHECKER_OPT) $(ASTUBS) DoorlockSensor/*.java + cp DoorlockSensor/DoorlockSensor.config $(BIN_DIR)/iotcode/DoorlockSensor + cd $(BIN_DIR)/iotcode/DoorlockSensor; $(JAR) $(JARFLAGS) DoorlockSensor.jar ../../iotcode/DoorlockSensor/*.class ../../iotcode/interfaces/SmartthingsSensor*.class ../../iotcode/interfaces/Camera*.class + .PHONY: $(PHONY) diff --git a/benchmarks/other/DoorlockAndOutlet/IoTZigbee.java b/benchmarks/other/DoorlockAndOutlet/IoTZigbee.java index 6f0ad69..e3bb401 100644 --- a/benchmarks/other/DoorlockAndOutlet/IoTZigbee.java +++ b/benchmarks/other/DoorlockAndOutlet/IoTZigbee.java @@ -217,6 +217,8 @@ public 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"; diff --git a/benchmarks/other/ZigbeeTest/IoTZigbee.java b/benchmarks/other/ZigbeeTest/IoTZigbee.java index 6f0ad69..dd12352 100644 --- a/benchmarks/other/ZigbeeTest/IoTZigbee.java +++ b/benchmarks/other/ZigbeeTest/IoTZigbee.java @@ -216,7 +216,7 @@ public class IoTZigbee { DatagramPacket sendPacket = new DatagramPacket(message.getBytes(), message.getBytes().length, InetAddress.getByName(strHostAddress), iDstPort); 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 { String message = "type: zcl_configure_reporting\n"; message += "packet_id: " + String.format("%04x", packetId) + "\n"; diff --git a/iotjava/gmon.out b/iotjava/gmon.out new file mode 100644 index 0000000..7d5b7b2 Binary files /dev/null and b/iotjava/gmon.out differ diff --git a/iotjava/iotruntime/zigbee/IoTZigbee.java b/iotjava/iotruntime/zigbee/IoTZigbee.java index a047be5..a087546 100644 --- a/iotjava/iotruntime/zigbee/IoTZigbee.java +++ b/iotjava/iotruntime/zigbee/IoTZigbee.java @@ -221,13 +221,14 @@ public final class IoTZigbee { socket.send(sendPacket); } - public void sendConfigureReportingCommand(int packetId, int clusterId, int profileId, int deviceEndpoint, 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"; message += "cluster_id: " + String.format("%04x", clusterId) + "\n"; message += "profile_id: " + String.format("%04x", profileId) + "\n"; - message += "device_endpoint: " + String.format("%02x", deviceEndpoint) + "\n"; + message += "src_endpoint: " + String.format("%02x", src_endpoint) + "\n"; + message += "device_endpoint: " + String.format("%02x", dest_endpoint) + "\n"; message += "attribute_id: " + String.format("%04x", attributeId) + "\n"; message += "data_type: " + String.format("%02x", dataType) + "\n"; message += "min_reporting_interval: " + String.format("%04x", minReportingInterval) + "\n"; @@ -245,6 +246,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 registerCallback(IoTZigbeeCallback callbackTo) { callbackList.add(callbackTo); } diff --git a/iotjava/iotruntime/zigbee/IoTZigbeeMessageZclReadAttributesResponse.java b/iotjava/iotruntime/zigbee/IoTZigbeeMessageZclReadAttributesResponse.java index ce8b1e9..5143bb7 100644 --- a/iotjava/iotruntime/zigbee/IoTZigbeeMessageZclReadAttributesResponse.java +++ b/iotjava/iotruntime/zigbee/IoTZigbeeMessageZclReadAttributesResponse.java @@ -10,7 +10,7 @@ import java.util.List; */ public final class IoTZigbeeMessageZclReadAttributesResponse extends IoTZigbeeMessage { - static class Attribute { + public static class Attribute { // private variables private int attributeId;