Search in sources :

Example 26 with IeeeAddress

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;
}
Also used : ZoneStateEnum(com.zsmartsystems.zigbee.zcl.clusters.iaszone.ZoneStateEnum) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress)

Example 27 with IeeeAddress

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));
}
Also used : XBeeCommand(com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeCommand) ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) XBeeFrameHandler(com.zsmartsystems.zigbee.dongle.xbee.internal.XBeeFrameHandler) MatchDescriptorResponse(com.zsmartsystems.zigbee.zdo.command.MatchDescriptorResponse) ArrayList(java.util.ArrayList) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Field(java.lang.reflect.Field) ZigBeeEndpointAddress(com.zsmartsystems.zigbee.ZigBeeEndpointAddress) XBeeTransmitRequestExplicitCommand(com.zsmartsystems.zigbee.dongle.xbee.internal.protocol.XBeeTransmitRequestExplicitCommand) Test(org.junit.Test)

Example 28 with IeeeAddress

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()));
}
Also used : IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 29 with IeeeAddress

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);
}
Also used : IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 30 with IeeeAddress

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()));
}
Also used : IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Aggregations

IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)66 Test (org.junit.Test)53 ZigBeeEndpoint (com.zsmartsystems.zigbee.ZigBeeEndpoint)12 ZigBeeNode (com.zsmartsystems.zigbee.ZigBeeNode)12 CommandTest (com.zsmartsystems.zigbee.CommandTest)7 DefaultDeserializer (com.zsmartsystems.zigbee.serialization.DefaultDeserializer)7 ZclOnOffCluster (com.zsmartsystems.zigbee.zcl.clusters.ZclOnOffCluster)7 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)6 ZclFieldDeserializer (com.zsmartsystems.zigbee.zcl.ZclFieldDeserializer)6 ArrayList (java.util.ArrayList)6 ZigBeeCommand (com.zsmartsystems.zigbee.ZigBeeCommand)5 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)4 CommandResult (com.zsmartsystems.zigbee.CommandResult)3 ExtendedPanId (com.zsmartsystems.zigbee.ExtendedPanId)3 NodeDescriptor (com.zsmartsystems.zigbee.zdo.field.NodeDescriptor)3 HashSet (java.util.HashSet)3 ZigBeeNetworkManager (com.zsmartsystems.zigbee.ZigBeeNetworkManager)2 EmberInitialSecurityState (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberInitialSecurityState)2 EmberKeyData (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberKeyData)2 XBeeFrameHandler (com.zsmartsystems.zigbee.dongle.xbee.internal.XBeeFrameHandler)2