Skip to content

Commit f9d6957

Browse files
committed
revert exposing cached TX address
1 parent e0fe474 commit f9d6957

3 files changed

Lines changed: 11 additions & 44 deletions

File tree

RF24.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,17 +1185,17 @@ void RF24::stopListening(void)
11851185
powerUp();
11861186
}
11871187
#endif
1188-
write_register(RX_ADDR_P0, txAddress, addr_width);
1188+
write_register(RX_ADDR_P0, pipe0_writing_address, addr_width);
11891189
write_register(EN_RXADDR, static_cast<uint8_t>(read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[0])))); // Enable RX on pipe0
11901190
}
11911191

11921192
/****************************************************************************/
11931193

1194-
void RF24::stopListening(const uint8_t* tx_address)
1194+
void RF24::stopListening(const uint8_t* txAddress)
11951195
{
1196-
memcpy(txAddress, tx_address, addr_width);
1196+
memcpy(pipe0_writing_address, txAddress, addr_width);
11971197
stopListening();
1198-
write_register(TX_ADDR, txAddress, addr_width);
1198+
write_register(TX_ADDR, pipe0_writing_address, addr_width);
11991199
}
12001200

12011201
/****************************************************************************/
@@ -1603,7 +1603,7 @@ void RF24::openWritingPipe(uint64_t value)
16031603

16041604
write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&value), addr_width);
16051605
write_register(TX_ADDR, reinterpret_cast<uint8_t*>(&value), addr_width);
1606-
memcpy(txAddress, &value, addr_width);
1606+
memcpy(pipe0_writing_address, &value, addr_width);
16071607
}
16081608

16091609
/****************************************************************************/

RF24.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ class RF24
182182
uint8_t status; /* The status byte returned from every SPI transaction */
183183
uint8_t payload_size; /* Fixed size of payloads */
184184
uint8_t pipe0_reading_address[5]; /* Last address set on pipe 0 for reading. */
185+
uint8_t pipe0_writing_address[5]; /* Last address set on pipe 0 for writing. */
185186
uint8_t config_reg; /* For storing the value of the NRF_CONFIG register */
186187
bool _is_p_variant; /* For storing the result of testing the toggleFeatures() affect */
187188
bool _is_p0_rx; /* For keeping track of pipe 0's usage in user-triggered RX mode. */
@@ -366,24 +367,6 @@ class RF24
366367
*/
367368
void startListening(void);
368369

369-
/**
370-
* The TX address to use on pipe 0 for writing.
371-
*
372-
* This is cached in the library to ensure proper auto-ack behavior on pipe 0,
373-
* if pipe 0 is also used with a different RX address for receiving.
374-
*
375-
* Use this instead of calling openWritingPipe()
376-
*
377-
* ```cpp
378-
* uint8_t rxNodeAddress[6] = "1Node";
379-
* memcpy(radio.txAddress, rxNodeAddress, 5);
380-
* radio.stopListening();
381-
* ```
382-
*
383-
* Previously, openWritingPipe() should be called after stopListening().
384-
*/
385-
uint8_t txAddress[5];
386-
387370
/**
388371
* Stop listening for incoming messages, and switch to transmit mode.
389372
*
@@ -401,9 +384,10 @@ class RF24
401384

402385
/**
403386
* @brief Similar to startListening(void) but changes the TX address.
404-
* @param tx_address The new TX address. This value will be cached to `txAddress` member.
387+
* @param txAddress The new TX address.
388+
* This value will be cached for auto-ack purposes.
405389
*/
406-
void stopListening(const uint8_t* tx_address);
390+
void stopListening(const uint8_t* txAddress);
407391

408392
/**
409393
* Check whether there are bytes available to be read
@@ -542,7 +526,7 @@ class RF24
542526
* New: Open a pipe for writing via byte array. Old addressing format retained
543527
* for compatibility.
544528
*
545-
* @deprecated Use `RF24::txAddress` or `RF24::stopListening(uint8_t*)` instead.
529+
* @deprecated Use `RF24::stopListening(uint8_t*)` instead.
546530
*
547531
* Only one writing pipe can be opened at once, but this function changes
548532
* the address that is used to transmit (ACK payloads/packets do not apply

pyRF24/pyRF24.cpp

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,6 @@ int get_bytes_or_bytearray_ln(bp::object buf)
3939
return 0;
4040
}
4141

42-
void set_tx_address(RF24& ref, bp::object buf)
43-
{
44-
// set the TX address of the RX node for use on the TX pipe (pipe 0)
45-
memcpy(ref.txAddress, get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf));
46-
}
47-
48-
bp::object get_tx_address(RF24& ref)
49-
{
50-
char* buf = new char[6];
51-
memcpy(buf, ref.txAddress, 5);
52-
bp::object py_ba(bp::handle<>(PyByteArray_FromStringAndSize(buf, 5)));
53-
delete[] buf;
54-
return py_ba;
55-
}
56-
5742
bp::object read_wrap(RF24& ref, int maxlen)
5843
{
5944
char* buf = new char[maxlen + 1];
@@ -348,8 +333,6 @@ BOOST_PYTHON_MODULE(RF24)
348333
.def("openReadingPipe", (void(::RF24::*)(::uint8_t, ::uint64_t))(&::RF24::openReadingPipe), (bp::arg("number"), bp::arg("address")))
349334
.def("openWritingPipe", &openWritingPipe_wrap, (bp::arg("address")))
350335
.def("openWritingPipe", (void(::RF24::*)(::uint64_t))(&::RF24::openWritingPipe), (bp::arg("address")))
351-
.add_property("txAddress", &get_tx_address, &set_tx_address)
352-
.add_property("tx_address", &get_tx_address, &set_tx_address)
353336
.def("powerDown", &RF24::powerDown)
354337
.def("powerUp", &RF24::powerUp)
355338
.def("printDetails", &RF24::printDetails)
@@ -374,7 +357,7 @@ BOOST_PYTHON_MODULE(RF24)
374357
.def("startListening", &RF24::startListening)
375358
.def("startWrite", &startWrite_wrap, (bp::arg("buf"), bp::arg("len"), bp::arg("multicast")))
376359
.def("stopListening", (void(::RF24::*)(void))(&RF24::stopListening))
377-
.def("stopListening", &stopListening_wrap, (bp::arg("tx_address")))
360+
.def("stopListening", &stopListening_wrap, (bp::arg("txAddress")))
378361
.def("testCarrier", &RF24::testCarrier)
379362
.def("testRPD", &RF24::testRPD)
380363
.def("toggleAllPipes", &RF24::toggleAllPipes)

0 commit comments

Comments
 (0)