diff --git a/RF24.cpp b/RF24.cpp index 9471583d..63be3ebc 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -587,7 +587,7 @@ bool RF24::read( void* buf, uint8_t len ) /****************************************************************************/ -void RF24::whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready) +uint8_t RF24::whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready) { // Read the status & reset the status in one easy call // Or is that such a good idea? @@ -597,6 +597,10 @@ void RF24::whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready) tx_ok = status & _BV(TX_DS); tx_fail = status & _BV(MAX_RT); rx_ready = status & _BV(RX_DR); + + // Return pipe number. However, it is only useful and valid when + // something is received (rx_ready == true) + return ( status >> RX_P_NO ) & B111; } /****************************************************************************/ diff --git a/RF24.h b/RF24.h index 141bdab5..4be69aad 100644 --- a/RF24.h +++ b/RF24.h @@ -612,8 +612,10 @@ class RF24 * @param[out] tx_ok The send was successful (TX_DS) * @param[out] tx_fail The send failed, too many retries (MAX_RT) * @param[out] rx_ready There is a message waiting to be read (RX_DS) + * + * @return Pipe number for which data is ready. Only valid if rx_ready == true */ - void whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready); + uint8_t whatHappened(bool& tx_ok,bool& tx_fail,bool& rx_ready); /** * Test whether there was a carrier on the line for the