Search in sources :

Example 11 with ZigBeeApsFrame

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

the class ZigBeeDongleEzsp method handlePacket.

@Override
public void handlePacket(EzspFrame response) {
    logger.debug("RX: " + response.toString());
    if (response instanceof EzspIncomingMessageHandler) {
        EzspIncomingMessageHandler incomingMessage = (EzspIncomingMessageHandler) response;
        EmberApsFrame emberApsFrame = incomingMessage.getApsFrame();
        ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
        apsFrame.setApsCounter(emberApsFrame.getSequence());
        apsFrame.setCluster(emberApsFrame.getClusterId());
        apsFrame.setDestinationEndpoint(emberApsFrame.getDestinationEndpoint());
        apsFrame.setProfile(emberApsFrame.getProfileId());
        apsFrame.setSourceEndpoint(emberApsFrame.getSourceEndpoint());
        apsFrame.setSequence(incomingMessage.getSequenceNumber());
        apsFrame.setSourceAddress(incomingMessage.getSender());
        apsFrame.setPayload(incomingMessage.getMessageContents());
        zigbeeTransportReceive.receiveCommand(apsFrame);
        return;
    }
    // TODO: Check if this should be done only after initialisation is complete?
    if (response instanceof EzspStackStatusHandler) {
        switch(((EzspStackStatusHandler) response).getStatus()) {
            case EMBER_NETWORK_BUSY:
                break;
            case EMBER_NETWORK_DOWN:
                zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
                break;
            case EMBER_NETWORK_UP:
                break;
            default:
                break;
        }
        return;
    }
    if (response instanceof EzspTrustCenterJoinHandler) {
        EzspTrustCenterJoinHandler joinHandler = (EzspTrustCenterJoinHandler) response;
        ZigBeeNodeStatus status;
        switch(joinHandler.getStatus()) {
            case EMBER_HIGH_SECURITY_UNSECURED_JOIN:
            case EMBER_STANDARD_SECURITY_UNSECURED_JOIN:
                status = ZigBeeNodeStatus.UNSECURED_JOIN;
                break;
            case EMBER_HIGH_SECURITY_UNSECURED_REJOIN:
            case EMBER_STANDARD_SECURITY_UNSECURED_REJOIN:
                status = ZigBeeNodeStatus.UNSECURED_REJOIN;
                break;
            case EMBER_HIGH_SECURITY_SECURED_REJOIN:
            case EMBER_STANDARD_SECURITY_SECURED_REJOIN:
                status = ZigBeeNodeStatus.SECURED_REJOIN;
                break;
            case EMBER_DEVICE_LEFT:
                status = ZigBeeNodeStatus.DEVICE_LEFT;
                break;
            default:
                logger.debug("Unknown state in trust centre join handler {}", joinHandler.getStatus());
                return;
        }
        zigbeeTransportReceive.nodeStatusUpdate(status, joinHandler.getNewNodeId(), joinHandler.getNewNodeEui64());
        return;
    }
    if (response instanceof EzspChildJoinHandler) {
        EzspChildJoinHandler joinHandler = (EzspChildJoinHandler) response;
        zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.UNSECURED_JOIN, joinHandler.getChildId(), joinHandler.getChildEui64());
        return;
    }
    logger.debug("Unhandled EZSP Frame: {}", response.toString());
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) EzspStackStatusHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspStackStatusHandler) EmberApsFrame(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.structure.EmberApsFrame) ZigBeeNodeStatus(com.zsmartsystems.zigbee.ZigBeeNodeStatus) EzspIncomingMessageHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspIncomingMessageHandler) EzspTrustCenterJoinHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspTrustCenterJoinHandler) EzspChildJoinHandler(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspChildJoinHandler)

Example 12 with ZigBeeApsFrame

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

the class ZDO_MSG_CB_INCOMING_Test method testReceive.

@Test
public void testReceive() {
    ZToolPacket data = getPacket("FE 15 45 FF 00 00 00 01 80 00 00 00 1B 00 5B 23 EB 09 00 4B 12 00 00 00 00 F6");
    ZigBeeApsFrame apsFrame = ZdoCallbackIncoming.create(data);
    assertEquals(0x8001, apsFrame.getCluster());
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("1B 00 5B 23 EB 09 00 4B 12 00 00 00 00"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 13 with ZigBeeApsFrame

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

the class ZDO_NODE_DESC_RSP_Test method testReceive.

@Test
public void testReceive() {
    ZToolPacket data = getPacket("FE 12 45 82 00 00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00 CB");
    ZigBeeApsFrame apsFrame = ZdoNodeDescriptor.create(data);
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("00 00 00 00 00 40 0F 00 00 50 A0 00 01 00 A0 00 00"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 14 with ZigBeeApsFrame

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

the class ZDO_POWER_DESC_RSP_Test method testReceive.

@Test
public void testReceive() {
    ZToolPacket data = getPacket("FE 07 45 83 00 00 00 00 00 10 C1 10");
    ZigBeeApsFrame apsFrame = ZdoPowerDescriptor.create(data);
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("00 00 00 00 10 C1"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 15 with ZigBeeApsFrame

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

the class ZDO_SIMPLE_DESC_RSP_Test method testReceive1.

@Test
public void testReceive1() {
    ZToolPacket data = getPacket("FE 2E 45 84 00 00 00 00 00 28 01 04 01 00 00 00 00 10 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0F 00 0A 00 0C 00 15 00 00 01 01 01 CF");
    ZigBeeApsFrame apsFrame = ZdoSimpleDescriptor.create(data);
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("00 00 00 00 28 01 04 01 00 00 00 00 10 00 00 01 00 02 00 03 00 04 00 05 00 06 00 07 00 08 00 09 00 0F 00 0A 00 0C 00 15 00 00 01 01 01"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

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