@Test public void testThatTxAckCompletesTransactionWhenNoApsAckRequired() { ZigBeeTransactionManager transactionManager = Mockito.mock(ZigBeeTransactionManager.class); ZigBeeCommand command = createCommand(false); ZigBeeTransactionMatcher matcher = Mockito.mock(ZigBeeTransactionMatcher.class); ZigBeeTransaction transaction = new ZigBeeTransaction(transactionManager, command, matcher); transaction.transactionStatusReceived(ZigBeeTransportProgressState.TX_ACK, 12); Mockito.verify(transactionManager, Mockito.times(1)).transactionComplete(transaction, TransactionState.COMPLETE); }
public void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId) { synchronized (command) { if (command.getTransactionId() != transactionId) { return; } switch (progress) { case TX_NAK: failTransaction(); break; case TX_ACK: if (responseMatcher == null || command.isAckRequest() == false) { completeTransaction(null); break; } state = TransactionState.TRANSMITTED; startTimer(timeout2); break; case RX_NAK: if (state == TransactionState.RESPONDED) { completeTransaction(completionCommand); } else { failTransaction(); } break; case RX_ACK: if (responseMatcher == null || state == TransactionState.RESPONDED || (command instanceof ZclCommand && ((ZclCommand) command).isDisableDefaultResponse())) { completeTransaction(completionCommand); } else { state = TransactionState.ACKED; } break; default: logger.debug("Unknown transaction state update: TID {} to {}", String.format("%02X", transactionId), progress); break; } } logger.debug("Transaction state changed: nwk={}, TID={}, event={}, state={}", String.format("%04X", command.getDestinationAddress().getAddress()), String.format("%02X", transactionId), progress, state); }
ZigBeeTransaction { public void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId) { synchronized (command) { if (command.getTransactionId() != transactionId) { return; } switch (progress) { case TX_NAK: failTransaction(); break; case TX_ACK: if (responseMatcher == null || command.isAckRequest() == false) { completeTransaction(null); break; } state = TransactionState.TRANSMITTED; startTimer(timeout2); break; case RX_NAK: if (state == TransactionState.RESPONDED) { completeTransaction(completionCommand); } else { failTransaction(); } break; case RX_ACK: if (responseMatcher == null || state == TransactionState.RESPONDED || (command instanceof ZclCommand && ((ZclCommand) command).isDisableDefaultResponse())) { completeTransaction(completionCommand); } else { state = TransactionState.ACKED; } break; default: logger.debug("Unknown transaction state update: TID {} to {}", String.format("%02X", transactionId), progress); break; } } logger.debug("Transaction state changed: nwk={}, TID={}, event={}, state={}", String.format("%04X", command.getDestinationAddress().getAddress()), String.format("%02X", transactionId), progress, state); } }
ZigBeeTransaction { public void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId) { synchronized (command) { if (command.getTransactionId() != transactionId) { return; } switch (progress) { case TX_NAK: failTransaction(); break; case TX_ACK: if (responseMatcher == null || command.isAckRequest() == false) { completeTransaction(null); break; } state = TransactionState.TRANSMITTED; startTimer(timeout2); break; case RX_NAK: if (state == TransactionState.RESPONDED) { completeTransaction(completionCommand); } else { failTransaction(); } break; case RX_ACK: if (responseMatcher == null || state == TransactionState.RESPONDED || (command instanceof ZclCommand && ((ZclCommand) command).isDisableDefaultResponse())) { completeTransaction(completionCommand); } else { state = TransactionState.ACKED; } break; default: logger.debug("Unknown transaction state update: TID {} to {}", String.format("%02X", transactionId), progress); break; } } logger.debug("Transaction state changed: nwk={}, TID={}, event={}, state={}", String.format("%04X", command.getDestinationAddress().getAddress()), String.format("%02X", transactionId), progress, state); } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); }
ZigBeeTransaction { public void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId) { synchronized (command) { if (command.getTransactionId() != transactionId) { return; } switch (progress) { case TX_NAK: failTransaction(); break; case TX_ACK: if (responseMatcher == null || command.isAckRequest() == false) { completeTransaction(null); break; } state = TransactionState.TRANSMITTED; startTimer(timeout2); break; case RX_NAK: if (state == TransactionState.RESPONDED) { completeTransaction(completionCommand); } else { failTransaction(); } break; case RX_ACK: if (responseMatcher == null || state == TransactionState.RESPONDED || (command instanceof ZclCommand && ((ZclCommand) command).isDisableDefaultResponse())) { completeTransaction(completionCommand); } else { state = TransactionState.ACKED; } break; default: logger.debug("Unknown transaction state update: TID {} to {}", String.format("%02X", transactionId), progress); break; } } logger.debug("Transaction state changed: nwk={}, TID={}, event={}, state={}", String.format("%04X", command.getDestinationAddress().getAddress()), String.format("%02X", transactionId), progress, state); } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); void setTransactionId(int transactionId); Integer getTransactionId(); int getTimerPeriod1(); void setTimerPeriod1(int timeout); int getTimerPeriod2(); void setTimerPeriod2(int timeout); IeeeAddress getIeeeAddress(); void setIeeeAddress(IeeeAddress ieeeAddress); void commandReceived(ZigBeeCommand receivedCommand); void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId); @Override String toString(); }
ZigBeeTransaction { public void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId) { synchronized (command) { if (command.getTransactionId() != transactionId) { return; } switch (progress) { case TX_NAK: failTransaction(); break; case TX_ACK: if (responseMatcher == null || command.isAckRequest() == false) { completeTransaction(null); break; } state = TransactionState.TRANSMITTED; startTimer(timeout2); break; case RX_NAK: if (state == TransactionState.RESPONDED) { completeTransaction(completionCommand); } else { failTransaction(); } break; case RX_ACK: if (responseMatcher == null || state == TransactionState.RESPONDED || (command instanceof ZclCommand && ((ZclCommand) command).isDisableDefaultResponse())) { completeTransaction(completionCommand); } else { state = TransactionState.ACKED; } break; default: logger.debug("Unknown transaction state update: TID {} to {}", String.format("%02X", transactionId), progress); break; } } logger.debug("Transaction state changed: nwk={}, TID={}, event={}, state={}", String.format("%04X", command.getDestinationAddress().getAddress()), String.format("%02X", transactionId), progress, state); } ZigBeeTransaction(ZigBeeTransactionManager transactionManager, final ZigBeeCommand command,
            final ZigBeeTransactionMatcher responseMatcher); void setTransactionId(int transactionId); Integer getTransactionId(); int getTimerPeriod1(); void setTimerPeriod1(int timeout); int getTimerPeriod2(); void setTimerPeriod2(int timeout); IeeeAddress getIeeeAddress(); void setIeeeAddress(IeeeAddress ieeeAddress); void commandReceived(ZigBeeCommand receivedCommand); void transactionStatusReceived(ZigBeeTransportProgressState progress, int transactionId); @Override String toString();  }