Search in sources :

Example 21 with ZigBeeApsFrame

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

the class ZdoSimpleDescriptor method create.

public static ZigBeeApsFrame create(ZToolPacket packet) {
    ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
    apsFrame.setCluster(ZdoCommandType.SIMPLE_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)

Example 22 with ZigBeeApsFrame

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

the class ZDO_MGMT_RTG_RSP_Test method testReceive.

@Test
public void testReceive() {
    ZToolPacket data = getPacket("FE 0B 45 B2 00 00 00 01 00 01 2A 2F 00 35 38 F4");
    ZigBeeApsFrame apsFrame = ZdoManagementRouting.create(data);
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("00 00 01 00 01 2A 2F 00 35 38"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 23 with ZigBeeApsFrame

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

the class ZDO_SIMPLE_DESC_RSP_Test method testReceive2.

@Test
public void testReceive2() {
    ZToolPacket data = getPacket("FE 18 45 84 21 A4 00 21 A4 12 02 04 01 01 00 00 02 00 00 03 00 03 05 00 06 00 08 00 C4");
    ZigBeeApsFrame apsFrame = ZdoSimpleDescriptor.create(data);
    assertEquals(42017, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("A4 00 21 A4 12 02 04 01 01 00 00 02 00 00 03 00 03 05 00 06 00 08 00"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 24 with ZigBeeApsFrame

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

the class ZigBeeDongleConBee method receiveIncomingFrame.

/**
 * @param frame the received {@link ConBeeFrame}
 */
public void receiveIncomingFrame(ConBeeFrame frame) {
    if (frame instanceof ConBeeReadReceivedDataResponse) {
        ConBeeReadReceivedDataResponse receivedData = (ConBeeReadReceivedDataResponse) frame;
        if (receivedData.getStatus() != ConBeeStatus.SUCCESS) {
            return;
        }
        ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
        // apsFrame.setApsCounter(emberApsFrame.getSequence());
        apsFrame.setCluster(receivedData.getClusterId());
        apsFrame.setDestinationEndpoint(receivedData.getDestinationEndpoint());
        apsFrame.setProfile(receivedData.getProfileId());
        apsFrame.setSourceEndpoint(receivedData.getSourceEndpoint());
        // receivedData.getSourceAddressMode()
        // apsFrame.sets
        apsFrame.setSourceAddress(receivedData.getSourceNetworkAddress());
        apsFrame.setPayload(receivedData.getAdsuData());
        zigbeeNetworkReceive.receiveCommand(apsFrame);
        return;
    }
    if (frame instanceof ConBeeDeviceStateChanged || frame instanceof ConBeeDeviceStateResponse) {
        ConBeeDeviceState deviceState;
        if (frame instanceof ConBeeDeviceStateChanged) {
            deviceState = ((ConBeeDeviceStateChanged) frame).getDeviceState();
        } else {
            deviceState = ((ConBeeDeviceStateResponse) frame).getDeviceState();
        }
        if (!initialisationComplete || deviceState.getNetworkState() == currentNetworkState) {
            return;
        }
        currentNetworkState = deviceState.getNetworkState();
        switch(deviceState.getNetworkState()) {
            case NET_CONNECTED:
                zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.ONLINE);
                break;
            case NET_JOINING:
            case NET_LEAVING:
            case NET_OFFLINE:
                zigbeeNetworkReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
                break;
            default:
                break;
        }
    }
}
Also used : ConBeeDeviceState(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceState) ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ConBeeDeviceStateChanged(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateChanged) ConBeeReadReceivedDataResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)

Example 25 with ZigBeeApsFrame

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

the class ZDO_END_DEVICE_ANNCE_IND_Test method testReceive.

@Test
public void testReceive() {
    ZToolPacket data = getPacket("FE 0D 45 C1 2A 2F 2A 2F F9 41 F6 02 00 4B 12 00 00 9C");
    ZigBeeApsFrame apsFrame = ZdoEndDeviceAnnounce.create(data);
    assertEquals(0x2f2a, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("2F 2A 2F F9 41 F6 02 00 4B 12 00 00"), 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