Skip to content

Commit

Permalink
Added setRetries()
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Jun 28, 2011
1 parent 1c6cc96 commit a22906f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
7 changes: 7 additions & 0 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,5 +631,12 @@ void RF24::setCRCLength(rf24_crclength_e length)
write_register(CONFIG,config);
}

/******************************************************************/

void RF24::setRetries(uint8_t delay, uint8_t count)
{
write_register(SETUP_RETR,(delay&0xf)<<ARD | (count&0xf)<<ARC);
}

// vim:ai:cin:sts=2 sw=2 ft=cpp

9 changes: 9 additions & 0 deletions RF24.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,15 @@ class RF24
*/
/**@{*/

/**
* Set the number and delay of retries upon failed submit
*
* @param delay How long to wait between each retry, in multiples of 250us,
* max is 15. 0 means 250us, 15 means 4000us.
* @param count How many retries before giving up, max 15
*/
void setRetries(uint8_t delay, uint8_t count);

/**
* Set RF communication channel
*
Expand Down
8 changes: 7 additions & 1 deletion examples/pingpair/pingpair.pde
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ void setup(void)

radio.begin();

// optionally, increase the delay between retries & # of retries
radio.setRetries(15,15);

// optionally, use a high channel to avoid WiFi chatter
radio.setChannel(110);

//
// Open pipes to other nodes for communication
//
Expand Down Expand Up @@ -201,4 +207,4 @@ void loop(void)
}
}
}
// vim:ci sts=2 sw=2 ft=cpp
// vim:cin:ai:sts=2 sw=2 ft=cpp

0 comments on commit a22906f

Please sign in to comment.