Skip to content

Commit feb8fd1

Browse files
committed
revert exposing cached TX address
1 parent 47c25f5 commit feb8fd1

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
@@ -1187,17 +1187,17 @@ void RF24::stopListening(void)
11871187
powerUp();
11881188
}
11891189
#endif
1190-
write_register(RX_ADDR_P0, txAddress, addr_width);
1190+
write_register(RX_ADDR_P0, pipe0_writing_address, addr_width);
11911191
write_register(EN_RXADDR, static_cast<uint8_t>(read_register(EN_RXADDR) | _BV(pgm_read_byte(&child_pipe_enable[0])))); // Enable RX on pipe0
11921192
}
11931193

11941194
/****************************************************************************/
11951195

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

12031203
/****************************************************************************/
@@ -1574,7 +1574,7 @@ void RF24::openWritingPipe(uint64_t value)
15741574

15751575
write_register(RX_ADDR_P0, reinterpret_cast<uint8_t*>(&value), addr_width);
15761576
write_register(TX_ADDR, reinterpret_cast<uint8_t*>(&value), addr_width);
1577-
memcpy(txAddress, &value, addr_width);
1577+
memcpy(pipe0_writing_address, &value, addr_width);
15781578
}
15791579

15801580
/****************************************************************************/

RF24.h

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class RF24
158158
uint8_t status; /* The status byte returned from every SPI transaction */
159159
uint8_t payload_size; /* Fixed size of payloads */
160160
uint8_t pipe0_reading_address[5]; /* Last address set on pipe 0 for reading. */
161+
uint8_t pipe0_writing_address[5]; /* Last address set on pipe 0 for writing. */
161162
uint8_t config_reg; /* For storing the value of the NRF_CONFIG register */
162163
bool _is_p_variant; /* For storing the result of testing the toggleFeatures() affect */
163164
bool _is_p0_rx; /* For keeping track of pipe 0's usage in user-triggered RX mode. */
@@ -342,24 +343,6 @@ class RF24
342343
*/
343344
void startListening(void);
344345

345-
/**
346-
* The TX address to use on pipe 0 for writing.
347-
*
348-
* This is cached in the library to ensure proper auto-ack behavior on pipe 0,
349-
* if pipe 0 is also used with a different RX address for receiving.
350-
*
351-
* Use this instead of calling openWritingPipe()
352-
*
353-
* ```cpp
354-
* uint8_t rxNodeAddress[6] = "1Node";
355-
* memcpy(radio.txAddress, rxNodeAddress, 5);
356-
* radio.stopListening();
357-
* ```
358-
*
359-
* Previously, openWritingPipe() should be called after stopListening().
360-
*/
361-
uint8_t txAddress[5];
362-
363346
/**
364347
* Stop listening for incoming messages, and switch to transmit mode.
365348
*
@@ -377,9 +360,10 @@ class RF24
377360

378361
/**
379362
* @brief Similar to startListening(void) but changes the TX address.
380-
* @param tx_address The new TX address. This value will be cached to `txAddress` member.
363+
* @param txAddress The new TX address.
364+
* This value will be cached for auto-ack purposes.
381365
*/
382-
void stopListening(const uint8_t* tx_address);
366+
void stopListening(const uint8_t* txAddress);
383367

384368
/**
385369
* Check whether there are bytes available to be read
@@ -518,7 +502,7 @@ class RF24
518502
* New: Open a pipe for writing via byte array. Old addressing format retained
519503
* for compatibility.
520504
*
521-
* @deprecated Use `RF24::txAddress` or `RF24::stopListening(uint8_t*)` instead.
505+
* @deprecated Use `RF24::stopListening(uint8_t*)` instead.
522506
*
523507
* Only one writing pipe can be opened at once, but this function changes
524508
* 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];
@@ -340,8 +325,6 @@ BOOST_PYTHON_MODULE(RF24)
340325
.def("openReadingPipe", (void(::RF24::*)(::uint8_t, ::uint64_t))(&::RF24::openReadingPipe), (bp::arg("number"), bp::arg("address")))
341326
.def("openWritingPipe", &openWritingPipe_wrap, (bp::arg("address")))
342327
.def("openWritingPipe", (void(::RF24::*)(::uint64_t))(&::RF24::openWritingPipe), (bp::arg("address")))
343-
.add_property("txAddress", &get_tx_address, &set_tx_address)
344-
.add_property("tx_address", &get_tx_address, &set_tx_address)
345328
.def("powerDown", &RF24::powerDown)
346329
.def("powerUp", &RF24::powerUp)
347330
.def("printDetails", &RF24::printDetails)
@@ -365,7 +348,7 @@ BOOST_PYTHON_MODULE(RF24)
365348
.def("startListening", &RF24::startListening)
366349
.def("startWrite", &startWrite_wrap, (bp::arg("buf"), bp::arg("len"), bp::arg("multicast")))
367350
.def("stopListening", (void(::RF24::*)(void))(&RF24::stopListening))
368-
.def("stopListening", &stopListening_wrap, (bp::arg("tx_address")))
351+
.def("stopListening", &stopListening_wrap, (bp::arg("txAddress")))
369352
.def("testCarrier", &RF24::testCarrier)
370353
.def("testRPD", &RF24::testRPD)
371354
.def("toggleAllPipes", &RF24::toggleAllPipes)

0 commit comments

Comments
 (0)