Search in sources :

Example 1 with ZigBeeApsFrame

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

the class ZigBeeDongleTelegesis method telegesisEventReceived.

@Override
public void telegesisEventReceived(TelegesisEvent event) {
    if (event instanceof TelegesisReceiveMessageEvent) {
        TelegesisReceiveMessageEvent rxMessage = (TelegesisReceiveMessageEvent) event;
        ZigBeeApsFrame apsFrame = new ZigBeeApsFrame();
        // apsFrame.setApsCounter(emberApsFrame.getSequence());
        apsFrame.setCluster(rxMessage.getClusterId());
        apsFrame.setDestinationEndpoint(rxMessage.getDestinationEp());
        apsFrame.setProfile(rxMessage.getProfileId());
        apsFrame.setSourceEndpoint(rxMessage.getSourceEp());
        apsFrame.setSourceAddress(rxMessage.getNetworkAddress());
        apsFrame.setPayload(rxMessage.getMessageData());
        zigbeeTransportReceive.receiveCommand(apsFrame);
        return;
    }
    // Handle devices joining and leaving
    if (event instanceof TelegesisDeviceJoinedNetworkEvent) {
        TelegesisDeviceJoinedNetworkEvent deviceJoinedEvent = (TelegesisDeviceJoinedNetworkEvent) event;
        zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.UNSECURED_JOIN, deviceJoinedEvent.getNetworkAddress(), deviceJoinedEvent.getIeeeAddress());
        return;
    }
    if (event instanceof TelegesisDeviceLeftNetworkEvent) {
        TelegesisDeviceLeftNetworkEvent deviceLeftEvent = (TelegesisDeviceLeftNetworkEvent) event;
        zigbeeTransportReceive.nodeStatusUpdate(ZigBeeNodeStatus.DEVICE_LEFT, deviceLeftEvent.getNetworkAddress(), deviceLeftEvent.getIeeeAddress());
        return;
    }
    // Handle link changes and notify framework or just reset link with dongle?
    if (event instanceof TelegesisNetworkLeftEvent | event instanceof TelegesisNetworkLostEvent) {
        zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.OFFLINE);
        return;
    }
    if (event instanceof TelegesisNetworkJoinedEvent) {
        zigbeeTransportReceive.setNetworkState(ZigBeeTransportState.ONLINE);
        return;
    }
    logger.debug("Unhandled Telegesis Frame: {}", event.toString());
}
Also used : TelegesisDeviceJoinedNetworkEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisDeviceJoinedNetworkEvent) ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) TelegesisReceiveMessageEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisReceiveMessageEvent) TelegesisNetworkLostEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisNetworkLostEvent) TelegesisNetworkLeftEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisNetworkLeftEvent) TelegesisNetworkJoinedEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisNetworkJoinedEvent) TelegesisDeviceLeftNetworkEvent(com.zsmartsystems.zigbee.dongle.telegesis.internal.protocol.TelegesisDeviceLeftNetworkEvent)

Example 2 with ZigBeeApsFrame

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

the class ZdoActiveEndpoint method create.

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

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

the class ZdoCallbackIncoming method create.

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

Example 4 with ZigBeeApsFrame

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

the class ZDO_ACTIVE_EP_RSP_Test method testReceive.

@Test
public void testReceive() {
    String packetString = "FE 08 45 85 00 00 00 00 00 02 02 01 C9";
    ZToolPacket data = getPacket(packetString);
    assertEquals(packetString, data.getPacketString());
    ZigBeeApsFrame apsFrame = ZdoActiveEndpoint.create(data);
    assertEquals(0x0000, apsFrame.getSourceAddress());
    assertEquals(0, apsFrame.getProfile());
    assertEquals(0, apsFrame.getDestinationEndpoint());
    assertTrue(Arrays.equals(getPacketData("00 00 00 00 02 02 01"), apsFrame.getPayload()));
}
Also used : ZigBeeApsFrame(com.zsmartsystems.zigbee.ZigBeeApsFrame) ZToolPacket(com.zsmartsystems.zigbee.dongle.cc2531.network.packet.ZToolPacket) Test(org.junit.Test)

Example 5 with ZigBeeApsFrame

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

the class ZdoEndDeviceAnnounce method create.

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