Search in sources :

Example 1 with EzspVersionRequest

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspSingleResponseTransactionTest method testResponseMatches.

@Test
public void testResponseMatches() {
    EzspVersionRequest version = new EzspVersionRequest();
    version.setSequenceNumber(3);
    version.setDesiredProtocolVersion(4);
    EzspTransaction versionTransaction = new EzspSingleResponseTransaction(version, EzspVersionResponse.class);
    EzspVersionResponse versionResponse = new EzspVersionResponse(getPacketData("03 80 00 04 02 00 58"));
    assertTrue(versionTransaction.isMatch(versionResponse));
    versionTransaction.getRequest();
    assertEquals(1, versionTransaction.getResponses().size());
    assertNotNull(versionTransaction.getResponses());
    assertEquals(versionTransaction.getResponses().get(0), versionTransaction.getResponse());
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Example 2 with EzspVersionRequest

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class EzspSingleResponseTransactionTest method testResponseMatchFails.

@Test
public void testResponseMatchFails() {
    EzspVersionRequest version = new EzspVersionRequest();
    version.setSequenceNumber(4);
    version.setDesiredProtocolVersion(4);
    EzspTransaction versionTransaction = new EzspSingleResponseTransaction(version, EzspVersionResponse.class);
    EzspVersionResponse versionResponse = new EzspVersionResponse(getPacketData("03 80 00 04 02 00 58"));
    assertFalse(versionTransaction.isMatch(versionResponse));
    assertNull(versionTransaction.getResponse());
    assertNull(versionTransaction.getResponses());
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction) EzspFrameTest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest) Test(org.junit.Test)

Example 3 with EzspVersionRequest

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class AshFrameHandlerTest method testAshFrameData.

@Test
public void testAshFrameData() {
    AshFrameData frame;
    EzspVersionRequest request = new EzspVersionRequest();
    request.setSequenceNumber(1);
    request.setDesiredProtocolVersion(4);
    frame = new AshFrameData(request);
    System.out.println(frame);
    assertTrue(Arrays.equals(new int[] { 0, 67, 33, 168, 80, 155, 152, 126 }, frame.getOutputBuffer()));
    request = new EzspVersionRequest();
    request.setSequenceNumber(2);
    request.setDesiredProtocolVersion(4);
    frame = new AshFrameData(request);
    frame.setAckNum(3);
    frame.setFrmNum(4);
    System.out.println(frame);
    assertTrue(Arrays.equals(new int[] { 67, 64, 33, 168, 80, 255, 254, 126 }, frame.getOutputBuffer()));
    request = new EzspVersionRequest();
    request.setSequenceNumber(3);
    request.setDesiredProtocolVersion(4);
    frame = new AshFrameData(request);
    frame.setAckNum(6);
    frame.setFrmNum(2);
    frame.setReTx();
    System.out.println(frame);
    assertTrue(Arrays.equals(new int[] { 46, 65, 33, 168, 80, 177, 236, 126 }, frame.getOutputBuffer()));
    AshFrame inFrame = AshFrame.createFromInput(new int[] { 46, 65, 33, 168, 80, 177, 236 });
    assertTrue(inFrame instanceof AshFrameData);
    assertEquals(6, inFrame.getAckNum());
    assertEquals(2, inFrame.getFrmNum());
    assertEquals(FrameType.DATA, inFrame.getFrameType());
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) Test(org.junit.Test)

Example 4 with EzspVersionRequest

use of com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest in project com.zsmartsystems.zigbee by zsmartsystems.

the class EmberNcp method getVersion.

/**
 * The command allows the Host to specify the desired EZSP version and must be sent before any other command. The
 * response provides information about the firmware running on the NCP.
 *
 * @param desiredVersion the requested version we support
 * @return the {@link EzspVersionResponse}
 */
public EzspVersionResponse getVersion(int desiredVersion) {
    EzspVersionRequest request = new EzspVersionRequest();
    request.setDesiredProtocolVersion(EzspFrame.getEzspVersion());
    EzspTransaction transaction = ashHandler.sendEzspTransaction(new EzspSingleResponseTransaction(request, EzspVersionResponse.class));
    EzspVersionResponse response = (EzspVersionResponse) transaction.getResponse();
    logger.debug(response.toString());
    lastStatus = null;
    return response;
}
Also used : EzspVersionRequest(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest) EzspTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction) EzspVersionResponse(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse) EzspSingleResponseTransaction(com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)

Aggregations

EzspVersionRequest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionRequest)4 EzspVersionResponse (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.command.EzspVersionResponse)3 EzspSingleResponseTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspSingleResponseTransaction)3 EzspTransaction (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.transaction.EzspTransaction)3 Test (org.junit.Test)3 EzspFrameTest (com.zsmartsystems.zigbee.dongle.ember.internal.ezsp.EzspFrameTest)2