@Test public void handleReset() throws Exception { System.out.println("--- " + Thread.currentThread().getStackTrace()[1].getMethodName()); int[] dataCorrupt = new int[] { 0xC1, 0x02, 0x02, 0x9B, 0x7C, 0x7E }; int[] dataPOR = new int[] { 0xC1, 0x02, 0x02, 0x9B, 0x7B, 0x7E }; int[] dataSWV1 = new int[] { 0xC1, 0x01, 0x0B, 0x5F, 0x01, 0x7E }; int[] dataSWV2 = new int[] { 0xC1, 0x02, 0x0B, 0x0A, 0x52, 0x7E }; byte[] bytedata = new byte[dataPOR.length * 5]; int cnt = 0; for (int value : dataCorrupt) { bytedata[cnt++] = (byte) value; } for (int value : dataPOR) { bytedata[cnt++] = (byte) value; } for (int value : dataSWV1) { bytedata[cnt++] = (byte) value; } for (int value : dataSWV2) { bytedata[cnt++] = (byte) value; } for (int value : dataPOR) { bytedata[cnt++] = (byte) value; } ByteArrayInputStream stream = new ByteArrayInputStream(bytedata); ZigBeePort port = new TestPort(stream, null); EzspFrameHandler ezspHandler = Mockito.mock(EzspFrameHandler.class); AshFrameHandler frameHandler = new AshFrameHandler(ezspHandler); frameHandler.start(port); Mockito.verify(ezspHandler, Mockito.timeout(TIMEOUT)).handleLinkStateChange(true); }
private synchronized void handleReset(AshFrameRstAck rstAck) { if (stateConnected) { logger.debug("ASH: RESET received while connected. Disconnecting."); disconnect(); return; } if (rstAck.getResetType() != AshErrorCode.RESET_SOFTWARE) { return; } if (rstAck.getVersion() == 2) { startConnectTimer(); } else { logger.debug("ASH: Invalid version"); } }
AshFrameHandler implements EzspProtocolHandler { private synchronized void handleReset(AshFrameRstAck rstAck) { if (stateConnected) { logger.debug("ASH: RESET received while connected. Disconnecting."); disconnect(); return; } if (rstAck.getResetType() != AshErrorCode.RESET_SOFTWARE) { return; } if (rstAck.getVersion() == 2) { startConnectTimer(); } else { logger.debug("ASH: Invalid version"); } } }
AshFrameHandler implements EzspProtocolHandler { private synchronized void handleReset(AshFrameRstAck rstAck) { if (stateConnected) { logger.debug("ASH: RESET received while connected. Disconnecting."); disconnect(); return; } if (rstAck.getResetType() != AshErrorCode.RESET_SOFTWARE) { return; } if (rstAck.getVersion() == 2) { startConnectTimer(); } else { logger.debug("ASH: Invalid version"); } } AshFrameHandler(final EzspFrameHandler frameHandler); }
AshFrameHandler implements EzspProtocolHandler { private synchronized void handleReset(AshFrameRstAck rstAck) { if (stateConnected) { logger.debug("ASH: RESET received while connected. Disconnecting."); disconnect(); return; } if (rstAck.getResetType() != AshErrorCode.RESET_SOFTWARE) { return; } if (rstAck.getVersion() == 2) { startConnectTimer(); } else { logger.debug("ASH: Invalid version"); } } AshFrameHandler(final EzspFrameHandler frameHandler); @Override void start(final ZigBeePort port); @Override void setClosing(); @Override void close(); @Override boolean isAlive(); @Override void queueFrame(EzspFrameRequest request); @Override synchronized void connect(); synchronized void reconnect(); @Override Future<EzspFrame> sendEzspRequestAsync(final EzspTransaction ezspTransaction); @Override EzspTransaction sendEzspTransaction(EzspTransaction ezspTransaction); @Override Future<EzspFrameResponse> eventWaitAsync(final Class<?> eventClass); @Override EzspFrameResponse eventWait(final Class<?> eventClass, int timeout); @Override synchronized Map<String, Long> getCounters(); }
AshFrameHandler implements EzspProtocolHandler { private synchronized void handleReset(AshFrameRstAck rstAck) { if (stateConnected) { logger.debug("ASH: RESET received while connected. Disconnecting."); disconnect(); return; } if (rstAck.getResetType() != AshErrorCode.RESET_SOFTWARE) { return; } if (rstAck.getVersion() == 2) { startConnectTimer(); } else { logger.debug("ASH: Invalid version"); } } AshFrameHandler(final EzspFrameHandler frameHandler); @Override void start(final ZigBeePort port); @Override void setClosing(); @Override void close(); @Override boolean isAlive(); @Override void queueFrame(EzspFrameRequest request); @Override synchronized void connect(); synchronized void reconnect(); @Override Future<EzspFrame> sendEzspRequestAsync(final EzspTransaction ezspTransaction); @Override EzspTransaction sendEzspTransaction(EzspTransaction ezspTransaction); @Override Future<EzspFrameResponse> eventWaitAsync(final Class<?> eventClass); @Override EzspFrameResponse eventWait(final Class<?> eventClass, int timeout); @Override synchronized Map<String, Long> getCounters();  }