@Test public void testReceivePacketx() { System.out.println("--- " + Thread.currentThread().getStackTrace()[1].getMethodName()); int[] response = getPacket( new int[] { 0x44, 0x0E, 0xA1, 0x57, 0x54, 0x45, 0x15, 0x58, 0x94, 0x6C, 0x1B, 0x6E, 0x35, 0x27, 0xEA, 0x61, 0xE0, 0x60, 0x31, 0xFB, 0x04, 0xF3, 0xA7, 0x9D, 0x86, 0x86, 0xB0, 0x3E, 0x29, 0x7E }); assertNotNull(response); assertEquals(29, response.length); }
private int[] getPacket() throws IOException { int[] inputBuffer = new int[ASH_MAX_LENGTH]; int inputCount = 0; boolean inputError = false; while (!closeHandler) { int val = port.read(); logger.trace("ASH RX: {}", String.format("%02X", val)); switch (val) { case ASH_CANCEL_BYTE: inputCount = 0; inputError = false; break; case ASH_FLAG_BYTE: if (!inputError && inputCount != 0) { return Arrays.copyOfRange(inputBuffer, 0, inputCount); } inputCount = 0; inputError = false; break; case ASH_SUBSTITUTE_BYTE: inputError = true; break; case ASH_XON_BYTE: break; case ASH_OFF_BYTE: break; case ASH_TIMEOUT: break; default: if (inputCount >= ASH_MAX_LENGTH) { inputCount = 0; inputError = true; } inputBuffer[inputCount++] = val; break; } } return null; }
AshFrameHandler implements EzspProtocolHandler { private int[] getPacket() throws IOException { int[] inputBuffer = new int[ASH_MAX_LENGTH]; int inputCount = 0; boolean inputError = false; while (!closeHandler) { int val = port.read(); logger.trace("ASH RX: {}", String.format("%02X", val)); switch (val) { case ASH_CANCEL_BYTE: inputCount = 0; inputError = false; break; case ASH_FLAG_BYTE: if (!inputError && inputCount != 0) { return Arrays.copyOfRange(inputBuffer, 0, inputCount); } inputCount = 0; inputError = false; break; case ASH_SUBSTITUTE_BYTE: inputError = true; break; case ASH_XON_BYTE: break; case ASH_OFF_BYTE: break; case ASH_TIMEOUT: break; default: if (inputCount >= ASH_MAX_LENGTH) { inputCount = 0; inputError = true; } inputBuffer[inputCount++] = val; break; } } return null; } }
AshFrameHandler implements EzspProtocolHandler { private int[] getPacket() throws IOException { int[] inputBuffer = new int[ASH_MAX_LENGTH]; int inputCount = 0; boolean inputError = false; while (!closeHandler) { int val = port.read(); logger.trace("ASH RX: {}", String.format("%02X", val)); switch (val) { case ASH_CANCEL_BYTE: inputCount = 0; inputError = false; break; case ASH_FLAG_BYTE: if (!inputError && inputCount != 0) { return Arrays.copyOfRange(inputBuffer, 0, inputCount); } inputCount = 0; inputError = false; break; case ASH_SUBSTITUTE_BYTE: inputError = true; break; case ASH_XON_BYTE: break; case ASH_OFF_BYTE: break; case ASH_TIMEOUT: break; default: if (inputCount >= ASH_MAX_LENGTH) { inputCount = 0; inputError = true; } inputBuffer[inputCount++] = val; break; } } return null; } AshFrameHandler(final EzspFrameHandler frameHandler); }
AshFrameHandler implements EzspProtocolHandler { private int[] getPacket() throws IOException { int[] inputBuffer = new int[ASH_MAX_LENGTH]; int inputCount = 0; boolean inputError = false; while (!closeHandler) { int val = port.read(); logger.trace("ASH RX: {}", String.format("%02X", val)); switch (val) { case ASH_CANCEL_BYTE: inputCount = 0; inputError = false; break; case ASH_FLAG_BYTE: if (!inputError && inputCount != 0) { return Arrays.copyOfRange(inputBuffer, 0, inputCount); } inputCount = 0; inputError = false; break; case ASH_SUBSTITUTE_BYTE: inputError = true; break; case ASH_XON_BYTE: break; case ASH_OFF_BYTE: break; case ASH_TIMEOUT: break; default: if (inputCount >= ASH_MAX_LENGTH) { inputCount = 0; inputError = true; } inputBuffer[inputCount++] = val; break; } } return null; } 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 int[] getPacket() throws IOException { int[] inputBuffer = new int[ASH_MAX_LENGTH]; int inputCount = 0; boolean inputError = false; while (!closeHandler) { int val = port.read(); logger.trace("ASH RX: {}", String.format("%02X", val)); switch (val) { case ASH_CANCEL_BYTE: inputCount = 0; inputError = false; break; case ASH_FLAG_BYTE: if (!inputError && inputCount != 0) { return Arrays.copyOfRange(inputBuffer, 0, inputCount); } inputCount = 0; inputError = false; break; case ASH_SUBSTITUTE_BYTE: inputError = true; break; case ASH_XON_BYTE: break; case ASH_OFF_BYTE: break; case ASH_TIMEOUT: break; default: if (inputCount >= ASH_MAX_LENGTH) { inputCount = 0; inputError = true; } inputBuffer[inputCount++] = val; break; } } return null; } 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();  }