diff --git a/html/annotated.html b/html/annotated.html index 68efd90..9b414c1 100644 --- a/html/annotated.html +++ b/html/annotated.html @@ -107,7 +107,7 @@ diff --git a/html/classes.html b/html/classes.html index 3077747..5be3ab4 100644 --- a/html/classes.html +++ b/html/classes.html @@ -108,7 +108,7 @@ diff --git a/html/classnrf__to__nrf-members.html b/html/classnrf__to__nrf-members.html index 7b185cc..21bf61c 100644 --- a/html/classnrf__to__nrf-members.html +++ b/html/classnrf__to__nrf-members.html @@ -161,7 +161,7 @@ diff --git a/html/classnrf__to__nrf.html b/html/classnrf__to__nrf.html index 29da520..e60b20d 100644 --- a/html/classnrf__to__nrf.html +++ b/html/classnrf__to__nrf.html @@ -281,7 +281,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, examples/RF24/scanner/scanner.ino, examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino, examples/RF24Mesh/RF24Mesh_Example_MasterEncryption/RF24Mesh_Example_MasterEncryption.ino, examples/RF24Network/helloworld_rx/helloworld_rx.ino, examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino, examples/RF24Network/helloworld_tx/helloworld_tx.ino, and examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino.
-

Definition at line 80 of file nrf_to_nrf.cpp.

+

Definition at line 78 of file nrf_to_nrf.cpp.

@@ -303,7 +303,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 157 of file nrf_to_nrf.cpp.

+

Definition at line 155 of file nrf_to_nrf.cpp.

@@ -323,7 +323,7 @@

Same as NRF24 radio.available();

-

Definition at line 165 of file nrf_to_nrf.cpp.

+

Definition at line 163 of file nrf_to_nrf.cpp.

@@ -349,7 +349,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 328 of file nrf_to_nrf.cpp.

+

Definition at line 330 of file nrf_to_nrf.cpp.

@@ -385,7 +385,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 340 of file nrf_to_nrf.cpp.

+

Definition at line 342 of file nrf_to_nrf.cpp.

@@ -412,7 +412,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, and examples/RF24/scanner/scanner.ino.
-

Definition at line 678 of file nrf_to_nrf.cpp.

+

Definition at line 680 of file nrf_to_nrf.cpp.

@@ -444,7 +444,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, and examples/RF24/scanner/scanner.ino.
-

Definition at line 701 of file nrf_to_nrf.cpp.

+

Definition at line 703 of file nrf_to_nrf.cpp.

@@ -470,7 +470,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 908 of file nrf_to_nrf.cpp.

+

Definition at line 910 of file nrf_to_nrf.cpp.

@@ -492,7 +492,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 950 of file nrf_to_nrf.cpp.

+

Definition at line 952 of file nrf_to_nrf.cpp.

@@ -514,7 +514,7 @@

Examples
examples/RF24Mesh/RF24Mesh_Example/RF24Mesh_Example.ino, and examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino.
-

Definition at line 1026 of file nrf_to_nrf.cpp.

+

Definition at line 1028 of file nrf_to_nrf.cpp.

@@ -543,7 +543,7 @@

Not currently fully functional, calls the regular write();

-

Definition at line 1007 of file nrf_to_nrf.cpp.

+

Definition at line 1009 of file nrf_to_nrf.cpp.

@@ -579,7 +579,7 @@

txStandBy() to take the radio out of TX state or call startListening() to go into RX mode

-

Definition at line 528 of file nrf_to_nrf.cpp.

+

Definition at line 530 of file nrf_to_nrf.cpp.

@@ -610,7 +610,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino.
-

Definition at line 628 of file nrf_to_nrf.cpp.

+

Definition at line 630 of file nrf_to_nrf.cpp.

@@ -632,7 +632,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino.
-

Definition at line 670 of file nrf_to_nrf.cpp.

+

Definition at line 672 of file nrf_to_nrf.cpp.

@@ -652,7 +652,7 @@

Same as NRF24

-

Definition at line 674 of file nrf_to_nrf.cpp.

+

Definition at line 676 of file nrf_to_nrf.cpp.

@@ -692,7 +692,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino.
-

Definition at line 725 of file nrf_to_nrf.cpp.

+

Definition at line 727 of file nrf_to_nrf.cpp.

@@ -712,7 +712,7 @@

Same as NRF24

-

Definition at line 733 of file nrf_to_nrf.cpp.

+

Definition at line 735 of file nrf_to_nrf.cpp.

@@ -734,7 +734,7 @@

Examples
examples/RF24/scanner/scanner.ino, examples/RF24Network/helloworld_rx/helloworld_rx.ino, examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino, examples/RF24Network/helloworld_tx/helloworld_tx.ino, and examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino.
-

Definition at line 747 of file nrf_to_nrf.cpp.

+

Definition at line 749 of file nrf_to_nrf.cpp.

@@ -754,7 +754,7 @@

Same as NRF24

-

Definition at line 751 of file nrf_to_nrf.cpp.

+

Definition at line 753 of file nrf_to_nrf.cpp.

@@ -774,7 +774,7 @@

Supported speeds: NRF_1MBPS NRF_2MBPS

-

Definition at line 1030 of file nrf_to_nrf.cpp.

+

Definition at line 1032 of file nrf_to_nrf.cpp.

@@ -801,7 +801,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, examples/RF24Mesh/RF24Mesh_Example/RF24Mesh_Example.ino, and examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino.
-

Definition at line 1046 of file nrf_to_nrf.cpp.

+

Definition at line 1048 of file nrf_to_nrf.cpp.

@@ -821,7 +821,7 @@

Same as NRF24

-

Definition at line 1068 of file nrf_to_nrf.cpp.

+

Definition at line 1070 of file nrf_to_nrf.cpp.

@@ -843,7 +843,7 @@

Examples
examples/RF24/scanner/scanner.ino.
-

Definition at line 755 of file nrf_to_nrf.cpp.

+

Definition at line 757 of file nrf_to_nrf.cpp.

@@ -867,7 +867,7 @@

Note
If using static payloads, acks cannot be enabled & disabled on separate pipes, either ACKs are enabled or not
-

Definition at line 768 of file nrf_to_nrf.cpp.

+

Definition at line 770 of file nrf_to_nrf.cpp.

@@ -895,7 +895,7 @@

Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino, examples/RF24Mesh/RF24Mesh_Example_MasterEncryption/RF24Mesh_Example_MasterEncryption.ino, examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino, and examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino.
-

Definition at line 779 of file nrf_to_nrf.cpp.

+

Definition at line 781 of file nrf_to_nrf.cpp.

@@ -915,7 +915,7 @@

Same as NRF24

-

Definition at line 799 of file nrf_to_nrf.cpp.

+

Definition at line 801 of file nrf_to_nrf.cpp.

@@ -937,7 +937,7 @@

Examples
examples/RF24/GettingStarted/GettingStarted.ino, and examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 814 of file nrf_to_nrf.cpp.

+

Definition at line 816 of file nrf_to_nrf.cpp.

@@ -959,7 +959,7 @@

Examples
examples/RF24/GettingStarted/GettingStarted.ino.
-

Definition at line 830 of file nrf_to_nrf.cpp.

+

Definition at line 832 of file nrf_to_nrf.cpp.

@@ -979,7 +979,7 @@

Same as NRF24

-

Definition at line 1099 of file nrf_to_nrf.cpp.

+

Definition at line 1101 of file nrf_to_nrf.cpp.

@@ -999,7 +999,7 @@

Same as NRF24

-

Definition at line 1121 of file nrf_to_nrf.cpp.

+

Definition at line 1123 of file nrf_to_nrf.cpp.

@@ -1041,7 +1041,7 @@

Same as NRF24

-

Definition at line 837 of file nrf_to_nrf.cpp.

+

Definition at line 839 of file nrf_to_nrf.cpp.

@@ -1065,7 +1065,7 @@

Same as NRF24

-

Definition at line 846 of file nrf_to_nrf.cpp.

+

Definition at line 848 of file nrf_to_nrf.cpp.

@@ -1085,7 +1085,7 @@

Same as NRF24

-

Definition at line 887 of file nrf_to_nrf.cpp.

+

Definition at line 889 of file nrf_to_nrf.cpp.

@@ -1105,7 +1105,7 @@

Same as NRF24

-

Definition at line 1173 of file nrf_to_nrf.cpp.

+

Definition at line 1175 of file nrf_to_nrf.cpp.

@@ -1127,7 +1127,7 @@

Examples
examples/RF24Ethernet/mqtt_basic/mqtt_basic.ino.
-

Definition at line 1188 of file nrf_to_nrf.cpp.

+

Definition at line 1190 of file nrf_to_nrf.cpp.

@@ -1147,7 +1147,7 @@

When powering up from powerdown ALL radio settings will need to be re-applied

-

Definition at line 1158 of file nrf_to_nrf.cpp.

+

Definition at line 1160 of file nrf_to_nrf.cpp.

@@ -1167,7 +1167,7 @@

When called ALL radio settings will be reverted to default

-

Definition at line 1166 of file nrf_to_nrf.cpp.

+

Definition at line 1168 of file nrf_to_nrf.cpp.

@@ -1188,7 +1188,7 @@

Definition at line 970 of file nrf_to_nrf.cpp.

+

Definition at line 972 of file nrf_to_nrf.cpp.

@@ -1213,7 +1213,7 @@

Definition at line 988 of file nrf_to_nrf.cpp.

+

Definition at line 990 of file nrf_to_nrf.cpp.

@@ -1240,7 +1240,7 @@

Examples
examples/RF24/scanner/scanner.ino.
-

Definition at line 1136 of file nrf_to_nrf.cpp.

+

Definition at line 1138 of file nrf_to_nrf.cpp.

@@ -1265,7 +1265,7 @@

Definition at line 1151 of file nrf_to_nrf.cpp.

+

Definition at line 1153 of file nrf_to_nrf.cpp.

@@ -1285,7 +1285,7 @@

Same as NRF24

-

Definition at line 1092 of file nrf_to_nrf.cpp.

+

Definition at line 1094 of file nrf_to_nrf.cpp.

@@ -1304,7 +1304,7 @@

-

Definition at line 141 of file nrf_to_nrf.cpp.

+

Definition at line 139 of file nrf_to_nrf.cpp.

@@ -1348,7 +1348,7 @@

Function to encrypt data

-

Definition at line 1282 of file nrf_to_nrf.cpp.

+

Definition at line 1284 of file nrf_to_nrf.cpp.

@@ -1372,7 +1372,7 @@

Function to decrypt data

-

Definition at line 1314 of file nrf_to_nrf.cpp.

+

Definition at line 1316 of file nrf_to_nrf.cpp.

@@ -1394,7 +1394,7 @@

Examples
examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino, examples/RF24Mesh/RF24Mesh_Example_MasterEncryption/RF24Mesh_Example_MasterEncryption.ino, examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino, and examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino.
-

Definition at line 1347 of file nrf_to_nrf.cpp.

+

Definition at line 1349 of file nrf_to_nrf.cpp.

@@ -1416,7 +1416,7 @@

Examples
examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino.
-

Definition at line 1355 of file nrf_to_nrf.cpp.

+

Definition at line 1357 of file nrf_to_nrf.cpp.

@@ -1436,7 +1436,7 @@

Set IV for encryption. This is only used for manual encryption, a random IV is generated using the on-board RNG for encryption during normal operation.

-

Definition at line 1363 of file nrf_to_nrf.cpp.

+

Definition at line 1365 of file nrf_to_nrf.cpp.

@@ -1521,7 +1521,7 @@

diff --git a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 2fbfe44..fe6cd22 100644 --- a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -113,7 +113,7 @@ diff --git a/html/examples.html b/html/examples.html index 2fadaa8..9b04cac 100644 --- a/html/examples.html +++ b/html/examples.html @@ -109,7 +109,7 @@ diff --git a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html index c828542..2394016 100644 --- a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html +++ b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html @@ -232,12 +232,12 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void printDetails()
+
void printDetails()
diff --git a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html index b95900c..7b91dcb 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html @@ -198,18 +198,18 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool isChipConnected()
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
@ NRF_PA_MIN
Definition nrf_to_nrf.h:44
diff --git a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html index 064307b..2fc4d9a 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html @@ -191,14 +191,14 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool isChipConnected()
@ NRF_PA_MIN
Definition nrf_to_nrf.h:44
diff --git a/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html index 22fc325..108db10 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html @@ -179,15 +179,15 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html index f2809be..96a173b 100644 --- a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html @@ -149,16 +149,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html index 61c519c..d8bfb05 100644 --- a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html @@ -142,13 +142,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
bool begin()
+
void setChannel(uint8_t channel)
+
bool begin()
diff --git a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html index c1ef1f1..cee5cb7 100644 --- a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html @@ -157,16 +157,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html index 3a7b28a..daa07ec 100644 --- a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html @@ -149,13 +149,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
bool begin()
+
void setChannel(uint8_t channel)
+
bool begin()
diff --git a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html index 60cc7b1..af37782 100644 --- a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html +++ b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html @@ -290,25 +290,25 @@
}
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
uint8_t getDynamicPayloadSize()
-
bool begin()
-
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
-
void enableAckPayload()
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
uint8_t getDynamicPayloadSize()
+
bool begin()
+
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableAckPayload()
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
@ NRF_PA_MAX
Definition nrf_to_nrf.h:56
diff --git a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html index 10ec6dd..903b3db 100644 --- a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html +++ b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html @@ -253,25 +253,25 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
void setCounter(uint64_t counter)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
void setCounter(uint64_t counter)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setPayloadSize(uint8_t size)
@ NRF_PA_LOW
Definition nrf_to_nrf.h:48
diff --git a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html index b701cca..dc26ab8 100644 --- a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html +++ b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html @@ -239,23 +239,23 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
bool begin()
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
-
uint8_t getPayloadSize()
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
bool begin()
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setPayloadSize(uint8_t size)
+
uint8_t getPayloadSize()
@ NRF_PA_LOW
Definition nrf_to_nrf.h:48
diff --git a/html/examples_2RF24_2scanner_2scanner_8ino-example.html b/html/examples_2RF24_2scanner_2scanner_8ino-example.html index 2766da3..814d991 100644 --- a/html/examples_2RF24_2scanner_2scanner_8ino-example.html +++ b/html/examples_2RF24_2scanner_2scanner_8ino-example.html @@ -226,17 +226,17 @@
} //If constCarrierMode == 0
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void startListening(bool resetAddresses=true)
-
bool testCarrier(uint8_t RSSI=65)
-
void setChannel(uint8_t channel)
-
bool begin()
-
void setAutoAck(bool enable)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void startListening(bool resetAddresses=true)
+
bool testCarrier(uint8_t RSSI=65)
+
void setChannel(uint8_t channel)
+
bool begin()
+
void setAutoAck(bool enable)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
diff --git a/html/files.html b/html/files.html index fc2ebd7..e428fa9 100644 --- a/html/files.html +++ b/html/files.html @@ -108,7 +108,7 @@ diff --git a/html/functions.html b/html/functions.html index 0fdffbd..639e919 100644 --- a/html/functions.html +++ b/html/functions.html @@ -231,7 +231,7 @@

