Now caches the reading pipe 0 and re-sets it when starting to listen.
This commit is contained in:
parent
e86c6b0f15
commit
1d28d28a29
9
RF24.cpp
9
RF24.cpp
|
@ -313,6 +313,9 @@ void RF24::startListening(void)
|
||||||
{
|
{
|
||||||
write_register(CONFIG, _BV(EN_CRC) | _BV(PWR_UP) | _BV(PRIM_RX));
|
write_register(CONFIG, _BV(EN_CRC) | _BV(PWR_UP) | _BV(PRIM_RX));
|
||||||
write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT) );
|
||||||
|
|
||||||
|
// Restore the pipe0 adddress
|
||||||
|
write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&pipe0_reading_address), 5);
|
||||||
|
|
||||||
// Flush buffers
|
// Flush buffers
|
||||||
flush_rx();
|
flush_rx();
|
||||||
|
@ -495,6 +498,12 @@ void RF24::openReadingPipe(uint8_t child, uint64_t value)
|
||||||
const uint8_t child_pipe_enable[] = {
|
const uint8_t child_pipe_enable[] = {
|
||||||
ERX_P0, ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 };
|
ERX_P0, ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 };
|
||||||
|
|
||||||
|
// If this is pipe 0, cache the address. This is needed because
|
||||||
|
// openWritingPipe() will overwrite the pipe 0 address, so
|
||||||
|
// startListening() will have to restore it.
|
||||||
|
if (child == 0)
|
||||||
|
pipe0_reading_address = value;
|
||||||
|
|
||||||
if (child < 5)
|
if (child < 5)
|
||||||
{
|
{
|
||||||
// For pipes 2-5, only write the LSB
|
// For pipes 2-5, only write the LSB
|
||||||
|
|
1
RF24.h
1
RF24.h
|
@ -23,6 +23,7 @@ private:
|
||||||
uint8_t payload_size; /**< Fixed size of payloads */
|
uint8_t payload_size; /**< Fixed size of payloads */
|
||||||
boolean ack_payload_available; /**< Whether there is an ack payload waiting */
|
boolean ack_payload_available; /**< Whether there is an ack payload waiting */
|
||||||
uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */
|
uint8_t ack_payload_length; /**< Dynamic size of pending ack payload. Note: not used. */
|
||||||
|
uint64_t pipe0_reading_address; /**< Last address set on pipe 0 for reading. */
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue