Search in sources :

Example 1 with ZigBeeTransportReceive

use of com.zsmartsystems.zigbee.transport.ZigBeeTransportReceive 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)

Aggregations

ZigBeeApsFrame (com.zsmartsystems.zigbee.ZigBeeApsFrame)1 ZigBeeDongleEzsp (com.zsmartsystems.zigbee.dongle.ember.ZigBeeDongleEzsp)1 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)1 ZigBeeTransportReceive (com.zsmartsystems.zigbee.transport.ZigBeeTransportReceive)1 Test (org.junit.Test)1