use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeIasCieApp method appStartup.
@Override
public boolean appStartup(ZclCluster cluster) {
iasZoneCluster = (ZclIasZoneCluster) cluster;
Integer currentState = iasZoneCluster.getZoneState(0);
if (currentState != null) {
ZoneStateEnum currentStateEnum = ZoneStateEnum.getByValue(currentState);
logger.debug("{}: IAS CIE state is currently {}[{}]", iasZoneCluster.getZigBeeAddress(), currentStateEnum, currentState);
}
IeeeAddress currentIeeeAddress = iasZoneCluster.getIascieAddress(0);
logger.debug("{}: IAS CIE address is currently {}", iasZoneCluster.getZigBeeAddress(), currentIeeeAddress);
if (!ieeeAddress.equals(currentIeeeAddress)) {
// Set the CIE address in the remote device. This is where the device will send its reports.
iasZoneCluster.setIascieAddress(ieeeAddress);
currentIeeeAddress = iasZoneCluster.getIascieAddress(0);
logger.debug("{}: IAS CIE address is confirmed {}", iasZoneCluster.getZigBeeAddress(), currentIeeeAddress);
}
Integer currentZone = iasZoneCluster.getZoneId(0);
logger.debug("{}: IAS CIE zone is currently {}", iasZoneCluster.getZigBeeAddress(), currentZone);
return false;
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class ZigBeeDongleXBeeTest method sendCommand.
@Test
public void sendCommand() {
XBeeFrameHandler frameHandler = Mockito.mock(XBeeFrameHandler.class);
ArgumentCaptor<XBeeCommand> commandCapture = ArgumentCaptor.forClass(XBeeCommand.class);
Mockito.when(frameHandler.sendRequestAsync(commandCapture.capture())).thenReturn(null);
ZigBeeDongleXBee dongle = new ZigBeeDongleXBee(null);
Field field;
try {
field = dongle.getClass().getDeclaredField("frameHandler");
field.setAccessible(true);
field.set(dongle, frameHandler);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
MatchDescriptorResponse command = new MatchDescriptorResponse();
command.setDestinationAddress(new ZigBeeEndpointAddress(46946));
command.setNwkAddrOfInterest(46946);
command.setStatus(ZdoStatus.SUCCESS);
command.setTransactionId(0x2A);
List<Integer> matchList = new ArrayList<>();
matchList.add(1);
command.setMatchList(matchList);
ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
apsFrame.setDestinationAddress(46946);
apsFrame.setDestinationEndpoint(0);
apsFrame.setDestinationIeeeAddress(new IeeeAddress("000D6F00057CF7C6"));
apsFrame.setCluster(32774);
apsFrame.setAddressMode(ZigBeeNwkAddressMode.DEVICE);
apsFrame.setRadius(31);
apsFrame.setSequence(42);
apsFrame.setPayload(new int[] { 0x00, 0x00, 0x2E, 0x5B, 0x01, 0x01 });
System.out.println(command);
System.out.println(apsFrame);
dongle.sendCommand(apsFrame);
assertEquals(1, commandCapture.getAllValues().size());
XBeeTransmitRequestExplicitCommand sentCommand = (XBeeTransmitRequestExplicitCommand) commandCapture.getValue();
sentCommand.setFrameId(32);
System.out.println(sentCommand);
int[] payload = new int[] { 0, 26, 17, 32, 0, 13, 111, 0, 5, 124, 247, 198, 183, 98, 0, 0, 128, 6, 0, 0, 0, 32, 0, 0, 46, 91, 1, 1, 202 };
int[] output = sentCommand.serialize();
assertTrue(Arrays.equals(payload, output));
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class XBeeReceivePacketEventTest method test.
@Test
public void test() {
XBeeReceivePacketEvent event = new XBeeReceivePacketEvent();
event.deserialize(getPacketData("00 12 90 00 13 A2 00 40 52 2B AA 7D 84 01 52 78 44 61 74 61 0D"));
System.out.println(event);
assertEquals(0x90, event.getFrameType());
assertEquals(Integer.valueOf(0x7D84), event.getNetworkAddress());
assertEquals(ReceiveOptions.PACKET_ACKNOWLEDGED, event.getReceiveOptions());
assertEquals(new IeeeAddress("0013A20040522BAA"), event.getIeeeAddress());
assertTrue(Arrays.equals(getPacketData("52 78 44 61 74 61"), event.getData()));
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class XBeeRouteRecordEventTest method test.
@Test
public void test() {
XBeeRouteRecordEvent event = new XBeeRouteRecordEvent();
event.deserialize(getPacketData("00 13 A1 00 13 A2 00 40 40 11 22 33 44 01 03 EE FF CC DD AA BB 80"));
System.out.println(event);
assertEquals(0xA1, event.getFrameType());
assertEquals(Integer.valueOf(0x3344), event.getNetworkAddress());
assertEquals(ReceiveOptions.PACKET_ACKNOWLEDGED, event.getReceiveOptions());
assertEquals(new IeeeAddress("0013A20040401122"), event.getIeeeAddress());
assertEquals(3, event.getAddressList().length);
}
use of com.zsmartsystems.zigbee.IeeeAddress in project com.zsmartsystems.zigbee by zsmartsystems.
the class XBeeCreateSourceRouteCommandTest method test.
@Test
public void test() {
XBeeCreateSourceRouteCommand command = new XBeeCreateSourceRouteCommand();
command.setFrameId(0);
command.setIeeeAddress(new IeeeAddress("0013A20040401122"));
command.setNetworkAddress(0x3344);
command.setAddressList(new int[] { 0xEEFF, 0xCCDD, 0xAABB });
System.out.println(command);
assertTrue(Arrays.equals(new int[] { 0x00, 0x14, 0x21, 0x00, 0x00, 0x13, 0xA2, 0x00, 0x40, 0x40, 0x11, 0x22, 0x33, 0x44, 0x00, 0x03, 0xEE, 0xFF, 0xCC, 0xDD, 0xAA, 0xBB, 0x01 }, command.serialize()));
}
Aggregations