Search in sources :

Example 1 with ConBeeReadReceivedDataResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ConBeeReadReceivedDataResponseTest method readResponse.

@Test
public void readResponse() {
    ConBeeReadReceivedDataResponse readResponse = new ConBeeReadReceivedDataResponse(new int[] { 0x17, 0x0C, 0x00, 0x32, 0x00, 0x2B, 0x00, 0x26, 0x02, 0x00, 0x00, 0x00, 0x03, 0x8C, 0x0A, 0x01, 0xFF, 0xFF, 0x2E, 0x21, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x0E, 0x00, 0x00, 0x00, 0x8C, 0x0A, 0x01, 0xFF, 0xFF, 0x2E, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xAF, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x4B, 0xF8, 0xC0 });
    System.out.println(readResponse);
    assertEquals(12, readResponse.getSequence());
    assertEquals(ConBeeStatus.SUCCESS, readResponse.getStatus());
    assertEquals(0x8001, readResponse.getClusterId());
    assertEquals(14, readResponse.getAdsuData().length);
    assertEquals(new IeeeAddress("00212EFFFF010A8C"), readResponse.getSourceIeeeAddress());
}
Also used : ConBeeReadReceivedDataResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse) IeeeAddress(com.zsmartsystems.zigbee.IeeeAddress) Test(org.junit.Test)

Example 2 with ConBeeReadReceivedDataResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse in project com.zsmartsystems.zigbee by zsmartsystems.

the class ConBeeReadReceivedDataResponseTest method readErrorResponse.

@Test
public void readErrorResponse() {
    ConBeeReadReceivedDataResponse readResponse = new ConBeeReadReceivedDataResponse(new int[] { 0x17, 0x15, 0x05, 0x08, 0x00, 0x01, 0x00, 0x26, 0xA0, 0xFF, 0xC0 });
    System.out.println(readResponse);
    assertEquals(21, readResponse.getSequence());
    assertEquals(ConBeeStatus.ERROR, readResponse.getStatus());
}
Also used : ConBeeReadReceivedDataResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse) Test(org.junit.Test)

Example 3 with ConBeeReadReceivedDataResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse 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)

Aggregations

ConBeeReadReceivedDataResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse)3 Test (org.junit.Test)2 IeeeAddress (com.zsmartsystems.zigbee.IeeeAddress)1 ZigBeeApsFrame (com.zsmartsystems.zigbee.ZigBeeApsFrame)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