Search in sources :

Example 16 with ZigBeeApsFrame

use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspIncomingMessageHandlerTest method testReceive2.

@Test
public void testReceive2() {
    EzspFrame.setEzspVersion(4);
    // This tests a number of stages - not just this class
    // We process the received frame, make sure the dongle sends it to the networkManager
    EzspIncomingMessageHandler incomingMessageHandler = new EzspIncomingMessageHandler(getPacketData("01 90 45 00 00 00 01 80 00 00 40 00 00 00 EE FF 00 00 00 FF FF 0C 00 81 F0 F0 00 20 00 00 00 00 00 01"));
    System.out.println(incomingMessageHandler);
    assertEquals(0x45, incomingMessageHandler.getFrameId());
    assertTrue(incomingMessageHandler.isResponse());
    assertEquals(EmberIncomingMessageType.EMBER_INCOMING_UNICAST, incomingMessageHandler.getType());
    ZigBeeTransportReceive transportReceiveMock = Mockito.mock(ZigBeeTransportReceive.class);
    ArgumentCaptor<ZigBeeApsFrame> apsFrame = ArgumentCaptor.forClass(ZigBeeApsFrame.class);
    Mockito.doNothing().when(transportReceiveMock).receiveCommand(apsFrame.capture());
    ZigBeeDongleEzsp dongle = new ZigBeeDongleEzsp(null);
    dongle.setZigBeeTransportReceive(transportReceiveMock);
    dongle.handlePacket(incomingMessageHandler);
    assertEquals(1, apsFrame.getAllValues().size());
    assertEquals(0, apsFrame.getValue().getSourceAddress());
    assertEquals(0, apsFrame.getValue().getDestinationAddress());
    assertEquals(0, apsFrame.getValue().getProfile());
    assertEquals(238, apsFrame.getValue().getApsCounter());
    assertEquals(0x8001, apsFrame.getValue().getCluster());
    assertEquals(0, apsFrame.getValue().getSourceEndpoint());
    assertEquals(0, apsFrame.getValue().getDestinationEndpoint());
    assertTrue(Arrays.equals(apsFrame.getValue().getPayload(), getPacketData("00 81 F0 F0 00 20 00 00 00 00 00 01")));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZigBeeDongleEzsp(com.zsmartsystems.zigbee.dongle.ember.ZigBeeDongleEzsp) ZigBeeTransportReceive(com.zsmartsystems.zigbee.transport.ZigBeeTransportReceive) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Example 17 with ZigBeeApsFrame

use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZigBeeDongleTiCc2531 method notify.

@Override
public boolean notify(final AF_INCOMING_MSG clusterMessage) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(clusterMessage.getClusterId());
    apsFrame.setDestinationEndpoint(clusterMessage.getDstEndpoint());
    apsFrame.setSourceEndpoint(clusterMessage.getSrcEndpoint());
    apsFrame.setProfile(getEndpointProfile(clusterMessage.getDstEndpoint()));
    // nwkHeader.setDestinationAddress(clusterMessage.geta);
    apsFrame.setSourceAddress(clusterMessage.getSrcAddr());
    apsFrame.setSequence(clusterMessage.getTransId());
    apsFrame.setPayload(clusterMessage.getData());
    zigbeeNetworkReceive.receiveCommand(apsFrame);
    return true;
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame)

Example 18 with ZigBeeApsFrame

use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZdoManagementLeave method create.

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(ZdoCommandType.MANAGEMENT_LEAVE_RESPONSE.getClusterId());
    apsFrame.setDestinationEndpoint(0);
    apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
    apsFrame.setSourceEndpoint(0);
    apsFrame.setProfile(0);
    apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 5, packet.getPacket().length - 1));
    return apsFrame;
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame)

Example 19 with ZigBeeApsFrame

use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZdoManagementRouting method create.

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(ZdoCommandType.MANAGEMENT_ROUTING_RESPONSE.getClusterId());
    apsFrame.setDestinationEndpoint(0);
    apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
    apsFrame.setSourceEndpoint(0);
    apsFrame.setProfile(0);
    apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 5, packet.getPacket().length - 1));
    return apsFrame;
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame)

Example 20 with ZigBeeApsFrame

use of com.zsmartsystems.zigbee.ZigBeeApsFrame in project com.zsmartsystems.zigbee by zsmartsystems.

the class ZdoPowerDescriptor method create.

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(ZdoCommandType.POWER_DESCRIPTOR_RESPONSE.getClusterId());
    apsFrame.setDestinationEndpoint(0);
    apsFrame.setSourceAddress(packet.getPacket()[4] + (packet.getPacket()[5] << 8));
    apsFrame.setSourceEndpoint(0);
    apsFrame.setProfile(0);
    apsFrame.setPayload(Arrays.copyOfRange(packet.getPacket(), 5, packet.getPacket().length - 1));
    return apsFrame;
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame)

Aggregations

ZigBeeApsFrame (com.zsmartsystems.zigbee.ZigBeeApsFrame)29 Test (org.junit.Test)14 ZToolPacket (com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket)12 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 ZigBeeEndpointAddress (com.zsmartsystems.zigbee.ZigBeeEndpointAddress)1 ZigBeeNodeStatus (com.zsmartsystems.zigbee.ZigBeeNodeStatus)1 ConBeeDeviceState (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceState)1 ConBeeDeviceStateChanged (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateChanged)1 ConBeeDeviceStateResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)1 ConBeeReadReceivedDataResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse)1 ZigBeeDongleEzsp (com.zsmartsystems.zigbee.dongle.ember.ZigBeeDongleEzsp)1 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)1 EzspChildJoinHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspChildJoinHandler)1 EzspIncomingMessageHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspIncomingMessageHandler)1 EzspStackStatusHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspStackStatusHandler)1 EzspTrustCenterJoinHandler (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspTrustCenterJoinHandler)1 EmberApsFrame (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame)1 TelegesisDeviceJoinedNetworkEvent (com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisDeviceJoinedNetworkEvent)1 TelegesisDeviceLeftNetworkEvent (com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisDeviceLeftNetworkEvent)1 TelegesisNetworkJoinedEvent (com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisNetworkJoinedEvent)1