- w -

    diff --git a/html/functions_func.html b/html/functions_func.html index 6028130..06a5123 100644 --- a/html/functions_func.html +++ b/html/functions_func.html @@ -222,7 +222,7 @@

    - w -

      diff --git a/html/functions_vars.html b/html/functions_vars.html index 5c3c300..c9fd25b 100644 --- a/html/functions_vars.html +++ b/html/functions_vars.html @@ -112,7 +112,7 @@ diff --git a/html/globals.html b/html/globals.html index ff5b10e..e15dfb4 100644 --- a/html/globals.html +++ b/html/globals.html @@ -180,7 +180,7 @@

      - n -

        diff --git a/html/globals_defs.html b/html/globals_defs.html index 659939a..bbc3a70 100644 --- a/html/globals_defs.html +++ b/html/globals_defs.html @@ -127,7 +127,7 @@ diff --git a/html/globals_enum.html b/html/globals_enum.html index 5de4597..1368283 100644 --- a/html/globals_enum.html +++ b/html/globals_enum.html @@ -112,7 +112,7 @@ diff --git a/html/globals_eval.html b/html/globals_eval.html index 26b6c5c..e45adf3 100644 --- a/html/globals_eval.html +++ b/html/globals_eval.html @@ -120,7 +120,7 @@ diff --git a/html/globals_func.html b/html/globals_func.html index df8f3e2..b6eac57 100644 --- a/html/globals_func.html +++ b/html/globals_func.html @@ -111,7 +111,7 @@ diff --git a/html/index.html b/html/index.html index 7dc4ac4..c8396a7 100644 --- a/html/index.html +++ b/html/index.html @@ -101,7 +101,7 @@ diff --git a/html/nrf__to__nrf_8cpp.html b/html/nrf__to__nrf_8cpp.html index 1fe9776..62887f0 100644 --- a/html/nrf__to__nrf_8cpp.html +++ b/html/nrf__to__nrf_8cpp.html @@ -134,7 +134,7 @@

        -

        Definition at line 140 of file nrf_to_nrf.cpp.

        +

        Definition at line 138 of file nrf_to_nrf.cpp.

        @@ -196,7 +196,7 @@

        diff --git a/html/nrf__to__nrf_8cpp_source.html b/html/nrf__to__nrf_8cpp_source.html index aae7ca9..521a7fe 100644 --- a/html/nrf__to__nrf_8cpp_source.html +++ b/html/nrf__to__nrf_8cpp_source.html @@ -157,1470 +157,1472 @@
        43{
        -
        44 // Enable auto ack on all pipes by default
        -
        45 for (uint8_t i = 0; i < 8; i++) {
        -
        46 acksPerPipe[i] = true;
        -
        47 }
        -
        48 staticPayloadSize = 32;
        -
        49 DPL = false;
        -
        50 retries = 5;
        -
        51 retryDuration = 5;
        -
        52 ackPayloadsEnabled = false;
        -
        53 ackPipe = 0;
        -
        54 inRxMode = false;
        -
        55 radioConfigured = false;
        -
        56 ARC = 0;
        -
        57 addressWidth = 5;
        -
        58 ackTimeout = ACK_TIMEOUT_1MBPS;
        -
        59 payloadAvailable = false;
        -
        60
        -
        61#if defined CCM_ENCRYPTION_ENABLED
        -
        62 NRF_CCM->INPTR = (uint32_t)inBuffer;
        -
        63 NRF_CCM->OUTPTR = (uint32_t)outBuffer;
        -
        64 NRF_CCM->CNFPTR = (uint32_t)&ccmData;
        -
        65 NRF_CCM->SCRATCHPTR = (uint32_t)scratchPTR;
        -
        66 ccmData.counter = 12345;
        -
        67
        -
        68 NRF_CCM->MODE = 1 << 24 | 1 << 16;
        -
        69 NRF_CCM->MAXPACKETSIZE = MAX_PACKET_SIZE;
        -
        70 NRF_CCM->SHORTS = 1;
        -
        71 NRF_CCM->ENABLE = 2;
        -
        72 enableEncryption = false;
        -
        73 NRF_RNG->CONFIG = 1;
        -
        74 NRF_RNG->TASKS_START = 1;
        -
        75#endif
        -
        76};
        +
        44 DPL = false;
        +
        45 staticPayloadSize = 32;
        +
        46 // Enable auto ack on all pipes by default
        +
        47 setAutoAck(1);
        +
        48 retries = 5;
        +
        49 retryDuration = 5;
        +
        50 ackPayloadsEnabled = false;
        +
        51 ackPipe = 0;
        +
        52 inRxMode = false;
        +
        53 radioConfigured = false;
        +
        54 ARC = 0;
        +
        55 addressWidth = 5;
        +
        56 ackTimeout = ACK_TIMEOUT_1MBPS;
        +
        57 payloadAvailable = false;
        +
        58
        +
        59#if defined CCM_ENCRYPTION_ENABLED
        +
        60 NRF_CCM->INPTR = (uint32_t)inBuffer;
        +
        61 NRF_CCM->OUTPTR = (uint32_t)outBuffer;
        +
        62 NRF_CCM->CNFPTR = (uint32_t)&ccmData;
        +
        63 NRF_CCM->SCRATCHPTR = (uint32_t)scratchPTR;
        +
        64 ccmData.counter = 12345;
        +
        65
        +
        66 NRF_CCM->MODE = 1 << 24 | 1 << 16;
        +
        67 NRF_CCM->MAXPACKETSIZE = MAX_PACKET_SIZE;
        +
        68 NRF_CCM->SHORTS = 1;
        +
        69 NRF_CCM->ENABLE = 2;
        +
        70 enableEncryption = false;
        +
        71 NRF_RNG->CONFIG = 1;
        +
        72 NRF_RNG->TASKS_START = 1;
        +
        73#endif
        +
        74};
        +
        75
        +
        76/**********************************************************************************************************/
        77
        -
        78/**********************************************************************************************************/
        -
        79
        -
        - -
        81{
        -
        82
        -
        83 if (radioConfigured) {
        -
        84 return 1;
        -
        85 }
        -
        86
        -
        87 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        -
        88 NRF_CLOCK->TASKS_HFCLKSTART = 1;
        -
        89
        -
        90 /* Wait for the external oscillator to start up */
        -
        91 while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
        -
        92 // Do nothing.
        -
        93 }
        -
        94
        -
        95 NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        -
        96 NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        -
        97 NRF_CLOCK->TASKS_LFCLKSTART = 1;
        -
        98
        -
        99 while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
        -
        100 // Do nothing.
        -
        101 }
        -
        102
        -
        103 NRF_RADIO->POWER = 1;
        -
        104 // NRF_POWER->DCDCEN=1;
        +
        + +
        79{
        +
        80
        +
        81 if (radioConfigured) {
        +
        82 return 1;
        +
        83 }
        +
        84
        +
        85 NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        +
        86 NRF_CLOCK->TASKS_HFCLKSTART = 1;
        +
        87
        +
        88 /* Wait for the external oscillator to start up */
        +
        89 while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0) {
        +
        90 // Do nothing.
        +
        91 }
        +
        92
        +
        93 NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_Xtal << CLOCK_LFCLKSRC_SRC_Pos);
        +
        94 NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
        +
        95 NRF_CLOCK->TASKS_LFCLKSTART = 1;
        +
        96
        +
        97 while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {
        +
        98 // Do nothing.
        +
        99 }
        +
        100
        +
        101 NRF_RADIO->POWER = 1;
        +
        102 // NRF_POWER->DCDCEN=1;
        +
        103
        +
        104 NRF_RADIO->PCNF0 = (1 << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (1 << RADIO_PCNF0_S1LEN_Pos);
        105
        -
        106 NRF_RADIO->PCNF0 = (1 << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (1 << RADIO_PCNF0_S1LEN_Pos);
        +
        106 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (4 << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        107
        -
        108 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | (4 << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        -
        109
        -
        110 NRF_RADIO->BASE0 = 0xE7E7E7E7; /* Base address 0 */
        -
        111 NRF_RADIO->BASE1 = 0x43434343;
        -
        112 NRF_RADIO->PREFIX0 = 0x23C343E7; /* Prefixes bytes for logical addresses 0 */
        -
        113 NRF_RADIO->PREFIX1 = 0x13E363A3;
        -
        114 NRF_RADIO->RXADDRESSES = 0x01;
        -
        115 NRF_RADIO->TXADDRESS = 0x00;
        -
        116 /* Receive address select */
        -
        117 txBase = NRF_RADIO->BASE0;
        -
        118 txPrefix = NRF_RADIO->PREFIX0;
        -
        119 rxBase = NRF_RADIO->BASE0;
        -
        120 rxPrefix = NRF_RADIO->PREFIX0;
        -
        121 // Configure CRC for 16-bit
        -
        122 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two; /* CRC configuration: 16bit */
        -
        123 NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
        -
        124 NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
        -
        125
        -
        126 NRF_RADIO->PACKETPTR = (uint32_t)radioData;
        -
        127 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
        -
        128 NRF_RADIO->MODECNF0 = 0x200;
        -
        129 NRF_RADIO->MODECNF0 |= 1;
        -
        130 NRF_RADIO->TXPOWER = (0x8 << RADIO_TXPOWER_TXPOWER_Pos);
        -
        131 NRF_RADIO->SHORTS = 1 << 19;
        -
        132 NRF_RADIO->FREQUENCY = 0x4C;
        -
        133
        -
        134 radioConfigured = true;
        -
        135 return 1;
        -
        136}
        +
        108 NRF_RADIO->BASE0 = 0xE7E7E7E7; /* Base address 0 */
        +
        109 NRF_RADIO->BASE1 = 0x43434343;
        +
        110 NRF_RADIO->PREFIX0 = 0x23C343E7; /* Prefixes bytes for logical addresses 0 */
        +
        111 NRF_RADIO->PREFIX1 = 0x13E363A3;
        +
        112 NRF_RADIO->RXADDRESSES = 0x01;
        +
        113 NRF_RADIO->TXADDRESS = 0x00;
        +
        114 /* Receive address select */
        +
        115 txBase = NRF_RADIO->BASE0;
        +
        116 txPrefix = NRF_RADIO->PREFIX0;
        +
        117 rxBase = NRF_RADIO->BASE0;
        +
        118 rxPrefix = NRF_RADIO->PREFIX0;
        +
        119 // Configure CRC for 16-bit
        +
        120 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two; /* CRC configuration: 16bit */
        +
        121 NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
        +
        122 NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
        +
        123
        +
        124 NRF_RADIO->PACKETPTR = (uint32_t)radioData;
        +
        125 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
        +
        126 NRF_RADIO->MODECNF0 = 0x200;
        +
        127 NRF_RADIO->MODECNF0 |= 1;
        +
        128 NRF_RADIO->TXPOWER = (0x8 << RADIO_TXPOWER_TXPOWER_Pos);
        +
        129 NRF_RADIO->SHORTS = 1 << 19;
        +
        130 NRF_RADIO->FREQUENCY = 0x4C;
        +
        131
        +
        132 radioConfigured = true;
        +
        133 return 1;
        +
        134}
        +
        135
        +
        136/**********************************************************************************************************/
        137
        -
        138/**********************************************************************************************************/
        -
        139
        -
        140#define ED_RSSISCALE 4 // From electrical specifications
        -
        - -
        142{
        -
        143 int val;
        -
        144 NRF_RADIO->TASKS_EDSTART = 1; // Start
        -
        145 while (NRF_RADIO->EVENTS_EDEND != 1) {
        -
        146 // CPU can sleep here or do something else
        -
        147 // Use of interrupts are encouraged
        -
        148 }
        -
        149 val = NRF_RADIO->EDSAMPLE; // Read level
        -
        150 return (uint8_t)(val > 63
        -
        151 ? 255
        -
        152 : val * ED_RSSISCALE); // Convert to IEEE 802.15.4 scale
        -
        153}
        +
        138#define ED_RSSISCALE 4 // From electrical specifications
        +
        + +
        140{
        +
        141 int val;
        +
        142 NRF_RADIO->TASKS_EDSTART = 1; // Start
        +
        143 while (NRF_RADIO->EVENTS_EDEND != 1) {
        +
        144 // CPU can sleep here or do something else
        +
        145 // Use of interrupts are encouraged
        +
        146 }
        +
        147 val = NRF_RADIO->EDSAMPLE; // Read level
        +
        148 return (uint8_t)(val > 63
        +
        149 ? 255
        +
        150 : val * ED_RSSISCALE); // Convert to IEEE 802.15.4 scale
        +
        151}
        +
        152
        +
        153/**********************************************************************************************************/
        154
        -
        155/**********************************************************************************************************/
        -
        156
        -
        - -
        158{
        -
        159 uint8_t pipe_num = 0;
        -
        160 return available(&pipe_num);
        -
        161}
        +
        + +
        156{
        +
        157 uint8_t pipe_num = 0;
        +
        158 return available(&pipe_num);
        +
        159}
        +
        160
        +
        161/**********************************************************************************************************/
        162
        -
        163/**********************************************************************************************************/
        -
        164
        -
        -
        165bool nrf_to_nrf::available(uint8_t* pipe_num)
        -
        166{
        -
        167
        -
        168 if(payloadAvailable){
        -
        169 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
        -
        170 return true;
        -
        171 }
        -
        172
        -
        173 if (!inRxMode) {
        -
        174 if (ackPayloadAvailable) {
        -
        175 *pipe_num = ackAvailablePipeNo;
        -
        176 return true;
        -
        177 }
        -
        178 }
        -
        179 if (NRF_RADIO->EVENTS_CRCOK) {
        -
        180 uint32_t counter = 0;
        -
        181 uint8_t tmpIV[CCM_IV_SIZE];
        +
        +
        163bool nrf_to_nrf::available(uint8_t* pipe_num)
        +
        164{
        +
        165
        +
        166 if(payloadAvailable){
        +
        167 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
        +
        168 return true;
        +
        169 }
        +
        170
        +
        171 if (!inRxMode) {
        +
        172 if (ackPayloadAvailable) {
        +
        173 *pipe_num = ackAvailablePipeNo;
        +
        174 return true;
        +
        175 }
        +
        176 }
        +
        177 if (NRF_RADIO->EVENTS_CRCOK) {
        +
        178 uint32_t counter = 0;
        +
        179#if defined CCM_ENCRYPTION_ENABLED
        +
        180 uint8_t tmpIV[CCM_IV_SIZE];
        +
        181#endif
        182 NRF_RADIO->EVENTS_CRCOK = 0;
        -
        183 if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) {
        -
        184 NRF_RADIO->TASKS_START = 1;
        -
        185 return 0;
        -
        186 }else
        -
        187 if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) {
        -
        188 NRF_RADIO->TASKS_START = 1;
        -
        189 return 0;
        -
        190 }else
        -
        191 if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) {
        -
        192 NRF_RADIO->TASKS_START = 1;
        -
        193 return 0;
        -
        194 }
        -
        195
        -
        196 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
        -
        197 if (!DPL && acksEnabled(*pipe_num) == false) {
        -
        198#if defined CCM_ENCRYPTION_ENABLED
        -
        199 if (enableEncryption) {
        -
        200 memcpy(&rxBuffer[1], &radioData[CCM_IV_SIZE + CCM_COUNTER_SIZE], staticPayloadSize);
        -
        201 memcpy(ccmData.iv, &radioData[0], CCM_IV_SIZE);
        -
        202 memcpy(&counter, &radioData[CCM_IV_SIZE], CCM_COUNTER_SIZE);
        -
        203 }
        -
        204 else {
        -
        205#endif
        -
        206 memcpy(&rxBuffer[1], &radioData[0], staticPayloadSize);
        -
        207#if defined CCM_ENCRYPTION_ENABLED
        -
        208 }
        -
        209#endif
        -
        210 }
        -
        211 else {
        -
        212#if defined CCM_ENCRYPTION_ENABLED
        -
        213 if (enableEncryption) {
        -
        214 if (DPL) {
        -
        215 memcpy(&rxBuffer[1], &radioData[2 + CCM_IV_SIZE + CCM_COUNTER_SIZE], max(0, radioData[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        -
        216 }
        -
        217 else {
        -
        218 memcpy(&rxBuffer[1], &radioData[2 + CCM_IV_SIZE + CCM_COUNTER_SIZE], max(0, staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        -
        219 }
        -
        220 memcpy(tmpIV, &radioData[2], CCM_IV_SIZE);
        -
        221 memcpy(&counter, &radioData[2 + CCM_IV_SIZE], CCM_COUNTER_SIZE);
        -
        222 }
        -
        223 else {
        -
        224#endif
        -
        225 if(DPL) {
        -
        226 memcpy(&rxBuffer[1], &radioData[2], radioData[0]);
        -
        227 }else{
        -
        228 memcpy(&rxBuffer[1], &radioData[2], staticPayloadSize);
        -
        229 }
        -
        230#if defined CCM_ENCRYPTION_ENABLED
        -
        231 }
        -
        232#endif
        -
        233 }
        -
        234 rxBuffer[0] = radioData[0];
        -
        235 rxFifoAvailable = true;
        -
        236 uint8_t packetCtr = 0;
        -
        237 if (DPL) {
        -
        238 packetCtr = radioData[1];
        -
        239 }
        -
        240 else {
        -
        241 packetCtr = radioData[0];
        -
        242 }
        -
        243
        -
        244 ackPID = packetCtr;
        -
        245 uint16_t packetData = NRF_RADIO->RXCRC;
        -
        246 // If ack is enabled on this receiving pipe
        -
        247 if (acksEnabled(NRF_RADIO->RXMATCH)) {
        -
        248 stopListening(false, false);
        -
        249 uint32_t txAddress = NRF_RADIO->TXADDRESS;
        -
        250 NRF_RADIO->TXADDRESS = NRF_RADIO->RXMATCH;
        -
        251 delayMicroseconds(55);
        -
        252 if (ackPayloadsEnabled) {
        -
        253 if (*pipe_num == ackPipe) {
        -
        254 write(&ackBuffer[1], ackBuffer[0], 1, 0);
        -
        255 }
        -
        256 else {
        -
        257 write(0, 0, 1, 0);
        -
        258 }
        -
        259 }
        -
        260 else {
        -
        261 uint8_t payloadSize = 0;
        -
        262 if (!DPL) {
        -
        263 payloadSize = getPayloadSize();
        - -
        265 }
        -
        266 write(0, 0, 1, 0); // Send an ACK
        -
        267 if (!DPL) {
        -
        268 setPayloadSize(payloadSize);
        -
        269 }
        -
        270 }
        -
        271 NRF_RADIO->TXADDRESS = txAddress;
        -
        272 startListening(false);
        -
        273 }
        -
        274
        -
        275 // If the packet has the same ID number and data, it is most likely a
        -
        276 // duplicate
        -
        277 if(NRF_RADIO->CRCCNF != 0){ //If CRC enabled, check this data
        -
        278 if (packetCtr == lastPacketCounter && packetData == lastData) {
        -
        279 NRF_RADIO->TASKS_START = 1;
        -
        280 return 0;
        -
        281 }
        -
        282 }
        -
        283#if defined CCM_ENCRYPTION_ENABLED
        -
        284 if (enableEncryption) {
        -
        285 ccmData.counter = counter;
        -
        286 memcpy(&ccmData.iv[0], &tmpIV[0], CCM_IV_SIZE);
        -
        287 if (DPL) {
        -
        288 if (!decrypt(&rxBuffer[1], rxBuffer[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE)) {
        -
        289 Serial.println("DECRYPT FAIL");
        -
        290 NRF_RADIO->TASKS_START = 1;
        -
        291 return 0;
        -
        292 }
        -
        293 }
        -
        294 else {
        -
        295 if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) {
        -
        296 Serial.println("DECRYPT FAIL");
        -
        297 NRF_RADIO->TASKS_START = 1;
        -
        298 return 0;
        -
        299 }
        -
        300 }
        -
        301
        -
        302 memset(&rxBuffer[1], 0, sizeof(rxBuffer) - 1);
        +
        183 if (DPL){
        +
        184 if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) {
        +
        185 NRF_RADIO->TASKS_START = 1;
        +
        186 return 0;
        +
        187 }else
        +
        188 if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) {
        +
        189 NRF_RADIO->TASKS_START = 1;
        +
        190 return 0;
        +
        191 }else
        +
        192 if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) {
        +
        193 NRF_RADIO->TASKS_START = 1;
        +
        194 return 0;
        +
        195 }
        +
        196 }
        +
        197
        +
        198 *pipe_num = (uint8_t)NRF_RADIO->RXMATCH;
        +
        199 if (!DPL && acksEnabled(*pipe_num) == false) {
        +
        200#if defined CCM_ENCRYPTION_ENABLED
        +
        201 if (enableEncryption) {
        +
        202 memcpy(&rxBuffer[1], &radioData[CCM_IV_SIZE + CCM_COUNTER_SIZE], staticPayloadSize);
        +
        203 memcpy(ccmData.iv, &radioData[0], CCM_IV_SIZE);
        +
        204 memcpy(&counter, &radioData[CCM_IV_SIZE], CCM_COUNTER_SIZE);
        +
        205 }
        +
        206 else {
        +
        207#endif
        +
        208 memcpy(&rxBuffer[1], &radioData[0], staticPayloadSize);
        +
        209#if defined CCM_ENCRYPTION_ENABLED
        +
        210 }
        +
        211#endif
        +
        212 }
        +
        213 else {
        +
        214#if defined CCM_ENCRYPTION_ENABLED
        +
        215 if (enableEncryption) {
        +
        216 if (DPL) {
        +
        217 memcpy(&rxBuffer[1], &radioData[2 + CCM_IV_SIZE + CCM_COUNTER_SIZE], max(0, radioData[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        +
        218 }
        +
        219 else {
        +
        220 memcpy(&rxBuffer[1], &radioData[2 + CCM_IV_SIZE + CCM_COUNTER_SIZE], max(0, staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        +
        221 }
        +
        222 memcpy(tmpIV, &radioData[2], CCM_IV_SIZE);
        +
        223 memcpy(&counter, &radioData[2 + CCM_IV_SIZE], CCM_COUNTER_SIZE);
        +
        224 }
        +
        225 else {
        +
        226#endif
        +
        227 if(DPL) {
        +
        228 memcpy(&rxBuffer[1], &radioData[2], radioData[0]);
        +
        229 }else{
        +
        230 memcpy(&rxBuffer[1], &radioData[2], staticPayloadSize);
        +
        231 }
        +
        232#if defined CCM_ENCRYPTION_ENABLED
        +
        233 }
        +
        234#endif
        +
        235 }
        +
        236 rxBuffer[0] = radioData[0];
        +
        237 rxFifoAvailable = true;
        +
        238 uint8_t packetCtr = 0;
        +
        239 if (DPL) {
        +
        240 packetCtr = radioData[1];
        +
        241 }
        +
        242 else {
        +
        243 packetCtr = radioData[0];
        +
        244 }
        +
        245
        +
        246 ackPID = packetCtr;
        +
        247 uint16_t packetData = NRF_RADIO->RXCRC;
        +
        248 // If ack is enabled on this receiving pipe
        +
        249 if (acksEnabled(NRF_RADIO->RXMATCH)) {
        +
        250 stopListening(false, false);
        +
        251 uint32_t txAddress = NRF_RADIO->TXADDRESS;
        +
        252 NRF_RADIO->TXADDRESS = NRF_RADIO->RXMATCH;
        +
        253 delayMicroseconds(75);
        +
        254 if (ackPayloadsEnabled) {
        +
        255 if (*pipe_num == ackPipe) {
        +
        256 write(&ackBuffer[1], ackBuffer[0], 1, 0);
        +
        257 }
        +
        258 else {
        +
        259 write(0, 0, 1, 0);
        +
        260 }
        +
        261 }
        +
        262 else {
        +
        263 uint8_t payloadSize = 0;
        +
        264 if (!DPL) {
        +
        265 payloadSize = getPayloadSize();
        + +
        267 }
        +
        268 write(0, 0, 1, 0); // Send an ACK
        +
        269 if (!DPL) {
        +
        270 setPayloadSize(payloadSize);
        +
        271 }
        +
        272 }
        +
        273 NRF_RADIO->TXADDRESS = txAddress;
        +
        274 startListening(false);
        +
        275 }
        +
        276
        +
        277 // If the packet has the same ID number and data, it is most likely a
        +
        278 // duplicate
        +
        279 if(NRF_RADIO->CRCCNF != 0){ //If CRC enabled, check this data
        +
        280 if (packetCtr == lastPacketCounter && packetData == lastData) {
        +
        281 NRF_RADIO->TASKS_START = 1;
        +
        282 return 0;
        +
        283 }
        +
        284 }
        +
        285#if defined CCM_ENCRYPTION_ENABLED
        +
        286 if (enableEncryption) {
        +
        287 ccmData.counter = counter;
        +
        288 memcpy(&ccmData.iv[0], &tmpIV[0], CCM_IV_SIZE);
        +
        289 if (DPL) {
        +
        290 if (!decrypt(&rxBuffer[1], rxBuffer[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE)) {
        +
        291 Serial.println("DECRYPT FAIL");
        +
        292 NRF_RADIO->TASKS_START = 1;
        +
        293 return 0;
        +
        294 }
        +
        295 }
        +
        296 else {
        +
        297 if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) {
        +
        298 Serial.println("DECRYPT FAIL");
        +
        299 NRF_RADIO->TASKS_START = 1;
        +
        300 return 0;
        +
        301 }
        +
        302 }
        303
        -
        304 if (DPL) {
        -
        305 rxBuffer[0] -= (CCM_MIC_SIZE + CCM_IV_SIZE + CCM_COUNTER_SIZE);
        -
        306 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], rxBuffer[0]);
        -
        307
        -
        308 }
        -
        309 else {
        -
        310 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], staticPayloadSize - (CCM_MIC_SIZE - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        -
        311 }
        -
        312 }
        -
        313#endif
        -
        314 lastPacketCounter = packetCtr;
        -
        315 lastData = packetData;
        -
        316 payloadAvailable = true;
        -
        317 return 1;
        -
        318 }
        -
        319 if(NRF_RADIO->EVENTS_CRCERROR) {
        -
        320 NRF_RADIO->EVENTS_CRCERROR = 0;
        -
        321 NRF_RADIO->TASKS_START = 1;
        -
        322 }
        -
        323 return 0;
        -
        324}
        +
        304 memset(&rxBuffer[1], 0, sizeof(rxBuffer) - 1);
        +
        305
        +
        306 if (DPL) {
        +
        307 rxBuffer[0] -= (CCM_MIC_SIZE + CCM_IV_SIZE + CCM_COUNTER_SIZE);
        +
        308 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], rxBuffer[0]);
        +
        309
        +
        310 }
        +
        311 else {
        +
        312 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], staticPayloadSize - (CCM_MIC_SIZE - CCM_IV_SIZE - CCM_COUNTER_SIZE));
        +
        313 }
        +
        314 }
        +
        315#endif
        +
        316 lastPacketCounter = packetCtr;
        +
        317 lastData = packetData;
        +
        318 payloadAvailable = true;
        +
        319 return 1;
        +
        320 }
        +
        321 if(NRF_RADIO->EVENTS_CRCERROR) {
        +
        322 NRF_RADIO->EVENTS_CRCERROR = 0;
        +
        323 NRF_RADIO->TASKS_START = 1;
        +
        324 }
        +
        325 return 0;
        +
        326}
        -
        325
        -
        326/**********************************************************************************************************/
        327
        -
        -
        328void nrf_to_nrf::read(void* buf, uint8_t len)
        -
        329{
        -
        330 memcpy(buf, &rxBuffer[1], len);
        -
        331 ackPayloadAvailable = false;
        -
        332 if (inRxMode) {
        -
        333 NRF_RADIO->TASKS_START = 1;
        -
        334 }
        -
        335 payloadAvailable = false;
        -
        336}
        +
        328/**********************************************************************************************************/
        +
        329
        +
        +
        330void nrf_to_nrf::read(void* buf, uint8_t len)
        +
        331{
        +
        332 memcpy(buf, &rxBuffer[1], len);
        +
        333 ackPayloadAvailable = false;
        +
        334 if (inRxMode) {
        +
        335 NRF_RADIO->TASKS_START = 1;
        +
        336 }
        +
        337 payloadAvailable = false;
        +
        338}
        -
        337
        -
        338/**********************************************************************************************************/
        339
        -
        -
        340bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption)
        -
        341{
        -
        342
        -
        343 uint8_t PID = ackPID;
        -
        344 if (DPL) {
        -
        345 PID = ((ackPID += 1) % 7) << 1;
        -
        346 }
        -
        347 else {
        -
        348 PID = ackPID++;
        -
        349 }
        -
        350 uint8_t payloadSize = 0;
        -
        351
        -
        352#if defined CCM_ENCRYPTION_ENABLED
        -
        353 uint8_t tmpIV[CCM_IV_SIZE];
        -
        354 uint32_t tmpCounter = 0;
        -
        355 uint8_t tmpBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
        -
        356
        -
        357 if (enableEncryption && doEncryption) {
        -
        358 if (len) {
        -
        359
        -
        360 for (int i = 0; i < CCM_IV_SIZE; i++) {
        -
        361 while (!NRF_RNG->EVENTS_VALRDY) {}
        -
        362 NRF_RNG->EVENTS_VALRDY = 0;
        -
        363 tmpIV[i] = NRF_RNG->VALUE;
        -
        364 ccmData.iv[i] = tmpIV[i];
        -
        365 }
        -
        366 tmpCounter = packetCounter;
        -
        367 ccmData.counter = tmpCounter;
        -
        368
        -
        369 if (!encrypt(buf, len)) {
        -
        370 return 0;
        -
        371 }
        -
        372
        -
        373 memcpy(tmpBuffer, &outBuffer[CCM_START_SIZE], len + CCM_MIC_SIZE);
        - -
        375 packetCounter++;
        -
        376 if (packetCounter > 200000) {
        -
        377 packetCounter = 0;
        -
        378 }
        -
        379 }
        -
        380 }
        -
        381#endif
        -
        382
        -
        383 for (int i = 0; i < (retries + 1); i++) {
        -
        384 ARC = i;
        -
        385 if (DPL) {
        -
        386 radioData[0] = len;
        -
        387 radioData[1] = PID;
        -
        388 }
        -
        389 else {
        -
        390 radioData[1] = 0;
        -
        391 radioData[0] = PID;
        -
        392 }
        -
        393
        -
        394 uint8_t dataStart = 0;
        +
        340/**********************************************************************************************************/
        +
        341
        +
        +
        342bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption)
        +
        343{
        +
        344
        +
        345 uint8_t PID = ackPID;
        +
        346 if (DPL) {
        +
        347 PID = ((ackPID += 1) % 7) << 1;
        +
        348 }
        +
        349 else {
        +
        350 PID = ackPID++;
        +
        351 }
        +
        352 uint8_t payloadSize = 0;
        +
        353
        +
        354#if defined CCM_ENCRYPTION_ENABLED
        +
        355 uint8_t tmpIV[CCM_IV_SIZE];
        +
        356 uint32_t tmpCounter = 0;
        +
        357 uint8_t tmpBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
        +
        358
        +
        359 if (enableEncryption && doEncryption) {
        +
        360 if (len) {
        +
        361
        +
        362 for (int i = 0; i < CCM_IV_SIZE; i++) {
        +
        363 while (!NRF_RNG->EVENTS_VALRDY) {}
        +
        364 NRF_RNG->EVENTS_VALRDY = 0;
        +
        365 tmpIV[i] = NRF_RNG->VALUE;
        +
        366 ccmData.iv[i] = tmpIV[i];
        +
        367 }
        +
        368 tmpCounter = packetCounter;
        +
        369 ccmData.counter = tmpCounter;
        +
        370
        +
        371 if (!encrypt(buf, len)) {
        +
        372 return 0;
        +
        373 }
        +
        374
        +
        375 memcpy(tmpBuffer, &outBuffer[CCM_START_SIZE], len + CCM_MIC_SIZE);
        + +
        377 packetCounter++;
        +
        378 if (packetCounter > 200000) {
        +
        379 packetCounter = 0;
        +
        380 }
        +
        381 }
        +
        382 }
        +
        383#endif
        +
        384
        +
        385 for (int i = 0; i < (retries + 1); i++) {
        +
        386 ARC = i;
        +
        387 if (DPL) {
        +
        388 radioData[0] = len;
        +
        389 radioData[1] = PID;
        +
        390 }
        +
        391 else {
        +
        392 radioData[1] = 0;
        +
        393 radioData[0] = PID;
        +
        394 }
        395
        -
        396#if defined CCM_ENCRYPTION_ENABLED
        +
        396 uint8_t dataStart = 0;
        397
        -
        398
        +
        398#if defined CCM_ENCRYPTION_ENABLED
        399
        -
        400 if (enableEncryption && doEncryption) {
        -
        401 dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2;
        -
        402 }
        -
        403 else {
        -
        404#endif
        -
        405 dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2;
        -
        406#if defined CCM_ENCRYPTION_ENABLED
        -
        407 }
        -
        408#endif
        -
        409
        -
        410#if defined CCM_ENCRYPTION_ENABLED
        -
        411 if (enableEncryption && doEncryption) {
        -
        412 memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE);
        -
        413 memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE);
        -
        414 memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE));
        -
        415 }
        -
        416 else {
        -
        417#endif
        -
        418 memcpy(&radioData[dataStart], buf, len);
        -
        419#if defined CCM_ENCRYPTION_ENABLED
        -
        420 }
        -
        421#endif
        -
        422
        -
        423 if (NRF_RADIO->STATE < 9) {
        -
        424 NRF_RADIO->EVENTS_TXREADY = 0;
        -
        425 NRF_RADIO->TASKS_TXEN = 1;
        -
        426 while (NRF_RADIO->EVENTS_TXREADY == 0) {
        -
        427 }
        -
        428 NRF_RADIO->EVENTS_TXREADY = 0;
        -
        429 }
        -
        430
        -
        431 NRF_RADIO->EVENTS_END = 0;
        -
        432 NRF_RADIO->TASKS_START = 1;
        -
        433 while (NRF_RADIO->EVENTS_END == 0) {
        -
        434 }
        -
        435 NRF_RADIO->EVENTS_END = 0;
        -
        436 if (!multicast && acksPerPipe[NRF_RADIO->TXADDRESS] == true) {
        -
        437 uint32_t rxAddress = NRF_RADIO->RXADDRESSES;
        -
        438 NRF_RADIO->RXADDRESSES = 1 << NRF_RADIO->TXADDRESS;
        -
        439 if (!DPL) {
        -
        440 payloadSize = getPayloadSize();
        - -
        442 }
        -
        443 startListening(false);
        -
        444
        -
        445 uint32_t realAckTimeout = ackTimeout;
        -
        446 if (!DPL) {
        -
        447 if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos)) {
        -
        448 realAckTimeout -= ACK_TIMEOUT_1MBPS_OFFSET;
        -
        449 }
        -
        450 else {
        -
        451 realAckTimeout -= ACK_TIMEOUT_2MBPS_OFFSET;
        -
        452 }
        -
        453 }else{
        -
        454 if(ackPayloadsEnabled && staticPayloadSize <= DEFAULT_MAX_PAYLOAD_SIZE ){
        -
        455 realAckTimeout += 200;
        -
        456 }else{
        -
        457 realAckTimeout += ACK_PAYLOAD_TIMEOUT_OFFSET;
        -
        458 }
        -
        459 }
        -
        460 uint32_t ack_timeout = micros();
        -
        461 while (!NRF_RADIO->EVENTS_CRCOK && !NRF_RADIO->EVENTS_CRCERROR) {
        -
        462 if (micros() - ack_timeout > realAckTimeout) {
        -
        463 break;
        -
        464 }
        -
        465 }
        -
        466 if (NRF_RADIO->EVENTS_CRCOK) {
        -
        467 if (ackPayloadsEnabled && radioData[0] > 0) {
        -
        468#if defined CCM_ENCRYPTION_ENABLED
        -
        469 if(enableEncryption && doEncryption){
        -
        470 memcpy(&rxBuffer[1], &radioData[2 + CCM_COUNTER_SIZE + CCM_IV_SIZE] , max(0, radioData[0] - CCM_COUNTER_SIZE - CCM_IV_SIZE));
        -
        471 }else{
        -
        472 memcpy(&rxBuffer[1], &radioData[2] , radioData[0]);
        -
        473 }
        -
        474#else
        -
        475 memcpy(&rxBuffer[1], &radioData[2], radioData[0]);
        -
        476#endif
        -
        477
        -
        478#if defined CCM_ENCRYPTION_ENABLED
        -
        479 if (enableEncryption && radioData[0] > 0) {
        -
        480 memcpy(ccmData.iv, &radioData[2], CCM_IV_SIZE);
        -
        481 memcpy(&ccmData.counter, &radioData[2 + CCM_IV_SIZE], CCM_COUNTER_SIZE);
        -
        482
        -
        483 if (!decrypt(&rxBuffer[1], radioData[0])) {
        -
        484 Serial.println("DECRYPT FAIL");
        -
        485 return 0;
        -
        486 }
        - - -
        489 }
        -
        490 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], radioData[0]);
        -
        491 }
        -
        492#endif
        -
        493 rxBuffer[0] = radioData[0];
        -
        494 ackPayloadAvailable = true;
        -
        495 ackAvailablePipeNo = NRF_RADIO->RXMATCH;
        -
        496 }
        -
        497 NRF_RADIO->EVENTS_CRCOK = 0;
        -
        498 stopListening(false, false);
        -
        499 if (!DPL) {
        -
        500 setPayloadSize(payloadSize);
        -
        501 }
        -
        502 NRF_RADIO->RXADDRESSES = rxAddress;
        -
        503 lastTxResult = true;
        -
        504 return 1;
        -
        505 }
        -
        506 else if (NRF_RADIO->EVENTS_CRCERROR) {
        -
        507 NRF_RADIO->EVENTS_CRCERROR = 0;
        -
        508 }
        -
        509 uint32_t duration = 258 * retryDuration;
        -
        510 delayMicroseconds(duration);
        -
        511 stopListening(false, false);
        -
        512 if (!DPL) {
        -
        513 setPayloadSize(payloadSize);
        -
        514 }
        -
        515 NRF_RADIO->RXADDRESSES = rxAddress;
        -
        516 }
        -
        517 else {
        -
        518 lastTxResult = true;
        -
        519 return 1;
        -
        520 }
        -
        521 }
        -
        522 lastTxResult = false;
        -
        523 return 0;
        -
        524}
        +
        400
        +
        401
        +
        402 if (enableEncryption && doEncryption) {
        +
        403 dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2;
        +
        404 }
        +
        405 else {
        +
        406#endif
        +
        407 dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2;
        +
        408#if defined CCM_ENCRYPTION_ENABLED
        +
        409 }
        +
        410#endif
        +
        411
        +
        412#if defined CCM_ENCRYPTION_ENABLED
        +
        413 if (enableEncryption && doEncryption) {
        +
        414 memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE);
        +
        415 memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE);
        +
        416 memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE));
        +
        417 }
        +
        418 else {
        +
        419#endif
        +
        420 memcpy(&radioData[dataStart], buf, len);
        +
        421#if defined CCM_ENCRYPTION_ENABLED
        +
        422 }
        +
        423#endif
        +
        424
        +
        425 if (NRF_RADIO->STATE < 9) {
        +
        426 NRF_RADIO->EVENTS_TXREADY = 0;
        +
        427 NRF_RADIO->TASKS_TXEN = 1;
        +
        428 while (NRF_RADIO->EVENTS_TXREADY == 0) {
        +
        429 }
        +
        430 NRF_RADIO->EVENTS_TXREADY = 0;
        +
        431 }
        +
        432
        +
        433 NRF_RADIO->EVENTS_END = 0;
        +
        434 NRF_RADIO->TASKS_START = 1;
        +
        435 while (NRF_RADIO->EVENTS_END == 0) {
        +
        436 }
        +
        437 NRF_RADIO->EVENTS_END = 0;
        +
        438 if (!multicast && acksPerPipe[NRF_RADIO->TXADDRESS] == true) {
        +
        439 uint32_t rxAddress = NRF_RADIO->RXADDRESSES;
        +
        440 NRF_RADIO->RXADDRESSES = 1 << NRF_RADIO->TXADDRESS;
        +
        441 if (!DPL) {
        +
        442 payloadSize = getPayloadSize();
        + +
        444 }
        +
        445 startListening(false);
        +
        446
        +
        447 uint32_t realAckTimeout = ackTimeout;
        +
        448 if (!DPL) {
        +
        449 if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos)) {
        +
        450 realAckTimeout -= ACK_TIMEOUT_1MBPS_OFFSET;
        +
        451 }
        +
        452 else {
        +
        453 realAckTimeout -= ACK_TIMEOUT_2MBPS_OFFSET;
        +
        454 }
        +
        455 }else{
        +
        456 if(ackPayloadsEnabled && staticPayloadSize <= DEFAULT_MAX_PAYLOAD_SIZE ){
        +
        457 realAckTimeout += 200;
        +
        458 }else{
        +
        459 realAckTimeout += ACK_PAYLOAD_TIMEOUT_OFFSET;
        +
        460 }
        +
        461 }
        +
        462 uint32_t ack_timeout = micros();
        +
        463 while (!NRF_RADIO->EVENTS_CRCOK && !NRF_RADIO->EVENTS_CRCERROR) {
        +
        464 if (micros() - ack_timeout > realAckTimeout) {
        +
        465 break;
        +
        466 }
        +
        467 }
        +
        468 if (NRF_RADIO->EVENTS_CRCOK) {
        +
        469 if (ackPayloadsEnabled && radioData[0] > 0) {
        +
        470#if defined CCM_ENCRYPTION_ENABLED
        +
        471 if(enableEncryption && doEncryption){
        +
        472 memcpy(&rxBuffer[1], &radioData[2 + CCM_COUNTER_SIZE + CCM_IV_SIZE] , max(0, radioData[0] - CCM_COUNTER_SIZE - CCM_IV_SIZE));
        +
        473 }else{
        +
        474 memcpy(&rxBuffer[1], &radioData[2] , radioData[0]);
        +
        475 }
        +
        476#else
        +
        477 memcpy(&rxBuffer[1], &radioData[2], radioData[0]);
        +
        478#endif
        +
        479
        +
        480#if defined CCM_ENCRYPTION_ENABLED
        +
        481 if (enableEncryption && radioData[0] > 0) {
        +
        482 memcpy(ccmData.iv, &radioData[2], CCM_IV_SIZE);
        +
        483 memcpy(&ccmData.counter, &radioData[2 + CCM_IV_SIZE], CCM_COUNTER_SIZE);
        +
        484
        +
        485 if (!decrypt(&rxBuffer[1], radioData[0])) {
        +
        486 Serial.println("DECRYPT FAIL");
        +
        487 return 0;
        +
        488 }
        + + +
        491 }
        +
        492 memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], radioData[0]);
        +
        493 }
        +
        494#endif
        +
        495 rxBuffer[0] = radioData[0];
        +
        496 ackPayloadAvailable = true;
        +
        497 ackAvailablePipeNo = NRF_RADIO->RXMATCH;
        +
        498 }
        +
        499 NRF_RADIO->EVENTS_CRCOK = 0;
        +
        500 stopListening(false, false);
        +
        501 if (!DPL) {
        +
        502 setPayloadSize(payloadSize);
        +
        503 }
        +
        504 NRF_RADIO->RXADDRESSES = rxAddress;
        +
        505 lastTxResult = true;
        +
        506 return 1;
        +
        507 }
        +
        508 else if (NRF_RADIO->EVENTS_CRCERROR) {
        +
        509 NRF_RADIO->EVENTS_CRCERROR = 0;
        +
        510 }
        +
        511 uint32_t duration = 258 * retryDuration;
        +
        512 delayMicroseconds(duration);
        +
        513 stopListening(false, false);
        +
        514 if (!DPL) {
        +
        515 setPayloadSize(payloadSize);
        +
        516 }
        +
        517 NRF_RADIO->RXADDRESSES = rxAddress;
        +
        518 }
        +
        519 else {
        +
        520 lastTxResult = true;
        +
        521 return 1;
        +
        522 }
        +
        523 }
        +
        524 lastTxResult = false;
        +
        525 return 0;
        +
        526}
        -
        525
        -
        526/**********************************************************************************************************/
        527
        -
        -
        528bool nrf_to_nrf::startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption)
        -
        529{
        -
        530
        -
        531
        -
        532 uint8_t PID = ackPID;
        -
        533 if (DPL) {
        -
        534 PID = ((ackPID += 1) % 7) << 1;
        -
        535 }
        -
        536 else {
        -
        537 PID = ackPID++;
        -
        538 }
        -
        539
        -
        540#if defined CCM_ENCRYPTION_ENABLED
        -
        541 uint8_t tmpIV[CCM_IV_SIZE];
        -
        542 uint32_t tmpCounter = 0;
        -
        543 uint8_t tmpBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
        -
        544
        -
        545 if (enableEncryption && doEncryption) {
        -
        546 if (len) {
        -
        547
        -
        548 for (int i = 0; i < CCM_IV_SIZE; i++) {
        -
        549 while (!NRF_RNG->EVENTS_VALRDY) {}
        -
        550 NRF_RNG->EVENTS_VALRDY = 0;
        -
        551 tmpIV[i] = NRF_RNG->VALUE;
        -
        552 ccmData.iv[i] = tmpIV[i];
        -
        553 }
        -
        554 tmpCounter = packetCounter;
        -
        555 ccmData.counter = tmpCounter;
        -
        556
        -
        557 if (!encrypt(buf, len)) {
        -
        558 return 0;
        -
        559 }
        -
        560
        -
        561 memcpy(tmpBuffer, &outBuffer[CCM_START_SIZE], len + CCM_MIC_SIZE);
        - -
        563 packetCounter++;
        -
        564 if (packetCounter > 200000) {
        -
        565 packetCounter = 0;
        -
        566 }
        -
        567 }
        -
        568 }
        -
        569#endif
        -
        570
        -
        571 // for (int i = 0; i < retries; i++) {
        -
        572 ARC = 0;
        -
        573 if (DPL) {
        -
        574 radioData[0] = len;
        -
        575 radioData[1] = PID;
        -
        576 }
        -
        577 else {
        -
        578 radioData[1] = 0;
        -
        579 radioData[0] = PID;
        -
        580 }
        -
        581
        -
        582 uint8_t dataStart = 0;
        +
        528/**********************************************************************************************************/
        +
        529
        +
        +
        530bool nrf_to_nrf::startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption)
        +
        531{
        +
        532
        +
        533
        +
        534 uint8_t PID = ackPID;
        +
        535 if (DPL) {
        +
        536 PID = ((ackPID += 1) % 7) << 1;
        +
        537 }
        +
        538 else {
        +
        539 PID = ackPID++;
        +
        540 }
        +
        541
        +
        542#if defined CCM_ENCRYPTION_ENABLED
        +
        543 uint8_t tmpIV[CCM_IV_SIZE];
        +
        544 uint32_t tmpCounter = 0;
        +
        545 uint8_t tmpBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
        +
        546
        +
        547 if (enableEncryption && doEncryption) {
        +
        548 if (len) {
        +
        549
        +
        550 for (int i = 0; i < CCM_IV_SIZE; i++) {
        +
        551 while (!NRF_RNG->EVENTS_VALRDY) {}
        +
        552 NRF_RNG->EVENTS_VALRDY = 0;
        +
        553 tmpIV[i] = NRF_RNG->VALUE;
        +
        554 ccmData.iv[i] = tmpIV[i];
        +
        555 }
        +
        556 tmpCounter = packetCounter;
        +
        557 ccmData.counter = tmpCounter;
        +
        558
        +
        559 if (!encrypt(buf, len)) {
        +
        560 return 0;
        +
        561 }
        +
        562
        +
        563 memcpy(tmpBuffer, &outBuffer[CCM_START_SIZE], len + CCM_MIC_SIZE);
        + +
        565 packetCounter++;
        +
        566 if (packetCounter > 200000) {
        +
        567 packetCounter = 0;
        +
        568 }
        +
        569 }
        +
        570 }
        +
        571#endif
        +
        572
        +
        573 // for (int i = 0; i < retries; i++) {
        +
        574 ARC = 0;
        +
        575 if (DPL) {
        +
        576 radioData[0] = len;
        +
        577 radioData[1] = PID;
        +
        578 }
        +
        579 else {
        +
        580 radioData[1] = 0;
        +
        581 radioData[0] = PID;
        +
        582 }
        583
        -
        584#if defined CCM_ENCRYPTION_ENABLED
        +
        584 uint8_t dataStart = 0;
        585
        -
        586
        +
        586#if defined CCM_ENCRYPTION_ENABLED
        587
        -
        588 if (enableEncryption && doEncryption) {
        -
        589 dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2;
        -
        590 }
        -
        591 else {
        -
        592#endif
        -
        593 dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2;
        -
        594#if defined CCM_ENCRYPTION_ENABLED
        -
        595 }
        -
        596#endif
        -
        597
        -
        598#if defined CCM_ENCRYPTION_ENABLED
        -
        599 if (enableEncryption && doEncryption) {
        -
        600 memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE);
        -
        601 memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE);
        -
        602 memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE));
        -
        603 }
        -
        604 else {
        -
        605#endif
        -
        606 memcpy(&radioData[dataStart], buf, len);
        -
        607#if defined CCM_ENCRYPTION_ENABLED
        -
        608 }
        -
        609#endif
        -
        610
        -
        611 if (NRF_RADIO->STATE < 9) {
        -
        612 NRF_RADIO->EVENTS_TXREADY = 0;
        -
        613 NRF_RADIO->TASKS_TXEN = 1;
        -
        614 while (NRF_RADIO->EVENTS_TXREADY == 0) {
        -
        615 }
        -
        616 NRF_RADIO->EVENTS_TXREADY = 0;
        -
        617 }
        -
        618
        -
        619 NRF_RADIO->EVENTS_END = 0;
        -
        620 NRF_RADIO->TASKS_START = 1;
        -
        621 lastTxResult = true;
        -
        622
        -
        623 return true;
        -
        624}
        +
        588
        +
        589
        +
        590 if (enableEncryption && doEncryption) {
        +
        591 dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2;
        +
        592 }
        +
        593 else {
        +
        594#endif
        +
        595 dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2;
        +
        596#if defined CCM_ENCRYPTION_ENABLED
        +
        597 }
        +
        598#endif
        +
        599
        +
        600#if defined CCM_ENCRYPTION_ENABLED
        +
        601 if (enableEncryption && doEncryption) {
        +
        602 memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE);
        +
        603 memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE);
        +
        604 memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE));
        +
        605 }
        +
        606 else {
        +
        607#endif
        +
        608 memcpy(&radioData[dataStart], buf, len);
        +
        609#if defined CCM_ENCRYPTION_ENABLED
        +
        610 }
        +
        611#endif
        +
        612
        +
        613 if (NRF_RADIO->STATE < 9) {
        +
        614 NRF_RADIO->EVENTS_TXREADY = 0;
        +
        615 NRF_RADIO->TASKS_TXEN = 1;
        +
        616 while (NRF_RADIO->EVENTS_TXREADY == 0) {
        +
        617 }
        +
        618 NRF_RADIO->EVENTS_TXREADY = 0;
        +
        619 }
        +
        620
        +
        621 NRF_RADIO->EVENTS_END = 0;
        +
        622 NRF_RADIO->TASKS_START = 1;
        +
        623 lastTxResult = true;
        +
        624
        +
        625 return true;
        +
        626}
        -
        625
        -
        626/**********************************************************************************************************/
        627
        -
        -
        628bool nrf_to_nrf::writeAckPayload(uint8_t pipe, void* buf, uint8_t len)
        -
        629{
        -
        630
        -
        631#if defined CCM_ENCRYPTION_ENABLED
        - -
        633 if (len) {
        -
        634
        -
        635 for (int i = 0; i < CCM_IV_SIZE; i++) {
        -
        636 while (!NRF_RNG->EVENTS_VALRDY) {
        -
        637 }
        -
        638 NRF_RNG->EVENTS_VALRDY = 0;
        -
        639 ccmData.iv[i] = NRF_RNG->VALUE;
        -
        640 ackBuffer[i + 1] = ccmData.iv[i];
        -
        641 }
        -
        642
        -
        643 ccmData.counter = packetCounter;
        -
        644 memcpy(&ackBuffer[1 + CCM_IV_SIZE], &ccmData.counter, CCM_COUNTER_SIZE);
        -
        645
        -
        646 if (!encrypt(buf, len)) {
        -
        647 return 0;
        -
        648 }
        -
        649
        - - -
        652 packetCounter++;
        -
        653 if (packetCounter > 200000) {
        -
        654 packetCounter = 0;
        -
        655 }
        -
        656 }
        -
        657 }else{
        -
        658#endif
        -
        659 memcpy(&ackBuffer[1], buf, len);
        -
        660#if defined CCM_ENCRYPTION_ENABLED
        -
        661 }
        -
        662#endif
        -
        663 ackBuffer[0] = len;
        -
        664 ackPipe = pipe;
        -
        665 return true;
        -
        666}
        +
        628/**********************************************************************************************************/
        +
        629
        +
        +
        630bool nrf_to_nrf::writeAckPayload(uint8_t pipe, void* buf, uint8_t len)
        +
        631{
        +
        632
        +
        633#if defined CCM_ENCRYPTION_ENABLED
        + +
        635 if (len) {
        +
        636
        +
        637 for (int i = 0; i < CCM_IV_SIZE; i++) {
        +
        638 while (!NRF_RNG->EVENTS_VALRDY) {
        +
        639 }
        +
        640 NRF_RNG->EVENTS_VALRDY = 0;
        +
        641 ccmData.iv[i] = NRF_RNG->VALUE;
        +
        642 ackBuffer[i + 1] = ccmData.iv[i];
        +
        643 }
        +
        644
        +
        645 ccmData.counter = packetCounter;
        +
        646 memcpy(&ackBuffer[1 + CCM_IV_SIZE], &ccmData.counter, CCM_COUNTER_SIZE);
        +
        647
        +
        648 if (!encrypt(buf, len)) {
        +
        649 return 0;
        +
        650 }
        +
        651
        + + +
        654 packetCounter++;
        +
        655 if (packetCounter > 200000) {
        +
        656 packetCounter = 0;
        +
        657 }
        +
        658 }
        +
        659 }else{
        +
        660#endif
        +
        661 memcpy(&ackBuffer[1], buf, len);
        +
        662#if defined CCM_ENCRYPTION_ENABLED
        +
        663 }
        +
        664#endif
        +
        665 ackBuffer[0] = len;
        +
        666 ackPipe = pipe;
        +
        667 return true;
        +
        668}
        -
        667
        -
        668/**********************************************************************************************************/
        669
        -
        670void nrf_to_nrf::enableAckPayload() { ackPayloadsEnabled = true; }
        +
        670/**********************************************************************************************************/
        671
        -
        672/**********************************************************************************************************/
        +
        672void nrf_to_nrf::enableAckPayload() { ackPayloadsEnabled = true; }
        673
        -
        674void nrf_to_nrf::disableAckPayload() { ackPayloadsEnabled = false; }
        +
        674/**********************************************************************************************************/
        675
        -
        676/**********************************************************************************************************/
        +
        676void nrf_to_nrf::disableAckPayload() { ackPayloadsEnabled = false; }
        677
        -
        -
        678void nrf_to_nrf::startListening(bool resetAddresses)
        -
        679{
        -
        680
        -
        681 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        682 NRF_RADIO->TASKS_DISABLE = 1;
        -
        683 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        -
        684 }
        -
        685 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        686 if (resetAddresses == true) {
        -
        687 // Serial.println("rst ad");
        -
        688 NRF_RADIO->BASE0 = rxBase;
        -
        689 NRF_RADIO->PREFIX0 = rxPrefix;
        -
        690 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        -
        691 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        -
        692 }
        -
        693 NRF_RADIO->EVENTS_RXREADY = 0;
        -
        694 NRF_RADIO->EVENTS_CRCOK = 0;
        -
        695 NRF_RADIO->TASKS_RXEN = 1;
        -
        696 inRxMode = true;
        -
        697}
        +
        678/**********************************************************************************************************/
        +
        679
        +
        +
        680void nrf_to_nrf::startListening(bool resetAddresses)
        +
        681{
        +
        682
        +
        683 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        684 NRF_RADIO->TASKS_DISABLE = 1;
        +
        685 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        +
        686 }
        +
        687 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        688 if (resetAddresses == true) {
        +
        689 // Serial.println("rst ad");
        +
        690 NRF_RADIO->BASE0 = rxBase;
        +
        691 NRF_RADIO->PREFIX0 = rxPrefix;
        +
        692 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        +
        693 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        +
        694 }
        +
        695 NRF_RADIO->EVENTS_RXREADY = 0;
        +
        696 NRF_RADIO->EVENTS_CRCOK = 0;
        +
        697 NRF_RADIO->TASKS_RXEN = 1;
        +
        698 inRxMode = true;
        +
        699}
        -
        698
        -
        699/**********************************************************************************************************/
        700
        -
        -
        701void nrf_to_nrf::stopListening(bool setWritingPipe, bool resetAddresses)
        -
        702{
        -
        703
        -
        704 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        705 NRF_RADIO->TASKS_DISABLE = 1;
        -
        706 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        -
        707 }
        -
        708 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        709 if (resetAddresses) {
        -
        710 NRF_RADIO->BASE0 = txBase;
        -
        711 NRF_RADIO->PREFIX0 = txPrefix;
        -
        712 }
        -
        713 if (setWritingPipe) {
        -
        714 NRF_RADIO->TXADDRESS = 0x00;
        -
        715 }
        -
        716 // NRF_RADIO->EVENTS_TXREADY = 0;
        -
        717 // NRF_RADIO->TASKS_TXEN = 1;
        -
        718 // while (NRF_RADIO->EVENTS_TXREADY == 0);
        -
        719 // NRF_RADIO->EVENTS_TXREADY = 0;
        -
        720 inRxMode = false;
        -
        721}
        +
        701/**********************************************************************************************************/
        +
        702
        +
        +
        703void nrf_to_nrf::stopListening(bool setWritingPipe, bool resetAddresses)
        +
        704{
        +
        705
        +
        706 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        707 NRF_RADIO->TASKS_DISABLE = 1;
        +
        708 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        +
        709 }
        +
        710 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        711 if (resetAddresses) {
        +
        712 NRF_RADIO->BASE0 = txBase;
        +
        713 NRF_RADIO->PREFIX0 = txPrefix;
        +
        714 }
        +
        715 if (setWritingPipe) {
        +
        716 NRF_RADIO->TXADDRESS = 0x00;
        +
        717 }
        +
        718 // NRF_RADIO->EVENTS_TXREADY = 0;
        +
        719 // NRF_RADIO->TASKS_TXEN = 1;
        +
        720 // while (NRF_RADIO->EVENTS_TXREADY == 0);
        +
        721 // NRF_RADIO->EVENTS_TXREADY = 0;
        +
        722 inRxMode = false;
        +
        723}
        -
        722
        -
        723/**********************************************************************************************************/
        724
        -
        - -
        726{
        -
        727 uint8_t size = min(staticPayloadSize, rxBuffer[0]);
        -
        728 return size;
        -
        729}
        +
        725/**********************************************************************************************************/
        +
        726
        +
        + +
        728{
        +
        729 uint8_t size = min(staticPayloadSize, rxBuffer[0]);
        +
        730 return size;
        +
        731}
        -
        730
        -
        731/**********************************************************************************************************/
        732
        -
        - -
        734{
        -
        735
        -
        736 uint32_t freq = NRF_RADIO->FREQUENCY;
        -
        737 NRF_RADIO->FREQUENCY = 0x4C;
        -
        738 if (NRF_RADIO->FREQUENCY == 0x4C) {
        -
        739 NRF_RADIO->FREQUENCY = freq;
        -
        740 return 1;
        -
        741 }
        -
        742 return 0;
        -
        743}
        +
        733/**********************************************************************************************************/
        +
        734
        +
        + +
        736{
        +
        737
        +
        738 uint32_t freq = NRF_RADIO->FREQUENCY;
        +
        739 NRF_RADIO->FREQUENCY = 0x4C;
        +
        740 if (NRF_RADIO->FREQUENCY == 0x4C) {
        +
        741 NRF_RADIO->FREQUENCY = freq;
        +
        742 return 1;
        +
        743 }
        +
        744 return 0;
        +
        745}
        -
        744
        -
        745/**********************************************************************************************************/
        746
        -
        747void nrf_to_nrf::setChannel(uint8_t channel) { NRF_RADIO->FREQUENCY = channel; }
        +
        747/**********************************************************************************************************/
        748
        -
        749/**********************************************************************************************************/
        +
        749void nrf_to_nrf::setChannel(uint8_t channel) { NRF_RADIO->FREQUENCY = channel; }
        750
        -
        751uint8_t nrf_to_nrf::getChannel() { return (uint8_t)NRF_RADIO->FREQUENCY; }
        +
        751/**********************************************************************************************************/
        752
        -
        753/**********************************************************************************************************/
        +
        753uint8_t nrf_to_nrf::getChannel() { return (uint8_t)NRF_RADIO->FREQUENCY; }
        754
        -
        -
        755void nrf_to_nrf::setAutoAck(bool enable)
        -
        756{
        -
        757
        -
        758 for (int i = 0; i < 8; i++) {
        -
        759 acksPerPipe[i] = enable;
        -
        760 }
        -
        761 if (!DPL) {
        -
        762 disableDynamicPayloads(); // Called to re-configure the PCNF0 register
        -
        763 }
        -
        764}
        +
        755/**********************************************************************************************************/
        +
        756
        +
        +
        757void nrf_to_nrf::setAutoAck(bool enable)
        +
        758{
        +
        759
        +
        760 for (int i = 0; i < 8; i++) {
        +
        761 acksPerPipe[i] = enable;
        +
        762 }
        +
        763 if (!DPL) {
        +
        764 disableDynamicPayloads(); // Called to re-configure the PCNF0 register
        +
        765 }
        +
        766}
        -
        765
        -
        766/**********************************************************************************************************/
        767
        -
        -
        768void nrf_to_nrf::setAutoAck(uint8_t pipe, bool enable)
        -
        769{
        -
        770
        -
        771 acksPerPipe[pipe] = enable;
        -
        772 if (!DPL) {
        -
        773 disableDynamicPayloads(); // Called to re-configure the PCNF0 register
        -
        774 }
        -
        775}
        +
        768/**********************************************************************************************************/
        +
        769
        +
        +
        770void nrf_to_nrf::setAutoAck(uint8_t pipe, bool enable)
        +
        771{
        +
        772
        +
        773 acksPerPipe[pipe] = enable;
        +
        774 if (!DPL) {
        +
        775 disableDynamicPayloads(); // Called to re-configure the PCNF0 register
        +
        776 }
        +
        777}
        -
        776
        -
        777/**********************************************************************************************************/
        778
        -
        -
        779void nrf_to_nrf::enableDynamicPayloads(uint8_t payloadSize)
        -
        780{
        -
        781
        -
        782 if (!DPL) {
        -
        783 DPL = true;
        -
        784 staticPayloadSize = payloadSize;
        -
        785
        -
        786 if (payloadSize <= 32) {
        -
        787 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (6 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
        -
        788 }
        -
        789 else {
        -
        790 // Using 8 bits for length
        -
        791 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (8 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
        -
        792 }
        -
        793 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (0 << RADIO_PCNF1_STATLEN_Pos) | (payloadSize << RADIO_PCNF1_MAXLEN_Pos);
        -
        794 }
        -
        795}
        +
        779/**********************************************************************************************************/
        +
        780
        +
        +
        781void nrf_to_nrf::enableDynamicPayloads(uint8_t payloadSize)
        +
        782{
        +
        783
        +
        784 if (!DPL) {
        +
        785 DPL = true;
        +
        786 staticPayloadSize = payloadSize;
        +
        787
        +
        788 if (payloadSize <= 32) {
        +
        789 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (6 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
        +
        790 }
        +
        791 else {
        +
        792 // Using 8 bits for length
        +
        793 NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) | (8 << RADIO_PCNF0_LFLEN_Pos) | (3 << RADIO_PCNF0_S1LEN_Pos);
        +
        794 }
        +
        795 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (0 << RADIO_PCNF1_STATLEN_Pos) | (payloadSize << RADIO_PCNF1_MAXLEN_Pos);
        +
        796 }
        +
        797}
        -
        796
        -
        797/**********************************************************************************************************/
        798
        -
        - -
        800{
        -
        801 DPL = false;
        -
        802
        -
        803 uint8_t lenConfig = 0;
        -
        804 if (acksEnabled(0)) {
        -
        805 lenConfig = 1;
        -
        806 }
        -
        807 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
        -
        808
        -
        809 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        -
        810}
        +
        799/**********************************************************************************************************/
        +
        800
        +
        + +
        802{
        +
        803 DPL = false;
        +
        804
        +
        805 uint8_t lenConfig = 0;
        +
        806 if (acksEnabled(0)) {
        +
        807 lenConfig = 1;
        +
        808 }
        +
        809 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
        +
        810
        +
        811 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        +
        812}
        -
        811
        -
        812/**********************************************************************************************************/
        813
        -
        - -
        815{
        -
        816 staticPayloadSize = size;
        -
        817 DPL = false;
        -
        818
        -
        819 uint8_t lenConfig = 0;
        -
        820 if (acksEnabled(0)) {
        -
        821 lenConfig = 1;
        -
        822 }
        -
        823 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
        -
        824
        -
        825 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        -
        826}
        +
        814/**********************************************************************************************************/
        +
        815
        +
        + +
        817{
        +
        818 staticPayloadSize = size;
        +
        819 DPL = false;
        +
        820
        +
        821 uint8_t lenConfig = 0;
        +
        822 if (acksEnabled(0)) {
        +
        823 lenConfig = 1;
        +
        824 }
        +
        825 NRF_RADIO->PCNF0 = (lenConfig << RADIO_PCNF0_S0LEN_Pos) | (0 << RADIO_PCNF0_LFLEN_Pos) | (lenConfig << RADIO_PCNF0_S1LEN_Pos);
        +
        826
        +
        827 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((addressWidth - 1) << RADIO_PCNF1_BALEN_Pos) | (staticPayloadSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        +
        828}
        -
        827
        -
        828/**********************************************************************************************************/
        829
        -
        - -
        831{
        -
        832 return staticPayloadSize;
        -
        833}
        +
        830/**********************************************************************************************************/
        +
        831
        +
        + +
        833{
        +
        834 return staticPayloadSize;
        +
        835}
        -
        834
        -
        835/**********************************************************************************************************/
        836
        -
        -
        837void nrf_to_nrf::setRetries(uint8_t retryVar, uint8_t attempts)
        -
        838{
        -
        839
        -
        840 retries = attempts;
        -
        841 retryDuration = retryVar;
        -
        842}
        +
        837/**********************************************************************************************************/
        +
        838
        +
        +
        839void nrf_to_nrf::setRetries(uint8_t retryVar, uint8_t attempts)
        +
        840{
        +
        841
        +
        842 retries = attempts;
        +
        843 retryDuration = retryVar;
        +
        844}
        -
        843
        -
        844/**********************************************************************************************************/
        845
        -
        -
        846void nrf_to_nrf::openReadingPipe(uint8_t child, uint64_t address)
        -
        847{
        -
        848
        -
        849 // child += 1;
        -
        850 uint32_t base = address >> 8;
        -
        851 uint32_t prefix = address & 0xFF;
        -
        852
        -
        853 base = addrConv32(base);
        +
        846/**********************************************************************************************************/
        +
        847
        +
        +
        848void nrf_to_nrf::openReadingPipe(uint8_t child, uint64_t address)
        +
        849{
        +
        850
        +
        851 // child += 1;
        +
        852 uint32_t base = address >> 8;
        +
        853 uint32_t prefix = address & 0xFF;
        854
        -
        855 prefix = addrConv32(address);
        -
        856 prefix = prefix >> 24;
        -
        857
        -
        858 if (!child) {
        -
        859 NRF_RADIO->PREFIX0 = rxPrefix;
        -
        860 NRF_RADIO->BASE0 = base;
        -
        861 NRF_RADIO->PREFIX0 &= ~(0xFF);
        -
        862 NRF_RADIO->PREFIX0 |= prefix;
        -
        863 rxBase = NRF_RADIO->BASE0;
        -
        864 rxPrefix = NRF_RADIO->PREFIX0;
        -
        865 }
        -
        866 else if (child < 4) { // prefixes AP1-3 are in prefix0
        -
        867 NRF_RADIO->PREFIX0 = rxPrefix;
        -
        868 NRF_RADIO->BASE1 = base;
        -
        869 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
        -
        870 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
        -
        871 rxPrefix = NRF_RADIO->PREFIX0;
        -
        872 }
        -
        873 else {
        -
        874 NRF_RADIO->BASE1 = base;
        -
        875 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
        -
        876 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
        -
        877 }
        -
        878 NRF_RADIO->RXADDRESSES |= 1 << child;
        -
        879
        -
        880 // Serial.println(addrConv32(NRF_RADIO->BASE1),HEX);
        -
        881 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        -
        882 // Serial.println(NRF_RADIO->RXADDRESSES);
        -
        883}
        +
        855 base = addrConv32(base);
        +
        856
        +
        857 prefix = addrConv32(address);
        +
        858 prefix = prefix >> 24;
        +
        859
        +
        860 if (!child) {
        +
        861 NRF_RADIO->PREFIX0 = rxPrefix;
        +
        862 NRF_RADIO->BASE0 = base;
        +
        863 NRF_RADIO->PREFIX0 &= ~(0xFF);
        +
        864 NRF_RADIO->PREFIX0 |= prefix;
        +
        865 rxBase = NRF_RADIO->BASE0;
        +
        866 rxPrefix = NRF_RADIO->PREFIX0;
        +
        867 }
        +
        868 else if (child < 4) { // prefixes AP1-3 are in prefix0
        +
        869 NRF_RADIO->PREFIX0 = rxPrefix;
        +
        870 NRF_RADIO->BASE1 = base;
        +
        871 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
        +
        872 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
        +
        873 rxPrefix = NRF_RADIO->PREFIX0;
        +
        874 }
        +
        875 else {
        +
        876 NRF_RADIO->BASE1 = base;
        +
        877 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
        +
        878 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
        +
        879 }
        +
        880 NRF_RADIO->RXADDRESSES |= 1 << child;
        +
        881
        +
        882 // Serial.println(addrConv32(NRF_RADIO->BASE1),HEX);
        +
        883 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        +
        884 // Serial.println(NRF_RADIO->RXADDRESSES);
        +
        885}
        -
        884
        -
        885/**********************************************************************************************************/
        886
        -
        -
        887void nrf_to_nrf::openWritingPipe(uint64_t address)
        -
        888{
        -
        889 uint32_t base = address >> 8;
        -
        890 uint32_t prefix = address & 0xFF;
        -
        891 base = addrConv32(base);
        -
        892
        -
        893 prefix = addrConv32(address);
        -
        894 prefix = prefix >> 24;
        -
        895
        -
        896 NRF_RADIO->BASE0 = base;
        -
        897 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
        -
        898 NRF_RADIO->PREFIX0 |= prefix;
        -
        899 NRF_RADIO->TXADDRESS = 0x00;
        -
        900 txBase = NRF_RADIO->BASE0;
        -
        901 txPrefix = NRF_RADIO->PREFIX0;
        -
        902 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        -
        903 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        -
        904}
        +
        887/**********************************************************************************************************/
        +
        888
        +
        +
        889void nrf_to_nrf::openWritingPipe(uint64_t address)
        +
        890{
        +
        891 uint32_t base = address >> 8;
        +
        892 uint32_t prefix = address & 0xFF;
        +
        893 base = addrConv32(base);
        +
        894
        +
        895 prefix = addrConv32(address);
        +
        896 prefix = prefix >> 24;
        +
        897
        +
        898 NRF_RADIO->BASE0 = base;
        +
        899 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
        +
        900 NRF_RADIO->PREFIX0 |= prefix;
        +
        901 NRF_RADIO->TXADDRESS = 0x00;
        +
        902 txBase = NRF_RADIO->BASE0;
        +
        903 txPrefix = NRF_RADIO->PREFIX0;
        +
        904 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        +
        905 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        +
        906}
        -
        905
        -
        906/**********************************************************************************************************/
        907
        -
        -
        908void nrf_to_nrf::openReadingPipe(uint8_t child, const uint8_t* address)
        -
        909{
        -
        910
        -
        911 // child +=1;
        +
        908/**********************************************************************************************************/
        +
        909
        +
        +
        910void nrf_to_nrf::openReadingPipe(uint8_t child, const uint8_t* address)
        +
        911{
        912
        -
        913 uint32_t base = addr_conv(&address[1]);
        -
        914 uint32_t prefix = 0;
        -
        915 uint8_t prefixArray[5];
        -
        916 prefixArray[0] = address[0];
        -
        917 prefix = addr_conv(prefixArray);
        -
        918 prefix = prefix >> 24;
        -
        919
        -
        920 // Using pipes 1-7 for reading pipes, leaving pipe0 for a tx pipe
        -
        921 if (!child) {
        -
        922 NRF_RADIO->PREFIX0 = rxPrefix;
        -
        923 NRF_RADIO->BASE0 = base;
        -
        924 NRF_RADIO->PREFIX0 &= ~(0xFF);
        -
        925 NRF_RADIO->PREFIX0 |= prefix;
        -
        926 rxBase = NRF_RADIO->BASE0;
        -
        927 rxPrefix = NRF_RADIO->PREFIX0;
        -
        928 }
        -
        929 else if (child < 4) { // prefixes AP1-3 are in prefix0
        -
        930 NRF_RADIO->PREFIX0 = rxPrefix;
        -
        931 NRF_RADIO->BASE1 = base;
        -
        932 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
        -
        933 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
        -
        934 rxPrefix = NRF_RADIO->PREFIX0;
        -
        935 }
        -
        936 else {
        -
        937 NRF_RADIO->BASE1 = base;
        -
        938 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
        -
        939 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
        -
        940 }
        -
        941 NRF_RADIO->RXADDRESSES |= 1 << child;
        -
        942
        -
        943 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        -
        944 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        -
        945 // Serial.println(NRF_RADIO->RXADDRESSES);
        -
        946}
        +
        913 // child +=1;
        +
        914
        +
        915 uint32_t base = addr_conv(&address[1]);
        +
        916 uint32_t prefix = 0;
        +
        917 uint8_t prefixArray[5];
        +
        918 prefixArray[0] = address[0];
        +
        919 prefix = addr_conv(prefixArray);
        +
        920 prefix = prefix >> 24;
        +
        921
        +
        922 // Using pipes 1-7 for reading pipes, leaving pipe0 for a tx pipe
        +
        923 if (!child) {
        +
        924 NRF_RADIO->PREFIX0 = rxPrefix;
        +
        925 NRF_RADIO->BASE0 = base;
        +
        926 NRF_RADIO->PREFIX0 &= ~(0xFF);
        +
        927 NRF_RADIO->PREFIX0 |= prefix;
        +
        928 rxBase = NRF_RADIO->BASE0;
        +
        929 rxPrefix = NRF_RADIO->PREFIX0;
        +
        930 }
        +
        931 else if (child < 4) { // prefixes AP1-3 are in prefix0
        +
        932 NRF_RADIO->PREFIX0 = rxPrefix;
        +
        933 NRF_RADIO->BASE1 = base;
        +
        934 NRF_RADIO->PREFIX0 &= ~(0xFF << (8 * child));
        +
        935 NRF_RADIO->PREFIX0 |= prefix << (8 * child);
        +
        936 rxPrefix = NRF_RADIO->PREFIX0;
        +
        937 }
        +
        938 else {
        +
        939 NRF_RADIO->BASE1 = base;
        +
        940 NRF_RADIO->PREFIX1 &= ~(0xFF << (8 * (child - 4)));
        +
        941 NRF_RADIO->PREFIX1 |= prefix << (8 * (child - 4));
        +
        942 }
        +
        943 NRF_RADIO->RXADDRESSES |= 1 << child;
        +
        944
        +
        945 // Serial.println(addrConv32(NRF_RADIO->BASE0),HEX);
        +
        946 // Serial.println(addrConv32(NRF_RADIO->PREFIX0),HEX);
        +
        947 // Serial.println(NRF_RADIO->RXADDRESSES);
        +
        948}
        -
        947
        -
        948/**********************************************************************************************************/
        949
        -
        -
        950void nrf_to_nrf::openWritingPipe(const uint8_t* address)
        -
        951{
        -
        952
        -
        953 uint32_t base = 0;
        -
        954 uint32_t prefix = 0;
        -
        955
        -
        956 base = addr_conv(&address[1]);
        -
        957 prefix = addr_conv(&address[0]);
        -
        958 prefix = prefix >> 24;
        -
        959
        -
        960 NRF_RADIO->BASE0 = base;
        -
        961 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
        -
        962 NRF_RADIO->PREFIX0 |= prefix;
        -
        963 NRF_RADIO->TXADDRESS = 0x00;
        -
        964 txBase = NRF_RADIO->BASE0;
        -
        965 txPrefix = NRF_RADIO->PREFIX0;
        -
        966}
        +
        950/**********************************************************************************************************/
        +
        951
        +
        +
        952void nrf_to_nrf::openWritingPipe(const uint8_t* address)
        +
        953{
        +
        954
        +
        955 uint32_t base = 0;
        +
        956 uint32_t prefix = 0;
        +
        957
        +
        958 base = addr_conv(&address[1]);
        +
        959 prefix = addr_conv(&address[0]);
        +
        960 prefix = prefix >> 24;
        +
        961
        +
        962 NRF_RADIO->BASE0 = base;
        +
        963 NRF_RADIO->PREFIX0 &= 0xFFFFFF00;
        +
        964 NRF_RADIO->PREFIX0 |= prefix;
        +
        965 NRF_RADIO->TXADDRESS = 0x00;
        +
        966 txBase = NRF_RADIO->BASE0;
        +
        967 txPrefix = NRF_RADIO->PREFIX0;
        +
        968}
        -
        967
        -
        968/**********************************************************************************************************/
        969
        -
        - +
        970/**********************************************************************************************************/
        971
        -
        972 if(NRF_RADIO->STATE == 11){
        -
        973 while (NRF_RADIO->EVENTS_END == 0) {}
        -
        974 NRF_RADIO->EVENTS_END = 0;
        -
        975 }
        -
        976
        -
        977 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        978 NRF_RADIO->TASKS_DISABLE = 1;
        -
        979 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        -
        980 }
        -
        981 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        982
        -
        983 return lastTxResult;
        -
        984}
        +
        + +
        973
        +
        974 if(NRF_RADIO->STATE == 11){
        +
        975 while (NRF_RADIO->EVENTS_END == 0) {}
        +
        976 NRF_RADIO->EVENTS_END = 0;
        +
        977 }
        +
        978
        +
        979 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        980 NRF_RADIO->TASKS_DISABLE = 1;
        +
        981 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        +
        982 }
        +
        983 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        984
        +
        985 return lastTxResult;
        +
        986}
        -
        985
        -
        986/**********************************************************************************************************/
        987
        -
        -
        988bool nrf_to_nrf::txStandBy(uint32_t timeout, bool startTx)
        -
        989{
        -
        990
        -
        991 if(NRF_RADIO->STATE == 11){
        -
        992 while (NRF_RADIO->EVENTS_END == 0) {}
        -
        993 NRF_RADIO->EVENTS_END = 0;
        -
        994 }
        -
        995
        -
        996 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        997 NRF_RADIO->TASKS_DISABLE = 1;
        -
        998 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        -
        999 }
        -
        1000 NRF_RADIO->EVENTS_DISABLED = 0;
        -
        1001
        -
        1002 return lastTxResult;
        -
        1003}
        +
        988/**********************************************************************************************************/
        +
        989
        +
        +
        990bool nrf_to_nrf::txStandBy(uint32_t timeout, bool startTx)
        +
        991{
        +
        992
        +
        993 if(NRF_RADIO->STATE == 11){
        +
        994 while (NRF_RADIO->EVENTS_END == 0) {}
        +
        995 NRF_RADIO->EVENTS_END = 0;
        +
        996 }
        +
        997
        +
        998 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        999 NRF_RADIO->TASKS_DISABLE = 1;
        +
        1000 while (NRF_RADIO->EVENTS_DISABLED == 0) {
        +
        1001 }
        +
        1002 NRF_RADIO->EVENTS_DISABLED = 0;
        +
        1003
        +
        1004 return lastTxResult;
        +
        1005}
        -
        1004
        -
        1005/**********************************************************************************************************/
        1006
        -
        -
        1007bool nrf_to_nrf::writeFast(void* buf, uint8_t len, bool multicast)
        -
        1008{
        -
        1009 lastTxResult = write((void*)buf, len, multicast);
        -
        1010 return lastTxResult;
        -
        1011}
        +
        1007/**********************************************************************************************************/
        +
        1008
        +
        +
        1009bool nrf_to_nrf::writeFast(void* buf, uint8_t len, bool multicast)
        +
        1010{
        +
        1011 lastTxResult = write((void*)buf, len, multicast);
        +
        1012 return lastTxResult;
        +
        1013}
        -
        1012
        -
        1013/**********************************************************************************************************/
        1014
        -
        1015bool nrf_to_nrf::acksEnabled(uint8_t pipe)
        -
        1016{
        -
        1017
        -
        1018 if (acksPerPipe[pipe]) {
        -
        1019 return 1;
        -
        1020 }
        -
        1021 return 0;
        -
        1022}
        -
        1023
        -
        1024/**********************************************************************************************************/
        +
        1015/**********************************************************************************************************/
        +
        1016
        +
        1017bool nrf_to_nrf::acksEnabled(uint8_t pipe)
        +
        1018{
        +
        1019
        +
        1020 if (acksPerPipe[pipe]) {
        +
        1021 return 1;
        +
        1022 }
        +
        1023 return 0;
        +
        1024}
        1025
        - +
        1026/**********************************************************************************************************/
        1027
        -
        1028/**********************************************************************************************************/
        +
        1029
        -
        -
        1030bool nrf_to_nrf::setDataRate(uint8_t speed)
        -
        1031{
        -
        1032
        -
        1033 if (!speed) {
        -
        1034 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
        -
        1035 ackTimeout = ACK_TIMEOUT_1MBPS;
        -
        1036 }
        -
        1037 else {
        -
        1038 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos);
        -
        1039 ackTimeout = ACK_TIMEOUT_2MBPS;
        -
        1040 }
        -
        1041 return 1;
        -
        1042}
        +
        1030/**********************************************************************************************************/
        +
        1031
        +
        +
        1032bool nrf_to_nrf::setDataRate(uint8_t speed)
        +
        1033{
        +
        1034
        +
        1035 if (!speed) {
        +
        1036 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos);
        +
        1037 ackTimeout = ACK_TIMEOUT_1MBPS;
        +
        1038 }
        +
        1039 else {
        +
        1040 NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos);
        +
        1041 ackTimeout = ACK_TIMEOUT_2MBPS;
        +
        1042 }
        +
        1043 return 1;
        +
        1044}
        -
        1043
        -
        1044/**********************************************************************************************************/
        1045
        -
        -
        1046void nrf_to_nrf::setPALevel(uint8_t level, bool lnaEnable)
        -
        1047{
        -
        1048
        -
        1049 uint8_t paLevel = 0x00;
        +
        1046/**********************************************************************************************************/
        +
        1047
        +
        +
        1048void nrf_to_nrf::setPALevel(uint8_t level, bool lnaEnable)
        +
        1049{
        1050
        -
        1051 if (level == 0) {
        -
        1052 paLevel = 0xF4;
        -
        1053 }
        -
        1054 else if (level == 1) {
        -
        1055 paLevel = 0x2;
        -
        1056 }
        -
        1057 else if (level == 2) {
        -
        1058 paLevel = 0x6;
        -
        1059 }
        -
        1060 else if (level == 3) {
        -
        1061 paLevel = 0x8;
        -
        1062 }
        -
        1063 NRF_RADIO->TXPOWER = paLevel;
        -
        1064}
        +
        1051 uint8_t paLevel = 0x00;
        +
        1052
        +
        1053 if (level == 0) {
        +
        1054 paLevel = 0xF4;
        +
        1055 }
        +
        1056 else if (level == 1) {
        +
        1057 paLevel = 0x2;
        +
        1058 }
        +
        1059 else if (level == 2) {
        +
        1060 paLevel = 0x6;
        +
        1061 }
        +
        1062 else if (level == 3) {
        +
        1063 paLevel = 0x8;
        +
        1064 }
        +
        1065 NRF_RADIO->TXPOWER = paLevel;
        +
        1066}
        -
        1065
        -
        1066/**********************************************************************************************************/
        1067
        -
        - -
        1069{
        -
        1070
        -
        1071 uint8_t paLevel = NRF_RADIO->TXPOWER;
        +
        1068/**********************************************************************************************************/
        +
        1069
        +
        + +
        1071{
        1072
        -
        1073 if (paLevel == 0xF4) {
        -
        1074 return 0;
        -
        1075 }
        -
        1076 else if (paLevel == 0x2) {
        -
        1077 return 1;
        -
        1078 }
        -
        1079 else if (paLevel == 0x6) {
        -
        1080 return 2;
        -
        1081 }
        -
        1082 else if (paLevel == 0x8) {
        -
        1083 return 3;
        -
        1084 }
        -
        1085 else {
        -
        1086 return 4;
        -
        1087 }
        -
        1088}
        +
        1073 uint8_t paLevel = NRF_RADIO->TXPOWER;
        +
        1074
        +
        1075 if (paLevel == 0xF4) {
        +
        1076 return 0;
        +
        1077 }
        +
        1078 else if (paLevel == 0x2) {
        +
        1079 return 1;
        +
        1080 }
        +
        1081 else if (paLevel == 0x6) {
        +
        1082 return 2;
        +
        1083 }
        +
        1084 else if (paLevel == 0x8) {
        +
        1085 return 3;
        +
        1086 }
        +
        1087 else {
        +
        1088 return 4;
        +
        1089 }
        +
        1090}
        -
        1089
        -
        1090/**********************************************************************************************************/
        1091
        -
        - -
        1093{
        -
        1094 return ARC;
        -
        1095}
        +
        1092/**********************************************************************************************************/
        +
        1093
        +
        + +
        1095{
        +
        1096 return ARC;
        +
        1097}
        -
        1096
        -
        1097/**********************************************************************************************************/
        1098
        -
        - -
        1100{
        -
        1101
        -
        1102 if (length == NRF_CRC_16) {
        -
        1103 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two; /* CRC configuration: 16bit */
        -
        1104 NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
        -
        1105 NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
        -
        1106 }
        -
        1107 else if (length == NRF_CRC_8) {
        -
        1108 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_One; /* CRC configuration: 8bit */
        -
        1109 NRF_RADIO->CRCINIT = 0xFFUL;
        -
        1110 NRF_RADIO->CRCPOLY = 0x107UL;
        -
        1111 }
        -
        1112 else {
        -
        1113 NRF_RADIO->CRCCNF = 0; /* CRC configuration: Disabled */
        -
        1114 NRF_RADIO->CRCINIT = 0x00L;
        -
        1115 NRF_RADIO->CRCPOLY = 0x00UL;
        -
        1116 }
        -
        1117}
        +
        1099/**********************************************************************************************************/
        +
        1100
        +
        + +
        1102{
        +
        1103
        +
        1104 if (length == NRF_CRC_16) {
        +
        1105 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_Two; /* CRC configuration: 16bit */
        +
        1106 NRF_RADIO->CRCINIT = 0xFFFFUL; // Initial value
        +
        1107 NRF_RADIO->CRCPOLY = 0x11021UL; // CRC poly: x^16+x^12^x^5+1
        +
        1108 }
        +
        1109 else if (length == NRF_CRC_8) {
        +
        1110 NRF_RADIO->CRCCNF = RADIO_CRCCNF_LEN_One; /* CRC configuration: 8bit */
        +
        1111 NRF_RADIO->CRCINIT = 0xFFUL;
        +
        1112 NRF_RADIO->CRCPOLY = 0x107UL;
        +
        1113 }
        +
        1114 else {
        +
        1115 NRF_RADIO->CRCCNF = 0; /* CRC configuration: Disabled */
        +
        1116 NRF_RADIO->CRCINIT = 0x00L;
        +
        1117 NRF_RADIO->CRCPOLY = 0x00UL;
        +
        1118 }
        +
        1119}
        -
        1118
        -
        1119/**********************************************************************************************************/
        1120
        -
        - -
        1122{
        -
        1123 if (NRF_RADIO->CRCCNF == 0) {
        -
        1124 return NRF_CRC_DISABLED;
        -
        1125 }
        -
        1126 else if (NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) {
        -
        1127 return NRF_CRC_8;
        -
        1128 }
        -
        1129 else {
        -
        1130 return NRF_CRC_16;
        -
        1131 }
        -
        1132}
        +
        1121/**********************************************************************************************************/
        +
        1122
        +
        + +
        1124{
        +
        1125 if (NRF_RADIO->CRCCNF == 0) {
        +
        1126 return NRF_CRC_DISABLED;
        +
        1127 }
        +
        1128 else if (NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) {
        +
        1129 return NRF_CRC_8;
        +
        1130 }
        +
        1131 else {
        +
        1132 return NRF_CRC_16;
        +
        1133 }
        +
        1134}
        -
        1133
        -
        1134/**********************************************************************************************************/
        1135
        -
        -
        1136bool nrf_to_nrf::testCarrier(uint8_t RSSI)
        -
        1137{
        -
        1138
        -
        1139 NRF_RADIO->EVENTS_RSSIEND = 0;
        -
        1140 NRF_RADIO->TASKS_RSSISTART = 1;
        -
        1141 while (!NRF_RADIO->EVENTS_RSSIEND) {
        -
        1142 }
        -
        1143 if (NRF_RADIO->RSSISAMPLE < RSSI) {
        -
        1144 return 1;
        -
        1145 }
        -
        1146 return 0;
        -
        1147}
        +
        1136/**********************************************************************************************************/
        +
        1137
        +
        +
        1138bool nrf_to_nrf::testCarrier(uint8_t RSSI)
        +
        1139{
        +
        1140
        +
        1141 NRF_RADIO->EVENTS_RSSIEND = 0;
        +
        1142 NRF_RADIO->TASKS_RSSISTART = 1;
        +
        1143 while (!NRF_RADIO->EVENTS_RSSIEND) {
        +
        1144 }
        +
        1145 if (NRF_RADIO->RSSISAMPLE < RSSI) {
        +
        1146 return 1;
        +
        1147 }
        +
        1148 return 0;
        +
        1149}
        -
        1148
        -
        1149/**********************************************************************************************************/
        1150
        -
        -
        1151bool nrf_to_nrf::testRPD(uint8_t RSSI)
        -
        1152{
        -
        1153 return testCarrier(RSSI);
        -
        1154}
        +
        1151/**********************************************************************************************************/
        +
        1152
        +
        +
        1153bool nrf_to_nrf::testRPD(uint8_t RSSI)
        +
        1154{
        +
        1155 return testCarrier(RSSI);
        +
        1156}
        -
        1155
        -
        1156/**********************************************************************************************************/
        1157
        -
        - -
        1159{
        -
        1160 radioConfigured = false;
        -
        1161 begin();
        -
        1162}
        +
        1158/**********************************************************************************************************/
        +
        1159
        +
        + +
        1161{
        +
        1162 radioConfigured = false;
        +
        1163 begin();
        +
        1164}
        -
        1163
        -
        1164/**********************************************************************************************************/
        1165
        -
        - -
        1167{
        -
        1168 DPL = false;
        -
        1169 NRF_RADIO->POWER = 0;
        -
        1170}
        +
        1166/**********************************************************************************************************/
        +
        1167
        +
        + +
        1169{
        +
        1170 DPL = false;
        +
        1171 NRF_RADIO->POWER = 0;
        +
        1172}
        -
        1171
        -
        1172/**********************************************************************************************************/
        -
        -
        1173void nrf_to_nrf::setAddressWidth(uint8_t a_width)
        -
        1174{
        -
        1175
        -
        1176 addressWidth = a_width;
        +
        1173
        +
        1174/**********************************************************************************************************/
        +
        +
        1175void nrf_to_nrf::setAddressWidth(uint8_t a_width)
        +
        1176{
        1177
        -
        1178 uint8_t pSize = 0;
        -
        1179 if (!DPL) {
        -
        1180 pSize = staticPayloadSize;
        -
        1181 }
        -
        1182
        -
        1183 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        -
        1184}
        +
        1178 addressWidth = a_width;
        +
        1179
        +
        1180 uint8_t pSize = 0;
        +
        1181 if (!DPL) {
        +
        1182 pSize = staticPayloadSize;
        +
        1183 }
        +
        1184
        +
        1185 NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) | (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) | ((a_width - 1) << RADIO_PCNF1_BALEN_Pos) | (pSize << RADIO_PCNF1_STATLEN_Pos) | (staticPayloadSize << RADIO_PCNF1_MAXLEN_Pos);
        +
        1186}
        -
        1185
        -
        1186/**********************************************************************************************************/
        1187
        -
        - -
        1189{
        -
        1190
        -
        1191 Serial.println("================ Radio Configuration ================");
        -
        1192 Serial.print("STATUS\t\t= ");
        -
        1193 Serial.println(NRF_RADIO->STATE);
        -
        1194
        -
        1195 // Serial.println(addrConv32(NRF_RADIO->PREFIX0);
        -
        1196 Serial.print("RX_ADDR_P0-1\t= 0x");
        -
        1197 uint32_t base = addrConv32(NRF_RADIO->BASE0);
        -
        1198 for (int i = addressWidth - 2; i > -1; i--) {
        -
        1199 Serial.print((base >> (i * 8)) & 0xFF, HEX);
        -
        1200 }
        -
        1201 uint32_t prefixes = addrConv32(NRF_RADIO->PREFIX0);
        -
        1202 uint8_t prefix = (prefixes >> 24) & 0xFF;
        -
        1203 Serial.print(prefix, HEX);
        -
        1204 Serial.print(" 0x");
        -
        1205 base = addrConv32(NRF_RADIO->BASE1);
        -
        1206 for (int i = addressWidth - 2; i > -1; i--) {
        -
        1207 Serial.print((base >> (i * 8)) & 0xFF, HEX);
        -
        1208 }
        -
        1209 prefix = (prefixes >> 16) & 0xFF;
        -
        1210 Serial.println(prefix, HEX);
        -
        1211
        -
        1212 Serial.print("RX_ADDR_P2-7\t= 0x");
        -
        1213 prefix = (prefixes >> 8) & 0xFF;
        -
        1214 Serial.print(prefix, HEX);
        -
        1215 Serial.print(" 0x");
        -
        1216 prefix = (prefixes)&0xFF;
        -
        1217 Serial.print(prefix, HEX);
        -
        1218 Serial.print(" 0x");
        -
        1219 prefixes = addrConv32(NRF_RADIO->PREFIX1);
        -
        1220 prefix = (prefixes >> 24) & 0xFF;
        -
        1221 Serial.print(prefix, HEX);
        -
        1222 Serial.print(" 0x");
        -
        1223 prefix = (prefixes >> 16) & 0xFF;
        -
        1224 Serial.print(prefix, HEX);
        -
        1225 Serial.print(" 0x");
        -
        1226 prefix = (prefixes >> 8) & 0xFF;
        -
        1227 Serial.print(prefix, HEX);
        -
        1228 Serial.print(" 0x");
        -
        1229 prefix = (prefixes)&0xFF;
        -
        1230 Serial.println(prefix, HEX);
        -
        1231
        -
        1232 uint8_t enAA = 0;
        -
        1233 for (int i = 0; i < 6; i++) {
        -
        1234 enAA |= acksPerPipe[i] << i;
        -
        1235 }
        -
        1236 Serial.print("EN_AA\t\t= 0x");
        -
        1237 Serial.println(enAA, HEX);
        -
        1238 Serial.print("EN_RXADDR\t= 0x");
        -
        1239 Serial.println(NRF_RADIO->RXADDRESSES, HEX);
        -
        1240 Serial.print("RF_CH\t\t= 0x");
        -
        1241 Serial.println(NRF_RADIO->FREQUENCY, HEX);
        -
        1242 Serial.println("DYNPD/FEATURE\t= 0x");
        -
        1243 Serial.print("Data Rate\t= ");
        -
        1244 Serial.println(NRF_RADIO->MODE ? "2 MBPS" : "1MBPS");
        -
        1245 Serial.println("Model\t\t= NRF52");
        -
        1246 Serial.print("CRC Length\t= ");
        -
        1247 uint8_t crcLen = getCRCLength();
        -
        1248 if (crcLen == NRF_CRC_16) {
        -
        1249 Serial.println("16 bits");
        -
        1250 }
        -
        1251 else if (crcLen == NRF_CRC_8) {
        -
        1252 Serial.println("8 bits");
        -
        1253 }
        -
        1254 else {
        -
        1255 Serial.println("Disabled");
        -
        1256 }
        -
        1257 Serial.print("PA Power\t= ");
        -
        1258 uint8_t paLevel = getPALevel();
        -
        1259 if (paLevel == NRF_PA_MAX) {
        -
        1260 Serial.println("PA_MAX");
        -
        1261 }
        -
        1262 else if (paLevel == NRF_PA_HIGH) {
        -
        1263 Serial.println("PA_HIGH");
        -
        1264 }
        -
        1265 else if (paLevel == NRF_PA_LOW) {
        -
        1266 Serial.println("PA_LOW");
        -
        1267 }
        -
        1268 else if (paLevel == NRF_PA_MIN) {
        -
        1269 Serial.println("PA_MIN");
        -
        1270 }
        -
        1271 else {
        -
        1272 Serial.println("?");
        -
        1273 }
        -
        1274 Serial.print("ARC\t\t= ");
        -
        1275 Serial.println(ARC);
        -
        1276}
        +
        1188/**********************************************************************************************************/
        +
        1189
        +
        + +
        1191{
        +
        1192
        +
        1193 Serial.println("================ Radio Configuration ================");
        +
        1194 Serial.print("STATUS\t\t= ");
        +
        1195 Serial.println(NRF_RADIO->STATE);
        +
        1196
        +
        1197 // Serial.println(addrConv32(NRF_RADIO->PREFIX0);
        +
        1198 Serial.print("RX_ADDR_P0-1\t= 0x");
        +
        1199 uint32_t base = addrConv32(NRF_RADIO->BASE0);
        +
        1200 for (int i = addressWidth - 2; i > -1; i--) {
        +
        1201 Serial.print((base >> (i * 8)) & 0xFF, HEX);
        +
        1202 }
        +
        1203 uint32_t prefixes = addrConv32(NRF_RADIO->PREFIX0);
        +
        1204 uint8_t prefix = (prefixes >> 24) & 0xFF;
        +
        1205 Serial.print(prefix, HEX);
        +
        1206 Serial.print(" 0x");
        +
        1207 base = addrConv32(NRF_RADIO->BASE1);
        +
        1208 for (int i = addressWidth - 2; i > -1; i--) {
        +
        1209 Serial.print((base >> (i * 8)) & 0xFF, HEX);
        +
        1210 }
        +
        1211 prefix = (prefixes >> 16) & 0xFF;
        +
        1212 Serial.println(prefix, HEX);
        +
        1213
        +
        1214 Serial.print("RX_ADDR_P2-7\t= 0x");
        +
        1215 prefix = (prefixes >> 8) & 0xFF;
        +
        1216 Serial.print(prefix, HEX);
        +
        1217 Serial.print(" 0x");
        +
        1218 prefix = (prefixes)&0xFF;
        +
        1219 Serial.print(prefix, HEX);
        +
        1220 Serial.print(" 0x");
        +
        1221 prefixes = addrConv32(NRF_RADIO->PREFIX1);
        +
        1222 prefix = (prefixes >> 24) & 0xFF;
        +
        1223 Serial.print(prefix, HEX);
        +
        1224 Serial.print(" 0x");
        +
        1225 prefix = (prefixes >> 16) & 0xFF;
        +
        1226 Serial.print(prefix, HEX);
        +
        1227 Serial.print(" 0x");
        +
        1228 prefix = (prefixes >> 8) & 0xFF;
        +
        1229 Serial.print(prefix, HEX);
        +
        1230 Serial.print(" 0x");
        +
        1231 prefix = (prefixes)&0xFF;
        +
        1232 Serial.println(prefix, HEX);
        +
        1233
        +
        1234 uint8_t enAA = 0;
        +
        1235 for (int i = 0; i < 6; i++) {
        +
        1236 enAA |= acksPerPipe[i] << i;
        +
        1237 }
        +
        1238 Serial.print("EN_AA\t\t= 0x");
        +
        1239 Serial.println(enAA, HEX);
        +
        1240 Serial.print("EN_RXADDR\t= 0x");
        +
        1241 Serial.println(NRF_RADIO->RXADDRESSES, HEX);
        +
        1242 Serial.print("RF_CH\t\t= 0x");
        +
        1243 Serial.println(NRF_RADIO->FREQUENCY, HEX);
        +
        1244 Serial.println("DYNPD/FEATURE\t= 0x");
        +
        1245 Serial.print("Data Rate\t= ");
        +
        1246 Serial.println(NRF_RADIO->MODE ? "2 MBPS" : "1MBPS");
        +
        1247 Serial.println("Model\t\t= NRF52");
        +
        1248 Serial.print("CRC Length\t= ");
        +
        1249 uint8_t crcLen = getCRCLength();
        +
        1250 if (crcLen == NRF_CRC_16) {
        +
        1251 Serial.println("16 bits");
        +
        1252 }
        +
        1253 else if (crcLen == NRF_CRC_8) {
        +
        1254 Serial.println("8 bits");
        +
        1255 }
        +
        1256 else {
        +
        1257 Serial.println("Disabled");
        +
        1258 }
        +
        1259 Serial.print("PA Power\t= ");
        +
        1260 uint8_t paLevel = getPALevel();
        +
        1261 if (paLevel == NRF_PA_MAX) {
        +
        1262 Serial.println("PA_MAX");
        +
        1263 }
        +
        1264 else if (paLevel == NRF_PA_HIGH) {
        +
        1265 Serial.println("PA_HIGH");
        +
        1266 }
        +
        1267 else if (paLevel == NRF_PA_LOW) {
        +
        1268 Serial.println("PA_LOW");
        +
        1269 }
        +
        1270 else if (paLevel == NRF_PA_MIN) {
        +
        1271 Serial.println("PA_MIN");
        +
        1272 }
        +
        1273 else {
        +
        1274 Serial.println("?");
        +
        1275 }
        +
        1276 Serial.print("ARC\t\t= ");
        +
        1277 Serial.println(ARC);
        +
        1278}
        -
        1277
        -
        1278/**********************************************************************************************************/
        1279
        -
        1280#if defined CCM_ENCRYPTION_ENABLED
        +
        1280/**********************************************************************************************************/
        1281
        -
        -
        1282uint8_t nrf_to_nrf::encrypt(void* bufferIn, uint8_t size)
        -
        1283{
        -
        1284
        -
        1285 if (!size) {
        -
        1286 return 0;
        -
        1287 }
        -
        1288 if (size > MAX_PACKET_SIZE) {
        -
        1289 return 0;
        -
        1290 }
        -
        1291
        -
        1292 inBuffer[0] = 0;
        -
        1293 inBuffer[1] = size;
        -
        1294 inBuffer[2] = 0;
        -
        1295
        -
        1296 memcpy(&inBuffer[CCM_START_SIZE], bufferIn, size);
        -
        1297 memset(outBuffer, 0, sizeof(outBuffer));
        -
        1298
        -
        1299 NRF_CCM->OUTPTR = (uint32_t)outBuffer;
        -
        1300 NRF_CCM->EVENTS_ENDKSGEN = 0;
        -
        1301 NRF_CCM->EVENTS_ENDCRYPT = 0;
        -
        1302 NRF_CCM->TASKS_KSGEN = 1;
        -
        1303 while (!NRF_CCM->EVENTS_ENDCRYPT) {
        -
        1304 };
        -
        1305
        -
        1306 if (NRF_CCM->EVENTS_ERROR) {
        -
        1307 return 0;
        -
        1308 }
        -
        1309 return outBuffer[1];
        -
        1310}
        +
        1282#if defined CCM_ENCRYPTION_ENABLED
        +
        1283
        +
        +
        1284uint8_t nrf_to_nrf::encrypt(void* bufferIn, uint8_t size)
        +
        1285{
        +
        1286
        +
        1287 if (!size) {
        +
        1288 return 0;
        +
        1289 }
        +
        1290 if (size > MAX_PACKET_SIZE) {
        +
        1291 return 0;
        +
        1292 }
        +
        1293
        +
        1294 inBuffer[0] = 0;
        +
        1295 inBuffer[1] = size;
        +
        1296 inBuffer[2] = 0;
        +
        1297
        +
        1298 memcpy(&inBuffer[CCM_START_SIZE], bufferIn, size);
        +
        1299 memset(outBuffer, 0, sizeof(outBuffer));
        +
        1300
        +
        1301 NRF_CCM->OUTPTR = (uint32_t)outBuffer;
        +
        1302 NRF_CCM->EVENTS_ENDKSGEN = 0;
        +
        1303 NRF_CCM->EVENTS_ENDCRYPT = 0;
        +
        1304 NRF_CCM->TASKS_KSGEN = 1;
        +
        1305 while (!NRF_CCM->EVENTS_ENDCRYPT) {
        +
        1306 };
        +
        1307
        +
        1308 if (NRF_CCM->EVENTS_ERROR) {
        +
        1309 return 0;
        +
        1310 }
        +
        1311 return outBuffer[1];
        +
        1312}
        -
        1311
        -
        1312/**********************************************************************************************************/
        1313
        -
        -
        1314uint8_t nrf_to_nrf::decrypt(void* bufferIn, uint8_t size)
        -
        1315{
        -
        1316
        -
        1317 if (!size) {
        -
        1318 return 0;
        -
        1319 }
        -
        1320 if (size > MAX_PACKET_SIZE) {
        -
        1321 return 0;
        -
        1322 }
        -
        1323
        -
        1324 memcpy(&inBuffer[3], bufferIn, size);
        +
        1314/**********************************************************************************************************/
        +
        1315
        +
        +
        1316uint8_t nrf_to_nrf::decrypt(void* bufferIn, uint8_t size)
        +
        1317{
        +
        1318
        +
        1319 if (!size) {
        +
        1320 return 0;
        +
        1321 }
        +
        1322 if (size > MAX_PACKET_SIZE) {
        +
        1323 return 0;
        +
        1324 }
        1325
        -
        1326 inBuffer[0] = 0;
        -
        1327 inBuffer[1] = size;
        -
        1328 inBuffer[2] = 0;
        -
        1329
        -
        1330 memset(outBuffer, 0, sizeof(outBuffer));
        +
        1326 memcpy(&inBuffer[3], bufferIn, size);
        +
        1327
        +
        1328 inBuffer[0] = 0;
        +
        1329 inBuffer[1] = size;
        +
        1330 inBuffer[2] = 0;
        1331
        -
        1332 NRF_CCM->EVENTS_ENDKSGEN = 0;
        -
        1333 NRF_CCM->EVENTS_ENDCRYPT = 0;
        -
        1334 NRF_CCM->TASKS_KSGEN = 1;
        -
        1335
        -
        1336 while (!NRF_CCM->EVENTS_ENDCRYPT) {
        -
        1337 };
        -
        1338
        -
        1339 if (NRF_CCM->EVENTS_ERROR) {
        -
        1340 return 0;
        -
        1341 }
        -
        1342 return outBuffer[1];
        -
        1343}
        +
        1332 memset(outBuffer, 0, sizeof(outBuffer));
        +
        1333
        +
        1334 NRF_CCM->EVENTS_ENDKSGEN = 0;
        +
        1335 NRF_CCM->EVENTS_ENDCRYPT = 0;
        +
        1336 NRF_CCM->TASKS_KSGEN = 1;
        +
        1337
        +
        1338 while (!NRF_CCM->EVENTS_ENDCRYPT) {
        +
        1339 };
        +
        1340
        +
        1341 if (NRF_CCM->EVENTS_ERROR) {
        +
        1342 return 0;
        +
        1343 }
        +
        1344 return outBuffer[1];
        +
        1345}
        -
        1344
        -
        1345/**********************************************************************************************************/
        1346
        -
        - -
        1348{
        -
        1349
        -
        1350 memcpy(ccmData.key, key, CCM_KEY_SIZE);
        -
        1351}
        +
        1347/**********************************************************************************************************/
        +
        1348
        +
        + +
        1350{
        +
        1351
        +
        1352 memcpy(ccmData.key, key, CCM_KEY_SIZE);
        +
        1353}
        -
        1352
        -
        1353/**********************************************************************************************************/
        1354
        -
        -
        1355void nrf_to_nrf::setCounter(uint64_t counter)
        -
        1356{
        -
        1357
        -
        1358 ccmData.counter = counter;
        -
        1359 packetCounter = counter;
        -
        1360}
        +
        1355/**********************************************************************************************************/
        +
        1356
        +
        +
        1357void nrf_to_nrf::setCounter(uint64_t counter)
        +
        1358{
        +
        1359
        +
        1360 ccmData.counter = counter;
        +
        1361 packetCounter = counter;
        +
        1362}
        -
        1361/**********************************************************************************************************/
        -
        1362
        -
        - +
        1363/**********************************************************************************************************/
        1364
        -
        1365 for(int i=0; i<CCM_IV_SIZE; i++){
        -
        1366 ccmData.iv[i] = IV[i];
        -
        1367 }
        -
        1368}
        +
        + +
        1366
        +
        1367 for(int i=0; i<CCM_IV_SIZE; i++){
        +
        1368 ccmData.iv[i] = IV[i];
        +
        1369 }
        +
        1370}
        -
        1369
        -
        1370
        -
        1371#endif // defined CCM_ENCRYPTION_ENABLED
        -
        void startListening(bool resetAddresses=true)
        -
        void openReadingPipe(uint8_t child, const uint8_t *address)
        - -
        bool available()
        -
        void setPALevel(uint8_t level, bool lnaEnable=true)
        -
        uint8_t sample_ed(void)
        -
        bool testCarrier(uint8_t RSSI=65)
        -
        bool txStandBy()
        -
        uint8_t decrypt(void *bufferIn, uint8_t size)
        +
        1371
        +
        1372
        +
        1373#endif // defined CCM_ENCRYPTION_ENABLED
        +
        void startListening(bool resetAddresses=true)
        +
        void openReadingPipe(uint8_t child, const uint8_t *address)
        + +
        bool available()
        +
        void setPALevel(uint8_t level, bool lnaEnable=true)
        +
        uint8_t sample_ed(void)
        +
        bool testCarrier(uint8_t RSSI=65)
        +
        bool txStandBy()
        +
        uint8_t decrypt(void *bufferIn, uint8_t size)
        uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
        Definition nrf_to_nrf.h:201
        -
        void setChannel(uint8_t channel)
        +
        void setChannel(uint8_t channel)
        uint32_t addrConv32(uint32_t addr)
        -
        void disableDynamicPayloads()
        -
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        -
        bool testRPD(uint8_t RSSI=65)
        -
        void setCounter(uint64_t counter)
        -
        bool isChipConnected()
        -
        void setAddressWidth(uint8_t a_width)
        -
        uint8_t getDynamicPayloadSize()
        -
        bool setDataRate(uint8_t speed)
        -
        bool isValid()
        +
        void disableDynamicPayloads()
        +
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        +
        bool testRPD(uint8_t RSSI=65)
        +
        void setCounter(uint64_t counter)
        +
        bool isChipConnected()
        +
        void setAddressWidth(uint8_t a_width)
        +
        uint8_t getDynamicPayloadSize()
        +
        bool setDataRate(uint8_t speed)
        +
        bool isValid()
        -
        void setKey(uint8_t key[CCM_KEY_SIZE])
        -
        bool begin()
        -
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        +
        void setKey(uint8_t key[CCM_KEY_SIZE])
        +
        bool begin()
        +
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        bool enableEncryption
        Definition nrf_to_nrf.h:459
        -
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        -
        void disableAckPayload()
        -
        void powerDown()
        -
        uint8_t getARC()
        -
        uint8_t encrypt(void *bufferIn, uint8_t size)
        -
        void printDetails()
        -
        uint8_t getChannel()
        -
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        +
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        +
        void disableAckPayload()
        +
        void powerDown()
        +
        uint8_t getARC()
        +
        uint8_t encrypt(void *bufferIn, uint8_t size)
        +
        void printDetails()
        +
        uint8_t getChannel()
        +
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
        Definition nrf_to_nrf.h:426
        -
        void setRetries(uint8_t retryVar, uint8_t attempts)
        -
        void enableAckPayload()
        -
        void openWritingPipe(const uint8_t *address)
        -
        void setCRCLength(nrf_crclength_e length)
        -
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        -
        uint8_t getPALevel()
        -
        void setAutoAck(bool enable)
        -
        void read(void *buf, uint8_t len)
        -
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        -
        void setIV(uint8_t IV[CCM_IV_SIZE])
        -
        void setPayloadSize(uint8_t size)
        -
        nrf_crclength_e getCRCLength()
        -
        uint8_t getPayloadSize()
        -
        #define ED_RSSISCALE
        +
        void setRetries(uint8_t retryVar, uint8_t attempts)
        +
        void enableAckPayload()
        +
        void openWritingPipe(const uint8_t *address)
        +
        void setCRCLength(nrf_crclength_e length)
        +
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        +
        uint8_t getPALevel()
        +
        void setAutoAck(bool enable)
        +
        void read(void *buf, uint8_t len)
        +
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        +
        void setIV(uint8_t IV[CCM_IV_SIZE])
        +
        void setPayloadSize(uint8_t size)
        +
        nrf_crclength_e getCRCLength()
        +
        uint8_t getPayloadSize()
        +
        #define ED_RSSISCALE
        static uint32_t bytewise_bit_swap(uint8_t const *p_inp)
        Definition nrf_to_nrf.cpp:8
        static uint32_t addr_conv(uint8_t const *p_addr)
        @@ -1648,7 +1650,7 @@
        diff --git a/html/nrf__to__nrf_8h.html b/html/nrf__to__nrf_8h.html index 67caa58..5a525ac 100644 --- a/html/nrf__to__nrf_8h.html +++ b/html/nrf__to__nrf_8h.html @@ -545,7 +545,7 @@

        diff --git a/html/nrf__to__nrf_8h_source.html b/html/nrf__to__nrf_8h_source.html index 47bf84c..4434d42 100644 --- a/html/nrf__to__nrf_8h_source.html +++ b/html/nrf__to__nrf_8h_source.html @@ -340,57 +340,57 @@
        507
        567#endif //__nrf52840_nrf24l01_H__
        Driver class for nRF52840 2.4GHz Wireless Transceiver.
        Definition nrf_to_nrf.h:109
        -
        void startListening(bool resetAddresses=true)
        -
        void openReadingPipe(uint8_t child, const uint8_t *address)
        - -
        bool available()
        -
        void setPALevel(uint8_t level, bool lnaEnable=true)
        -
        uint8_t sample_ed(void)
        -
        bool testCarrier(uint8_t RSSI=65)
        -
        bool txStandBy()
        -
        uint8_t decrypt(void *bufferIn, uint8_t size)
        +
        void startListening(bool resetAddresses=true)
        +
        void openReadingPipe(uint8_t child, const uint8_t *address)
        + +
        bool available()
        +
        void setPALevel(uint8_t level, bool lnaEnable=true)
        +
        uint8_t sample_ed(void)
        +
        bool testCarrier(uint8_t RSSI=65)
        +
        bool txStandBy()
        +
        uint8_t decrypt(void *bufferIn, uint8_t size)
        uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
        Definition nrf_to_nrf.h:201
        -
        void setChannel(uint8_t channel)
        +
        void setChannel(uint8_t channel)
        uint32_t addrConv32(uint32_t addr)
        -
        void disableDynamicPayloads()
        -
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        -
        bool testRPD(uint8_t RSSI=65)
        -
        void setCounter(uint64_t counter)
        -
        bool isChipConnected()
        -
        void setAddressWidth(uint8_t a_width)
        -
        uint8_t getDynamicPayloadSize()
        -
        bool setDataRate(uint8_t speed)
        -
        bool isValid()
        +
        void disableDynamicPayloads()
        +
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        +
        bool testRPD(uint8_t RSSI=65)
        +
        void setCounter(uint64_t counter)
        +
        bool isChipConnected()
        +
        void setAddressWidth(uint8_t a_width)
        +
        uint8_t getDynamicPayloadSize()
        +
        bool setDataRate(uint8_t speed)
        +
        bool isValid()
        void enableDynamicAck()
        -
        void setKey(uint8_t key[CCM_KEY_SIZE])
        -
        bool begin()
        -
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        +
        void setKey(uint8_t key[CCM_KEY_SIZE])
        +
        bool begin()
        +
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        bool enableEncryption
        Definition nrf_to_nrf.h:459
        -
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        -
        void disableAckPayload()
        +
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        +
        void disableAckPayload()
        void disableCRC()
        -
        void powerDown()
        -
        uint8_t getARC()
        -
        uint8_t encrypt(void *bufferIn, uint8_t size)
        -
        void printDetails()
        -
        uint8_t getChannel()
        -
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        +
        void powerDown()
        +
        uint8_t getARC()
        +
        uint8_t encrypt(void *bufferIn, uint8_t size)
        +
        void printDetails()
        +
        uint8_t getChannel()
        +
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
        Definition nrf_to_nrf.h:426
        -
        void setRetries(uint8_t retryVar, uint8_t attempts)
        -
        void enableAckPayload()
        -
        void openWritingPipe(const uint8_t *address)
        -
        void setCRCLength(nrf_crclength_e length)
        +
        void setRetries(uint8_t retryVar, uint8_t attempts)
        +
        void enableAckPayload()
        +
        void openWritingPipe(const uint8_t *address)
        +
        void setCRCLength(nrf_crclength_e length)
        bool failureDetected
        Definition nrf_to_nrf.h:364
        -
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        -
        uint8_t getPALevel()
        -
        void setAutoAck(bool enable)
        -
        void read(void *buf, uint8_t len)
        -
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        -
        void setIV(uint8_t IV[CCM_IV_SIZE])
        -
        void setPayloadSize(uint8_t size)
        -
        nrf_crclength_e getCRCLength()
        -
        uint8_t getPayloadSize()
        +
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        +
        uint8_t getPALevel()
        +
        void setAutoAck(bool enable)
        +
        void read(void *buf, uint8_t len)
        +
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        +
        void setIV(uint8_t IV[CCM_IV_SIZE])
        +
        void setPayloadSize(uint8_t size)
        +
        nrf_crclength_e getCRCLength()
        +
        uint8_t getPayloadSize()
        #define CCM_MODE_LENGTH_EXTENDED
        Definition nrf_to_nrf.h:36
        #define DEFAULT_MAX_PAYLOAD_SIZE
        Definition nrf_to_nrf.h:16
        nrf_pa_dbm_e
        Definition nrf_to_nrf.h:40
        @@ -417,7 +417,7 @@

        diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index ffd3a72..d9ce0b3 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -41,12 +41,10 @@ uint32_t nrf_to_nrf::addrConv32(uint32_t addr) nrf_to_nrf::nrf_to_nrf() { - // Enable auto ack on all pipes by default - for (uint8_t i = 0; i < 8; i++) { - acksPerPipe[i] = true; - } - staticPayloadSize = 32; DPL = false; + staticPayloadSize = 32; + // Enable auto ack on all pipes by default + setAutoAck(1); retries = 5; retryDuration = 5; ackPayloadsEnabled = false; @@ -178,19 +176,23 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) } if (NRF_RADIO->EVENTS_CRCOK) { uint32_t counter = 0; +#if defined CCM_ENCRYPTION_ENABLED uint8_t tmpIV[CCM_IV_SIZE]; +#endif NRF_RADIO->EVENTS_CRCOK = 0; - if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) { + if (DPL){ + if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) { NRF_RADIO->TASKS_START = 1; return 0; - }else - if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) { + }else + if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) { NRF_RADIO->TASKS_START = 1; return 0; - }else - if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) { + }else + if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) { NRF_RADIO->TASKS_START = 1; return 0; + } } *pipe_num = (uint8_t)NRF_RADIO->RXMATCH; @@ -248,7 +250,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) stopListening(false, false); uint32_t txAddress = NRF_RADIO->TXADDRESS; NRF_RADIO->TXADDRESS = NRF_RADIO->RXMATCH; - delayMicroseconds(55); + delayMicroseconds(75); if (ackPayloadsEnabled) { if (*pipe_num == ackPipe) { write(&ackBuffer[1], ackBuffer[0], 1, 0);