@@ -1697,11 +1697,19 @@ uint8_t XBeeWithCallbacks::matchStatus(uint8_t frameId) {
16971697 return 0xff ;
16981698}
16991699
1700- bool XBeeWithCallbacks::waitForInternal (uint8_t apiId, void *response, uint16_t timeout, void *func, uintptr_t data) {
1700+ uint8_t XBeeWithCallbacks::waitForInternal (uint8_t apiId, void *response, uint16_t timeout, void *func, uintptr_t data, int16_t frameId ) {
17011701 unsigned long start = millis ();
17021702 do {
17031703 // Wait for a packet of the right type
17041704 if (loopTop ()) {
1705+ if (frameId >= 0 ) {
1706+ uint8_t status = matchStatus (frameId);
1707+ // If a status was found, but it was not
1708+ // a zero success status, stop waiting
1709+ if (status != 0xff && status != 0 )
1710+ return status;
1711+ }
1712+
17051713 if (getResponse ().getApiId () == apiId) {
17061714 // If the type is right, call the right
17071715 // conversion function based on the
@@ -1720,95 +1728,95 @@ bool XBeeWithCallbacks::waitForInternal(uint8_t apiId, void *response, uint16_t
17201728 bool (*f)(ZBTxStatusResponse&,uintptr_t ) = (bool (*)(ZBTxStatusResponse&,uintptr_t ))func;
17211729 getResponse ().getZBTxStatusResponse (*r);
17221730 if (!f || f (*r, data))
1723- return true ;
1731+ return 0 ;
17241732 break ;
17251733 }
17261734 case ZBRxResponse::API_ID: {
17271735 ZBRxResponse *r = (ZBRxResponse*)response;
17281736 bool (*f)(ZBRxResponse&,uintptr_t ) = (bool (*)(ZBRxResponse&,uintptr_t ))func;
17291737 getResponse ().getZBRxResponse (*r);
17301738 if (!f || f (*r, data))
1731- return true ;
1739+ return 0 ;
17321740 break ;
17331741 }
17341742 case ZBExplicitRxResponse::API_ID: {
17351743 ZBExplicitRxResponse *r = (ZBExplicitRxResponse*)response;
17361744 bool (*f)(ZBExplicitRxResponse&,uintptr_t ) = (bool (*)(ZBExplicitRxResponse&,uintptr_t ))func;
17371745 getResponse ().getZBExplicitRxResponse (*r);
17381746 if (!f || f (*r, data))
1739- return true ;
1747+ return 0 ;
17401748 break ;
17411749 }
17421750 case ZBRxIoSampleResponse::API_ID: {
17431751 ZBRxIoSampleResponse *r = (ZBRxIoSampleResponse*)response;
17441752 bool (*f)(ZBRxIoSampleResponse&,uintptr_t ) = (bool (*)(ZBRxIoSampleResponse&,uintptr_t ))func;
17451753 getResponse ().getZBRxIoSampleResponse (*r);
17461754 if (!f || f (*r, data))
1747- return true ;
1755+ return 0 ;
17481756 break ;
17491757 }
17501758 case TxStatusResponse::API_ID: {
17511759 TxStatusResponse *r = (TxStatusResponse*)response;
17521760 bool (*f)(TxStatusResponse&,uintptr_t ) = (bool (*)(TxStatusResponse&,uintptr_t ))func;
17531761 getResponse ().getTxStatusResponse (*r);
17541762 if (!f || f (*r, data))
1755- return true ;
1763+ return 0 ;
17561764 break ;
17571765 }
17581766 case Rx16Response::API_ID: {
17591767 Rx16Response *r = (Rx16Response*)response;
17601768 bool (*f)(Rx16Response&,uintptr_t ) = (bool (*)(Rx16Response&,uintptr_t ))func;
17611769 getResponse ().getRx16Response (*r);
17621770 if (!f || f (*r, data))
1763- return true ;
1771+ return 0 ;
17641772 break ;
17651773 }
17661774 case Rx64Response::API_ID: {
17671775 Rx64Response *r = (Rx64Response*)response;
17681776 bool (*f)(Rx64Response&,uintptr_t ) = (bool (*)(Rx64Response&,uintptr_t ))func;
17691777 getResponse ().getRx64Response (*r);
17701778 if (!f || f (*r, data))
1771- return true ;
1779+ return 0 ;
17721780 break ;
17731781 }
17741782 case Rx16IoSampleResponse::API_ID: {
17751783 Rx16IoSampleResponse *r = (Rx16IoSampleResponse*)response;
17761784 bool (*f)(Rx16IoSampleResponse&,uintptr_t ) = (bool (*)(Rx16IoSampleResponse&,uintptr_t ))func;
17771785 getResponse ().getRx16IoSampleResponse (*r);
17781786 if (!f || f (*r, data))
1779- return true ;
1787+ return 0 ;
17801788 break ;
17811789 }
17821790 case Rx64IoSampleResponse::API_ID: {
17831791 Rx64IoSampleResponse *r = (Rx64IoSampleResponse*)response;
17841792 bool (*f)(Rx64IoSampleResponse&,uintptr_t ) = (bool (*)(Rx64IoSampleResponse&,uintptr_t ))func;
17851793 getResponse ().getRx64IoSampleResponse (*r);
17861794 if (!f || f (*r, data))
1787- return true ;
1795+ return 0 ;
17881796 break ;
17891797 }
17901798 case ModemStatusResponse::API_ID: {
17911799 ModemStatusResponse *r = (ModemStatusResponse*)response;
17921800 bool (*f)(ModemStatusResponse&,uintptr_t ) = (bool (*)(ModemStatusResponse&,uintptr_t ))func;
17931801 getResponse ().getModemStatusResponse (*r);
17941802 if (!f || f (*r, data))
1795- return true ;
1803+ return 0 ;
17961804 break ;
17971805 }
17981806 case AtCommandResponse::API_ID: {
17991807 AtCommandResponse *r = (AtCommandResponse*)response;
18001808 bool (*f)(AtCommandResponse&,uintptr_t ) = (bool (*)(AtCommandResponse&,uintptr_t ))func;
18011809 getResponse ().getAtCommandResponse (*r);
18021810 if (!f || f (*r, data))
1803- return true ;
1811+ return 0 ;
18041812 break ;
18051813 }
18061814 case RemoteAtCommandResponse::API_ID: {
18071815 RemoteAtCommandResponse *r = (RemoteAtCommandResponse*)response;
18081816 bool (*f)(RemoteAtCommandResponse&,uintptr_t ) = (bool (*)(RemoteAtCommandResponse&,uintptr_t ))func;
18091817 getResponse ().getRemoteAtCommandResponse (*r);
18101818 if (!f || f (*r, data))
1811- return true ;
1819+ return 0 ;
18121820 break ;
18131821 }
18141822 }
@@ -1817,7 +1825,7 @@ bool XBeeWithCallbacks::waitForInternal(uint8_t apiId, void *response, uint16_t
18171825 loopBottom ();
18181826 }
18191827 } while (millis () - start < timeout);
1820- return false ;
1828+ return XBEE_WAIT_TIMEOUT ;
18211829}
18221830
18231831uint8_t XBeeWithCallbacks::waitForStatus (uint8_t frameId, uint16_t timeout) {
0 commit comments