Skip to content

Commit 79ea02d

Browse files
committed
add to migration guide
1 parent f9d6957 commit 79ea02d

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

docs/migration.md

+64
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ There are overloaded functions that use a buffer instead:
4646
These eliminate the unnecessary 24 bits by only using the length of the buffer (`uint8_t*`)
4747
specified by `RF24::setAddressWidth()`.
4848

49+
@see The `RF24::openWritingPipe(const uint8_t*)` is now deprecated in favor of the
50+
overloaded `RF24::stopListening(uint8_t*)` function.
51+
See the section below for more detail.
52+
4953
> [!CAUTION]
5054
> The endianness (byte order) of a buffer is reversed compared to a 64-bit integer.
5155
> ```c
@@ -211,3 +215,63 @@ radio.clearStatusFlags(RF24_RX_DR);
211215
```
212216
213217
</td></tr></table>
218+
219+
## openWritingPipe(const uint8_t*)
220+
221+
> Deprecated since v1.5
222+
223+
Originally, `RF24::openWritingPipe(const uint8_t*)` was just a compliment to
224+
`RF24::openReadingPipe()`.
225+
It changes the address on pipe 0 because that is the only pipe that can be
226+
used for transmitting.
227+
228+
Unfortunately, there was a bug that prevented the given TX address from being
229+
persistent on pipe 0 if the user code also set an RX address to pipe 0.
230+
This bug would surface when switching between RX mode and TX mode (via
231+
`RF24::startListening()` and `RF24::stopListening()` respectively) or after
232+
`RF24::stopConstCarrier()`.
233+
As a result the TX address has to be cached on the `RF24` instance.
234+
Consequently, this solution does not fit well with the traditional order of
235+
setting up the radio.
236+
237+
By overloading `RF24::stopListening(const uint8_t*)`, we are able to ensure proper radio
238+
setup without requiring certain functions are called in a certain order.
239+
240+
- Use `RF24::stopListening(const uint8_t*)` to set the TX address and enter inactive TX mode.
241+
`RF24::openReadingPipe()` can now (as of v1.5) be used in TX mode without consequence.
242+
- Use `RF24::stopListening()` to enter inactive TX mode without changing the TX address.
243+
244+
> [!warning]
245+
> Avoid using pipe 0 for RX operations to improve performance and reliability.
246+
>
247+
> For implementation detail, see the source for `RF24::openReadingPipe()` and
248+
> `RF24::stopListening()`. Ultimately, the datasheet's Appendix A has a detailed
249+
> example outlining the order of a proper radio setup.
250+
251+
<table><tr>
252+
<th>Old</th>
253+
<th>New (supported)</th>
254+
</tr><tr><td>
255+
256+
```cpp
257+
// set TX address (pipe 0)
258+
radio.openWritingPipe(tx_address);
259+
260+
// set RX address (pipe 1)
261+
radio.openReadingPipe(1, rx_address);
262+
263+
// idle radio using inactive TX mode
264+
radio.stopListening();
265+
```
266+
267+
</td><td>
268+
269+
```cpp
270+
// set TX address (pipe 0)
271+
radio.stopListening(tx_address); // enters inactive TX mode
272+
273+
// set RX address (pipe 1)
274+
radio.openReadingPipe(1, rx_address);
275+
```
276+
277+
</td></tr></table>

0 commit comments

Comments
 (0)