Skip to content

Commit f9fa18b

Browse files
committed
update examples
1 parent bf98165 commit f9fa18b

21 files changed

+33
-42
lines changed

examples/AcknowledgementPayloads/AcknowledgementPayloads.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ void setup() {
8484
// this feature for all nodes (TX & RX) to use ACK payloads.
8585
radio.enableAckPayload();
8686

87-
// set the RX address of the TX node into a RX pipe
88-
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
89-
9087
// set the TX address of the RX node for use on the TX pipe (pipe 0)
9188
radio.stopListening(address[radioNumber]); // put radio in TX mode
9289

90+
// set the RX address of the TX node into a RX pipe
91+
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
92+
9393
// additional setup specific to the node's role
9494
if (role) {
9595
// setup the TX payload

examples/GettingStarted/GettingStarted.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ void setup() {
7474
// number of bytes we need to transmit a float
7575
radio.setPayloadSize(sizeof(payload)); // float datatype occupies 4 bytes
7676

77-
// set the RX address of the TX node into a RX pipe
78-
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
79-
8077
// set the TX address of the RX node for use on the TX pipe (pipe 0)
8178
radio.stopListening(address[radioNumber]); // put radio in TX mode
8279

80+
// set the RX address of the TX node into a RX pipe
81+
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
82+
8383
// additional setup specific to the node's RX role
8484
if (!role) {
8585
radio.startListening(); // put radio in RX mode

examples/InterruptConfigure/InterruptConfigure.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ void setup() {
103103
// this feature for all nodes (TX & RX) to use ACK payloads.
104104
radio.enableAckPayload();
105105

106-
// set the RX address of the TX node into a RX pipe
107-
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
108-
109106
// set the TX address of the RX node for use on the TX pipe (pipe 0)
110107
radio.stopListening(address[radioNumber]); // put radio in TX mode
111108

109+
// set the RX address of the TX node into a RX pipe
110+
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
111+
112112
// additional setup specific to the node's RX role
113113
if (!role) {
114114
// setup for RX mode

examples/ManualAcknowledgements/ManualAcknowledgements.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ void setup() {
8888
// number of bytes we need to transmit a float
8989
radio.setPayloadSize(sizeof(payload)); // char[7] & uint8_t datatypes occupy 8 bytes
9090

91-
// set the RX address of the TX node into a RX pipe
92-
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
93-
9491
// set the TX address of the RX node for use on the TX pipe (pipe 0)
9592
radio.stopListening(address[radioNumber]); // put radio in TX mode
9693

94+
// set the RX address of the TX node into a RX pipe
95+
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
96+
9797
if (role) {
9898
// setup the TX node
9999

examples/StreamingData/StreamingData.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ void setup() {
8080
// number of bytes we need to transmit
8181
radio.setPayloadSize(SIZE); // default value is the maximum 32 bytes
8282

83-
// set the RX address of the TX node into a RX pipe
84-
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
85-
8683
// set the TX address of the RX node for use on the TX pipe (pipe 0)
8784
radio.stopListening(address[radioNumber]); // put radio in TX mode
8885

86+
// set the RX address of the TX node into a RX pipe
87+
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
88+
8989
// additional setup specific to the node's RX role
9090
if (!role) {
9191
radio.startListening(); // put radio in RX mode

examples_linux/acknowledgementPayloads.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int main(int argc, char** argv)
9797
radio.setPALevel(RF24_PA_LOW); // RF24_PA_MAX is default.
9898

9999
// set the TX address of the RX node for use on the TX pipe (pipe 0)
100-
memcpy(radio.txAddress, address[radioNumber], 5);
100+
radio.stopListening(address[radioNumber]);
101101

102102
// set the RX address of the TX node into a RX pipe
103103
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_linux/acknowledgement_payloads.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
radio.setPALevel(RF24_PA_LOW) # RF24_PA_MAX is default
5353

5454
# set the TX address of the RX node for use on the TX pipe (pipe 0)
55-
radio.txAddress = address[radio_number]
55+
radio.stopListening(address[radio_number])
5656

5757
# set the RX address of the TX node into a RX pipe
5858
radio.openReadingPipe(1, address[not radio_number]) # using pipe 1

examples_linux/getting_started.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
radio.setPALevel(RF24_PA_LOW) # RF24_PA_MAX is default
5050

5151
# set the TX address of the RX node for use on the TX pipe (pipe 0)
52-
radio.txAddress = address[radio_number]
52+
radio.stopListening(address[radio_number])
5353

5454
# set the RX address of the TX node into a RX pipe
5555
radio.openReadingPipe(1, address[not radio_number]) # using pipe 1

examples_linux/gettingstarted.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ int main(int argc, char** argv)
8888
radio.setPALevel(RF24_PA_LOW); // RF24_PA_MAX is default.
8989

9090
// set the TX address of the RX node for use on the TX pipe (pipe 0)
91-
memcpy(radio.txAddress, address[radioNumber], 5);
91+
radio.stopListening(address[radioNumber]);
9292

9393
// set the RX address of the TX node into a RX pipe
9494
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_linux/interruptConfigure.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int main(int argc, char** argv)
110110
radio.setPALevel(RF24_PA_LOW); // RF24_PA_MAX is default.
111111

112112
// set the TX address of the RX node for use on the TX pipe (pipe 0)
113-
memcpy(radio.txAddress, address[radioNumber], 5);
113+
radio.stopListening(address[radioNumber]);
114114

115115
// set the RX address of the TX node into a RX pipe
116116
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_linux/interrupt_configure.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
radio.setPALevel(RF24_PA_LOW) # RF24_PA_MAX is default
7676

7777
# set the TX address of the RX node for use on the TX pipe (pipe 0)
78-
radio.txAddress = address[radio_number]
78+
radio.stopListening(address[radio_number])
7979

8080
# set the RX address of the TX node into a RX pipe
8181
radio.openReadingPipe(1, address[not radio_number]) # using pipe 1

examples_linux/manualAcknowledgements.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ int main(int argc, char** argv)
104104
radio.setPayloadSize(sizeof(payload)); // char[7] & uint8_t datatypes occupy 8 bytes
105105

106106
// set the TX address of the RX node for use on the TX pipe (pipe 0)
107-
memcpy(radio.txAddress, address[radioNumber], 5);
107+
radio.stopListening(address[radioNumber]);
108108

109109
// set the RX address of the TX node into a RX pipe
110110
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_linux/manual_acknowledgements.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
radio.setPALevel(RF24_PA_LOW) # RF24_PA_MAX is default
5656

5757
# set the TX address of the RX node for use on the TX pipe (pipe 0)
58-
radio.txAddress = address[radio_number]
58+
radio.stopListening(address[radio_number])
5959

6060
# set the RX address of the TX node into a RX pipe
6161
radio.openReadingPipe(1, address[not radio_number]) # using pipe 1

examples_linux/streamingData.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ int main(int argc, char** argv)
150150
radio.setPALevel(RF24_PA_LOW); // RF24_PA_MAX is default.
151151

152152
// set the TX address of the RX node for use on the TX pipe (pipe 0)
153-
memcpy(radio.txAddress, address[radioNumber], 5);
153+
radio.stopListening(address[radioNumber]);
154154

155155
// set the RX address of the TX node into a RX pipe
156156
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_linux/streaming_data.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
radio.setPALevel(RF24_PA_LOW) # RF24_PA_MAX is default
4949

5050
# set the TX address of the RX node for use on the TX pipe (pipe 0)
51-
radio.txAddress = address[radio_number]
51+
radio.stopListening(address[radio_number])
5252

5353
# set the RX address of the TX node into a RX pipe
5454
radio.openReadingPipe(1, address[not radio_number]) # using pipe 1

examples_pico/acknowledgementPayloads.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bool setup()
7979
radio.enableAckPayload();
8080

8181
// set the TX address of the RX node for use on the TX pipe (pipe 0)
82-
memcpy(radio.txAddress, address[radioNumber], 5);
82+
radio.stopListening(address[radioNumber]);
8383

8484
// set the RX address of the TX node into a RX pipe
8585
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_pico/gettingStarted.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ bool setup()
6868
radio.setPayloadSize(sizeof(payload)); // float datatype occupies 4 bytes
6969

7070
// set the TX address of the RX node for use on the TX pipe (pipe 0)
71-
memcpy(radio.txAddress, address[radioNumber], 5);
71+
radio.stopListening(address[radioNumber]);
7272

7373
// set the RX address of the TX node into a RX pipe
7474
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1

examples_pico/interruptConfigure.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,13 @@ bool setup()
9797
// Fot this example, we use the same address to send data back and forth
9898

9999
// set the TX address of the RX node for use on the TX pipe (pipe 0)
100-
memcpy(radio.txAddress, address[radioNumber], 5);
100+
radio.stopListening(address[radioNumber]);
101101

102102
// set the RX address of the TX node into a RX pipe
103103
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
104104

105105
// additional setup specific to the node's role
106-
if (role) {
107-
// setup for TX mode
108-
radio.stopListening(); // put radio in TX mode
109-
}
110-
else {
106+
if (!role) {
111107
// setup for RX mode
112108

113109
// let IRQ pin not trigger in RX mode

examples_pico/manualAcknowledgements.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool setup()
8383
radio.setPayloadSize(sizeof(payload)); // char[7] & uint8_t datatypes occupy 8 bytes
8484

8585
// set the TX address of the RX node for use on the TX pipe (pipe 0)
86-
memcpy(radio.txAddress, address[radioNumber], 5);
86+
radio.stopListening(address[radioNumber]);
8787

8888
// set the RX address of the TX node into a RX pipe
8989
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
@@ -92,7 +92,6 @@ bool setup()
9292
// setup the TX node
9393

9494
memcpy(payload.message, "Hello ", 6); // set the outgoing message
95-
radio.stopListening(); // put radio in TX mode
9695
}
9796
else {
9897
// setup the RX node

examples_pico/multiceiverDemo.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ void setRole()
191191
payload.payloadID = 0;
192192

193193
// set the TX address of the RX node for use on the TX pipe (pipe 0)
194-
memcpy(radio.txAddress, address[role], 5);
195-
radio.stopListening(); // put radio in TX mode
194+
radio.stopListening(address[role]); // put radio in TX mode
196195

197196
// According to the datasheet, the auto-retry features's delay value should
198197
// be "skewed" to allow the RX node to receive 1 transmission at a time.

examples_pico/streamingData.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,13 @@ bool setup()
7474
radio.setPayloadSize(SIZE); // default value is the maximum 32 bytes
7575

7676
// set the TX address of the RX node for use on the TX pipe (pipe 0)
77-
memcpy(radio.txAddress, address[radioNumber], 5);
77+
radio.stopListening(address[radioNumber]);
7878

7979
// set the RX address of the TX node into a RX pipe
8080
radio.openReadingPipe(1, address[!radioNumber]); // using pipe 1
8181

8282
// additional setup specific to the node's role
83-
if (role) {
84-
radio.stopListening(); // put radio in TX mode
85-
}
86-
else {
83+
if (!role) {
8784
radio.startListening(); // put radio in RX mode
8885
}
8986

0 commit comments

Comments
 (0)