Search in sources :

Example 1 with ConBeeDeviceStateResponse

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

the class ConBeeSingleResponseTransactionTest method testResponseMatches.

@Test
public void testResponseMatches() {
    ConBeeDeviceStateRequest request = new ConBeeDeviceStateRequest();
    ConBeeTransaction transaction = new ConBeeSingleResponseTransaction(request, ConBeeDeviceStateResponse.class);
    ConBeeDeviceStateResponse response = new ConBeeDeviceStateResponse(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
    assertTrue(transaction.isMatch(response));
    transaction.getRequest();
    assertEquals(1, transaction.getResponses().size());
    assertNotNull(transaction.getResponses());
    assertEquals(transaction.getResponses().get(0), transaction.getResponse());
}
Also used : ConBeeSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction) ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) ConBeeTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeTransaction) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse) Test(org.junit.Test)

Example 2 with ConBeeDeviceStateResponse

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

the class ZigBeeDongleConBee method startup.

@Override
public boolean startup(boolean reinitialize) {
    logger.debug("ConBee transport startup");
    ConBeeDeviceStateRequest stateRequest = new ConBeeDeviceStateRequest();
    ConBeeDeviceStateResponse stateResponse = (ConBeeDeviceStateResponse) conbeeHandler.sendTransaction(new ConBeeSingleResponseTransaction(stateRequest, ConBeeDeviceStateResponse.class)).getResponse();
    stateResponse.getDeviceState();
    return true;
}
Also used : ConBeeSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction) ConBeeDeviceStateRequest(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)

Example 3 with ConBeeDeviceStateResponse

use of com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse 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 4 with ConBeeDeviceStateResponse

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

the class ConBeeDeviceStateResponseTest method doRequest.

@Test
public void doRequest() {
    ConBeeDeviceStateResponse response = new ConBeeDeviceStateResponse(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
    System.out.print(response);
    assertEquals(0, response.getSequence());
    assertEquals(ConBeeStatus.SUCCESS, response.getStatus());
    assertEquals(ConBeeNetworkState.NET_CONNECTED, response.getDeviceState().getNetworkState());
    assertFalse(response.getDeviceState().isDataConfirm());
    assertFalse(response.getDeviceState().isDataIndication());
    assertTrue(response.getDeviceState().isDataRequest());
    assertFalse(response.getDeviceState().isConfigChanged());
}
Also used : ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse) Test(org.junit.Test)

Example 5 with ConBeeDeviceStateResponse

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

the class ConBeeFrameTest method testCreateDeviceStateResponse.

@Test
public void testCreateDeviceStateResponse() {
    ConBeeFrame frame = ConBeeFrame.create(new int[] { 0x07, 0x00, 0x00, 0x08, 0x00, 0xA2, 0x00, 0x00, 0x4F, 0xFF });
    System.out.println(frame);
    assertNotNull(frame);
    assertTrue(frame instanceof ConBeeDeviceStateResponse);
    assertEquals(0, frame.getSequence());
}
Also used : ConBeeFrame(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeFrame) ConBeeDeviceStateResponse(com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse) Test(org.junit.Test)

Aggregations

ConBeeDeviceStateResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateResponse)5 Test (org.junit.Test)3 ConBeeDeviceStateRequest (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeDeviceStateRequest)2 ConBeeSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeSingleResponseTransaction)2 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 ConBeeFrame (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeFrame)1 ConBeeReadReceivedDataResponse (com.zsmartsystems.zigbee.dongle.conbee.internal.frame.ConBeeReadReceivedDataResponse)1 ConBeeTransaction (com.zsmartsystems.zigbee.dongle.conbee.internal.transaction.ConBeeTransaction)1