Skip to content

Return pipe number after executing whatHappened() #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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;
}

/****************************************************************************/
Expand Down
4 changes: 3 additions & 1 deletion RF24.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down