From 43e21aba1889288b3aacda58e970e1a182a2e5dc Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Tue, 12 Mar 2024 12:10:44 +0000 Subject: [PATCH] deploy: 6dbb3b19677e4210cb3e92c49a1331d1d40c960c --- html/annotated.html | 2 +- html/classes.html | 2 +- html/classnrf__to__nrf-members.html | 2 +- html/classnrf__to__nrf.html | 114 +- .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 2 +- html/doxygen_crawl.html | 2 + html/examples.html | 2 +- ..._2mqtt_basic_2mqtt_basic_8ino-example.html | 6 +- ...24Mesh_ExampleEncryption_8ino-example.html | 18 +- ...xample_2RF24Mesh_Example_8ino-example.html | 10 +- ...Example_MasterEncryption_8ino-example.html | 12 +- ...2helloworld_rxEncryption_8ino-example.html | 14 +- ...oworld_rx_2helloworld_rx_8ino-example.html | 8 +- ...2helloworld_txEncryption_8ino-example.html | 14 +- ...oworld_tx_2helloworld_tx_8ino-example.html | 8 +- ...2AcknowledgementPayloads_8ino-example.html | 32 +- ...GettingStartedEncryption_8ino-example.html | 32 +- ...gStarted_2GettingStarted_8ino-example.html | 28 +- ..._2RF24_2scanner_2scanner_8ino-example.html | 16 +- html/files.html | 2 +- html/functions.html | 2 +- html/functions_func.html | 2 +- html/functions_vars.html | 2 +- html/globals.html | 12 +- html/globals_defs.html | 5 +- html/globals_enum.html | 2 +- html/globals_eval.html | 2 +- html/globals_func.html | 2 +- html/index.html | 2 +- html/menudata.js | 3 +- html/nrf__to__nrf_8cpp.html | 26 +- html/nrf__to__nrf_8cpp_source.html | 2901 +++++++++-------- html/nrf__to__nrf_8h.html | 68 +- html/nrf__to__nrf_8h_source.html | 572 ++-- html/search/all_0.js | 14 +- html/search/all_c.js | 5 +- html/search/defines_0.js | 8 +- html/search/defines_6.js | 4 + html/search/searchdata.js | 2 +- src/nrf_to_nrf.cpp | 20 +- src/nrf_to_nrf.h | 2 + 41 files changed, 2046 insertions(+), 1936 deletions(-) create mode 100644 html/search/defines_6.js diff --git a/html/annotated.html b/html/annotated.html index e1ba28b..1603165 100644 --- a/html/annotated.html +++ b/html/annotated.html @@ -107,7 +107,7 @@ diff --git a/html/classes.html b/html/classes.html index eabab2e..7e6a1dc 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 d84fa0a..ebc0954 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 7f07d87..97b1733 100644 --- a/html/classnrf__to__nrf.html +++ b/html/classnrf__to__nrf.html @@ -238,7 +238,7 @@
Examples
examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino, examples/RF24/GettingStarted/GettingStarted.ino, examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino, examples/RF24/scanner/scanner.ino, examples/RF24Ethernet/mqtt_basic/mqtt_basic.ino, examples/RF24Mesh/RF24Mesh_Example/RF24Mesh_Example.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 108 of file nrf_to_nrf.h.

+

Definition at line 110 of file nrf_to_nrf.h.

Constructor & Destructor Documentation

◆ nrf_to_nrf()

@@ -256,9 +256,9 @@

Constructor for nrf_to_nrf

nrf_to_nrf radio;
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
-

Definition at line 42 of file nrf_to_nrf.cpp.

+

Definition at line 48 of file nrf_to_nrf.cpp.

@@ -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 78 of file nrf_to_nrf.cpp.

+

Definition at line 84 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 155 of file nrf_to_nrf.cpp.

+

Definition at line 161 of file nrf_to_nrf.cpp.

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

Same as NRF24 radio.available();

-

Definition at line 163 of file nrf_to_nrf.cpp.

+

Definition at line 169 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 330 of file nrf_to_nrf.cpp.

+

Definition at line 336 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 342 of file nrf_to_nrf.cpp.

+

Definition at line 348 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 680 of file nrf_to_nrf.cpp.

+

Definition at line 687 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 703 of file nrf_to_nrf.cpp.

+

Definition at line 710 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 910 of file nrf_to_nrf.cpp.

+

Definition at line 917 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 952 of file nrf_to_nrf.cpp.

+

Definition at line 959 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 1028 of file nrf_to_nrf.cpp.

+

Definition at line 1035 of file nrf_to_nrf.cpp.

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

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

-

Definition at line 1009 of file nrf_to_nrf.cpp.

+

Definition at line 1016 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 530 of file nrf_to_nrf.cpp.

+

Definition at line 537 of file nrf_to_nrf.cpp.

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

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

Definition at line 630 of file nrf_to_nrf.cpp.

+

Definition at line 637 of file nrf_to_nrf.cpp.

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

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

Definition at line 672 of file nrf_to_nrf.cpp.

+

Definition at line 679 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 676 of file nrf_to_nrf.cpp.

+

Definition at line 683 of file nrf_to_nrf.cpp.

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

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

Definition at line 727 of file nrf_to_nrf.cpp.

+

Definition at line 734 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 735 of file nrf_to_nrf.cpp.

+

Definition at line 742 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 749 of file nrf_to_nrf.cpp.

+

Definition at line 756 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 753 of file nrf_to_nrf.cpp.

+

Definition at line 760 of file nrf_to_nrf.cpp.

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

Supported speeds: NRF_1MBPS NRF_2MBPS

-

Definition at line 1032 of file nrf_to_nrf.cpp.

+

Definition at line 1039 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 1048 of file nrf_to_nrf.cpp.

+

Definition at line 1060 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1070 of file nrf_to_nrf.cpp.

+

Definition at line 1082 of file nrf_to_nrf.cpp.

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

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

Definition at line 757 of file nrf_to_nrf.cpp.

+

Definition at line 764 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 770 of file nrf_to_nrf.cpp.

+

Definition at line 777 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 781 of file nrf_to_nrf.cpp.

+

Definition at line 788 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 801 of file nrf_to_nrf.cpp.

+

Definition at line 808 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 816 of file nrf_to_nrf.cpp.

+

Definition at line 823 of file nrf_to_nrf.cpp.

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

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

Definition at line 832 of file nrf_to_nrf.cpp.

+

Definition at line 839 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1101 of file nrf_to_nrf.cpp.

+

Definition at line 1113 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1123 of file nrf_to_nrf.cpp.

+

Definition at line 1135 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 839 of file nrf_to_nrf.cpp.

+

Definition at line 846 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 848 of file nrf_to_nrf.cpp.

+

Definition at line 855 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 889 of file nrf_to_nrf.cpp.

+

Definition at line 896 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1175 of file nrf_to_nrf.cpp.

+

Definition at line 1187 of file nrf_to_nrf.cpp.

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

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

Definition at line 1190 of file nrf_to_nrf.cpp.

+

Definition at line 1202 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 1160 of file nrf_to_nrf.cpp.

+

Definition at line 1172 of file nrf_to_nrf.cpp.

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

When called ALL radio settings will be reverted to default

-

Definition at line 1168 of file nrf_to_nrf.cpp.

+

Definition at line 1180 of file nrf_to_nrf.cpp.

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

Definition at line 972 of file nrf_to_nrf.cpp.

+

Definition at line 979 of file nrf_to_nrf.cpp.

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

Definition at line 990 of file nrf_to_nrf.cpp.

+

Definition at line 997 of file nrf_to_nrf.cpp.

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

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

Definition at line 1138 of file nrf_to_nrf.cpp.

+

Definition at line 1150 of file nrf_to_nrf.cpp.

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

Definition at line 1153 of file nrf_to_nrf.cpp.

+

Definition at line 1165 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1094 of file nrf_to_nrf.cpp.

+

Definition at line 1106 of file nrf_to_nrf.cpp.

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

-

Definition at line 139 of file nrf_to_nrf.cpp.

+

Definition at line 145 of file nrf_to_nrf.cpp.

@@ -1324,7 +1324,7 @@

Used internally to convert addresses

-

Definition at line 28 of file nrf_to_nrf.cpp.

+

Definition at line 34 of file nrf_to_nrf.cpp.

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

Function to encrypt data

-

Definition at line 1284 of file nrf_to_nrf.cpp.

+

Definition at line 1296 of file nrf_to_nrf.cpp.

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

Function to decrypt data

-

Definition at line 1316 of file nrf_to_nrf.cpp.

+

Definition at line 1328 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 1349 of file nrf_to_nrf.cpp.

+

Definition at line 1361 of file nrf_to_nrf.cpp.

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

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

Definition at line 1357 of file nrf_to_nrf.cpp.

+

Definition at line 1369 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 1365 of file nrf_to_nrf.cpp.

+

Definition at line 1377 of file nrf_to_nrf.cpp.

@@ -1454,7 +1454,7 @@

Data buffer for radio data The radio can handle packets up to 127 bytes if CRC is disabled 125 bytes if using 16-bit CRC

-

Definition at line 201 of file nrf_to_nrf.h.

+

Definition at line 203 of file nrf_to_nrf.h.

@@ -1471,7 +1471,7 @@

Not implemented due to SOC

-

Definition at line 364 of file nrf_to_nrf.h.

+

Definition at line 366 of file nrf_to_nrf.h.

@@ -1488,7 +1488,7 @@

The data buffer where encrypted data is placed. See the datasheet p115 for the CCM data structure

-

Definition at line 426 of file nrf_to_nrf.h.

+

Definition at line 428 of file nrf_to_nrf.h.

@@ -1510,7 +1510,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 459 of file nrf_to_nrf.h.

+

Definition at line 461 of file nrf_to_nrf.h.

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

diff --git a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index dd7ba62..049e41d 100644 --- a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -113,7 +113,7 @@ diff --git a/html/doxygen_crawl.html b/html/doxygen_crawl.html index 6ed4348..698aa78 100644 --- a/html/doxygen_crawl.html +++ b/html/doxygen_crawl.html @@ -70,6 +70,7 @@ + @@ -80,6 +81,7 @@ + diff --git a/html/examples.html b/html/examples.html index cf86ae6..e234d25 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 e7fd556..9bac17e 100644 --- a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html +++ b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html @@ -231,13 +231,13 @@
client.publish("outTopic", str1);
}
}
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void printDetails()
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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 d31287d..6b98347 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html @@ -197,19 +197,19 @@
Serial.println(payload.ms);
}
}
-
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()
-
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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:461
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
-
@ NRF_PA_MIN
Definition nrf_to_nrf.h:44
+
@ NRF_PA_MIN
Definition nrf_to_nrf.h:46
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 ed2ef1a..4a11cdc 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html @@ -190,15 +190,15 @@
Serial.println(payload.ms);
}
}
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool isChipConnected()
-
@ NRF_PA_MIN
Definition nrf_to_nrf.h:44
+
@ NRF_PA_MIN
Definition nrf_to_nrf.h:46
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 86aacda..4a6c2bc 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 @@ -178,16 +178,16 @@
Serial.println(F("**********************************"));
}
}
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
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)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:461
+
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 3a26353..8a004ca 100644 --- a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html @@ -148,17 +148,17 @@
Serial.println(payload.ms);
}
}
-
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()
-
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:461
+
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 8fc1cbc..3df5467 100644 --- a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html @@ -141,14 +141,14 @@
Serial.println(payload.ms);
}
}
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
bool begin()
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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 74a53f6..d915f2d 100644 --- a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html @@ -156,17 +156,17 @@
Serial.println(ok ? F("ok.") : F("failed."));
}
}
-
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()
-
bool enableEncryption
Definition nrf_to_nrf.h:459
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:461
+
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 4f3ef1d..0163bbc 100644 --- a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html @@ -148,14 +148,14 @@
Serial.println(ok ? F("ok.") : F("failed."));
}
}
-
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:109
-
void setChannel(uint8_t channel)
-
bool begin()
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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 2a303fa..b070675 100644 --- a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html +++ b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html @@ -289,26 +289,26 @@
}
}
} // 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)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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
+
@ NRF_PA_MAX
Definition nrf_to_nrf.h:58
diff --git a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html index 9e0e72e..c64638e 100644 --- a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html +++ b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html @@ -252,26 +252,26 @@
}
} // 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()
-
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)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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:461
+
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
+
@ NRF_PA_LOW
Definition nrf_to_nrf.h:50
diff --git a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html index ebc255b..cfee3c1 100644 --- a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html +++ b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html @@ -238,24 +238,24 @@
}
} // 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()
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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
+
@ NRF_PA_LOW
Definition nrf_to_nrf.h:50
diff --git a/html/examples_2RF24_2scanner_2scanner_8ino-example.html b/html/examples_2RF24_2scanner_2scanner_8ino-example.html index 61cd3b5..72a23ac 100644 --- a/html/examples_2RF24_2scanner_2scanner_8ino-example.html +++ b/html/examples_2RF24_2scanner_2scanner_8ino-example.html @@ -225,18 +225,18 @@
} //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)
+
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:111
+
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 e6b6c25..6256f88 100644 --- a/html/files.html +++ b/html/files.html @@ -108,7 +108,7 @@ diff --git a/html/functions.html b/html/functions.html index e1692f9..06197e6 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 ee00d35..70fa8ef 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 38c4ffe..f419ca1 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 bf73cec..f1eaffa 100644 --- a/html/globals.html +++ b/html/globals.html @@ -89,7 +89,8 @@
    • d
    • e
    • m
    • -
    • n
    • +
    • n
    • +
    • r
    @@ -121,6 +122,8 @@

    - a -

    diff --git a/html/globals_enum.html b/html/globals_enum.html index 334c8ec..8321703 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 bed978a..e862562 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 e4da900..d6ee2e8 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 c6b29c9..6328043 100644 --- a/html/index.html +++ b/html/index.html @@ -101,7 +101,7 @@ diff --git a/html/menudata.js b/html/menudata.js index ce7753a..5a6eccc 100644 --- a/html/menudata.js +++ b/html/menudata.js @@ -68,7 +68,8 @@ var menudata={children:[ {text:"d",url:"globals.html#index_d"}, {text:"e",url:"globals.html#index_e"}, {text:"m",url:"globals.html#index_m"}, -{text:"n",url:"globals.html#index_n"}]}, +{text:"n",url:"globals.html#index_n"}, +{text:"r",url:"globals.html#index_r"}]}, {text:"Functions",url:"globals_func.html"}, {text:"Enumerations",url:"globals_enum.html"}, {text:"Enumerator",url:"globals_eval.html"}, diff --git a/html/nrf__to__nrf_8cpp.html b/html/nrf__to__nrf_8cpp.html index f0d151c..8862976 100644 --- a/html/nrf__to__nrf_8cpp.html +++ b/html/nrf__to__nrf_8cpp.html @@ -111,6 +111,8 @@ + +

    Macros

    #define RADIO_MODE_MODE_Nrf_250Kbit   (2UL)
     
    #define ED_RSSISCALE   4
     
    @@ -122,6 +124,22 @@
     

    Macro Definition Documentation

    + +

    ◆ RADIO_MODE_MODE_Nrf_250Kbit

    + +
    +
    + + + + +
    #define RADIO_MODE_MODE_Nrf_250Kbit   (2UL)
    +
    + +

    Definition at line 8 of file nrf_to_nrf.cpp.

    + +
    +

    ◆ ED_RSSISCALE

    @@ -134,7 +152,7 @@

    -

    Definition at line 138 of file nrf_to_nrf.cpp.

    +

    Definition at line 144 of file nrf_to_nrf.cpp.

    @@ -162,7 +180,7 @@

    -

    Definition at line 8 of file nrf_to_nrf.cpp.

    +

    Definition at line 14 of file nrf_to_nrf.cpp.

    @@ -189,14 +207,14 @@

    -

    Definition at line 20 of file nrf_to_nrf.cpp.

    +

    Definition at line 26 of file nrf_to_nrf.cpp.

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

    Definition at line 19 of file nrf_to_nrf.h.

    +

    +
    + +

    ◆ ACK_TIMEOUT_250KBPS

    + +
    +
    + + + + +
    #define ACK_TIMEOUT_250KBPS   500
    +
    + +

    Definition at line 20 of file nrf_to_nrf.h.

    +
    @@ -274,7 +294,7 @@

    -

    Definition at line 20 of file nrf_to_nrf.h.

    +

    Definition at line 21 of file nrf_to_nrf.h.

    @@ -290,7 +310,23 @@

    -

    Definition at line 21 of file nrf_to_nrf.h.

    +

    Definition at line 22 of file nrf_to_nrf.h.

    + +

    +
    + +

    ◆ ACK_TIMEOUT_250KBPS_OFFSET

    + +
    +
    + + + + +
    #define ACK_TIMEOUT_250KBPS_OFFSET   300
    +
    + +

    Definition at line 23 of file nrf_to_nrf.h.

    @@ -306,7 +342,7 @@

    -

    Definition at line 22 of file nrf_to_nrf.h.

    +

    Definition at line 24 of file nrf_to_nrf.h.

    @@ -322,7 +358,7 @@

    -

    Definition at line 26 of file nrf_to_nrf.h.

    +

    Definition at line 28 of file nrf_to_nrf.h.

    @@ -338,7 +374,7 @@

    -

    Definition at line 29 of file nrf_to_nrf.h.

    +

    Definition at line 31 of file nrf_to_nrf.h.

    @@ -354,7 +390,7 @@

    -

    Definition at line 30 of file nrf_to_nrf.h.

    +

    Definition at line 32 of file nrf_to_nrf.h.

    @@ -370,7 +406,7 @@

    -

    Definition at line 31 of file nrf_to_nrf.h.

    +

    Definition at line 33 of file nrf_to_nrf.h.

    @@ -386,7 +422,7 @@

    -

    Definition at line 32 of file nrf_to_nrf.h.

    +

    Definition at line 34 of file nrf_to_nrf.h.

    @@ -402,7 +438,7 @@

    -

    Definition at line 33 of file nrf_to_nrf.h.

    +

    Definition at line 35 of file nrf_to_nrf.h.

    @@ -418,7 +454,7 @@

    -

    Definition at line 34 of file nrf_to_nrf.h.

    +

    Definition at line 36 of file nrf_to_nrf.h.

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

    -

    Definition at line 35 of file nrf_to_nrf.h.

    +

    Definition at line 37 of file nrf_to_nrf.h.

    @@ -450,7 +486,7 @@

    -

    Definition at line 36 of file nrf_to_nrf.h.

    +

    Definition at line 38 of file nrf_to_nrf.h.

    @@ -479,7 +515,7 @@

    Definition at line 39 of file nrf_to_nrf.h.

    +

    Definition at line 41 of file nrf_to_nrf.h.

    @@ -508,7 +544,7 @@

    Definition at line 72 of file nrf_to_nrf.h.

    +

    Definition at line 74 of file nrf_to_nrf.h.

    @@ -538,14 +574,14 @@

    Definition at line 93 of file nrf_to_nrf.h.

    +

    Definition at line 95 of file nrf_to_nrf.h.

    diff --git a/html/nrf__to__nrf_8h_source.html b/html/nrf__to__nrf_8h_source.html index 89429c1..1ea1692 100644 --- a/html/nrf__to__nrf_8h_source.html +++ b/html/nrf__to__nrf_8h_source.html @@ -121,303 +121,305 @@
    17#define ACTUAL_MAX_PAYLOAD_SIZE 127
    18#define ACK_TIMEOUT_1MBPS 500 // 200 with static payloads
    19#define ACK_TIMEOUT_2MBPS 300 // 165 with static payloads
    -
    20#define ACK_TIMEOUT_1MBPS_OFFSET 300
    -
    21#define ACK_TIMEOUT_2MBPS_OFFSET 135
    -
    22#define ACK_PAYLOAD_TIMEOUT_OFFSET 750
    -
    23
    -
    24// AES CCM ENCRYPTION
    -
    25#if defined NRF_CCM || defined(DOXYGEN)
    -
    26 #define CCM_ENCRYPTION_ENABLED
    -
    27#endif
    -
    28#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
    -
    29 #define MAX_PACKET_SIZE ACTUAL_MAX_PAYLOAD_SIZE // Max Payload Size
    -
    30 #define CCM_KEY_SIZE 16
    -
    31 #define CCM_IV_SIZE 5
    -
    32 #define CCM_IV_SIZE_ACTUAL 8
    -
    33 #define CCM_COUNTER_SIZE 3
    -
    34 #define CCM_MIC_SIZE 4
    -
    35 #define CCM_START_SIZE 3
    -
    36 #define CCM_MODE_LENGTH_EXTENDED 16
    -
    37#endif
    -
    38
    -
    -
    39typedef enum
    -
    40{
    - - - - - - +
    20#define ACK_TIMEOUT_250KBPS 500
    +
    21#define ACK_TIMEOUT_1MBPS_OFFSET 300
    +
    22#define ACK_TIMEOUT_2MBPS_OFFSET 135
    +
    23#define ACK_TIMEOUT_250KBPS_OFFSET 300
    +
    24#define ACK_PAYLOAD_TIMEOUT_OFFSET 750
    +
    25
    +
    26// AES CCM ENCRYPTION
    +
    27#if defined NRF_CCM || defined(DOXYGEN)
    +
    28 #define CCM_ENCRYPTION_ENABLED
    +
    29#endif
    +
    30#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
    +
    31 #define MAX_PACKET_SIZE ACTUAL_MAX_PAYLOAD_SIZE // Max Payload Size
    +
    32 #define CCM_KEY_SIZE 16
    +
    33 #define CCM_IV_SIZE 5
    +
    34 #define CCM_IV_SIZE_ACTUAL 8
    +
    35 #define CCM_COUNTER_SIZE 3
    +
    36 #define CCM_MIC_SIZE 4
    +
    37 #define CCM_START_SIZE 3
    +
    38 #define CCM_MODE_LENGTH_EXTENDED 16
    +
    39#endif
    +
    40
    + -
    62
    -
    -
    72typedef enum
    -
    73{
    - - - - +
    64
    +
    +
    74typedef enum
    +
    75{
    + + + +
    -
    81
    -
    -
    93typedef enum
    -
    94{
    - - - - +
    83
    +
    +
    95typedef enum
    +
    96{
    + + + +
    -
    102
    -
    - -
    109{
    -
    110
    -
    111public:
    +
    104
    +
    + +
    111{
    112
    -
    127 nrf_to_nrf();
    -
    128
    -
    129
    -
    136 bool begin();
    -
    137
    -
    141 bool available();
    -
    142
    -
    146 bool available(uint8_t* pipe_num);
    -
    147
    -
    151 void read(void* buf, uint8_t len);
    -
    152
    -
    156 bool write(void* buf, uint8_t len, bool multicast = false, bool doEncryption = true);
    -
    157
    -
    162 void startListening(bool resetAddresses = true);
    -
    163
    -
    169 void stopListening(bool setWritingPipe = true, bool resetAddresses = true);
    -
    170
    -
    174 void openReadingPipe(uint8_t child, const uint8_t* address);
    -
    175
    -
    179 void openWritingPipe(const uint8_t* address);
    -
    180
    -
    184 bool isChipConnected();
    -
    185
    -
    186
    - -
    202
    -
    206 bool writeFast(void* buf, uint8_t len, bool multicast = 0);
    -
    207
    -
    216 bool startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption = true);
    -
    217
    -
    221 bool writeAckPayload(uint8_t pipe, void* buf, uint8_t len);
    -
    222
    -
    226 void enableAckPayload();
    -
    227
    -
    231 void disableAckPayload();
    -
    232
    - -
    237
    -
    238
    -
    242 uint8_t getDynamicPayloadSize();
    -
    243
    -
    247 bool isValid();
    -
    248
    -
    252 void setChannel(uint8_t channel);
    -
    253
    -
    257 uint8_t getChannel();
    -
    258
    -
    262 bool setDataRate(uint8_t speed);
    -
    263
    -
    272 void setPALevel(uint8_t level, bool lnaEnable = true);
    -
    273
    -
    277 uint8_t getPALevel();
    -
    278
    -
    282 void setAutoAck(bool enable);
    -
    283
    -
    287 void setAutoAck(uint8_t pipe, bool enable);
    -
    288
    -
    294 void enableDynamicPayloads(uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE);
    -
    295
    - -
    300
    -
    304 void setPayloadSize(uint8_t size);
    -
    305
    -
    309 uint8_t getPayloadSize();
    -
    310
    -
    314 void setCRCLength(nrf_crclength_e length);
    -
    315
    - -
    320
    - -
    325
    -
    329 void setRetries(uint8_t retryVar, uint8_t attempts);
    -
    330
    -
    334 void openReadingPipe(uint8_t child, uint64_t address);
    -
    335
    -
    339 void openWritingPipe(uint64_t address);
    -
    340
    -
    344 void setAddressWidth(uint8_t a_width);
    -
    345
    -
    349 void printDetails();
    -
    350
    -
    354 void powerUp();
    -
    355
    -
    359 void powerDown();
    -
    360
    - -
    365
    -
    371 bool txStandBy();
    -
    372
    -
    378 bool txStandBy(uint32_t timeout, bool startTx = 0);
    -
    379
    -
    384 bool testCarrier(uint8_t RSSI = 65);
    -
    385
    -
    390 bool testRPD(uint8_t RSSI = 65);
    -
    391
    -
    395 uint8_t getARC();
    -
    396
    -
    397 uint8_t sample_ed(void);
    -
    398
    -
    410 uint32_t addrConv32(uint32_t addr);
    -
    411#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
    -
    412
    -
    416 uint8_t encrypt(void* bufferIn, uint8_t size);
    -
    417
    -
    421 uint8_t decrypt(void* bufferIn, uint8_t size);
    -
    422
    - -
    427
    -
    431 void setKey(uint8_t key[CCM_KEY_SIZE]);
    -
    432
    -
    436 void setCounter(uint64_t counter);
    -
    437
    -
    443 void setIV(uint8_t IV[CCM_IV_SIZE]);
    -
    444
    - -
    461#endif
    -
    462
    -
    463private:
    -
    464 bool acksEnabled(uint8_t pipe);
    -
    465 bool acksPerPipe[8];
    -
    466 uint8_t retries;
    -
    467 uint8_t retryDuration;
    -
    468 uint8_t rxBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
    -
    469 uint8_t ackBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
    -
    470 uint8_t rxFifoAvailable;
    -
    471 bool DPL;
    -
    472 bool ackPayloadsEnabled;
    -
    473 bool inRxMode;
    -
    474 uint8_t staticPayloadSize;
    -
    475 uint8_t ackPID;
    -
    476 uint8_t ackPipe;
    -
    477 bool lastTxResult;
    -
    478 bool overWrite;
    -
    479 uint32_t rxBase;
    -
    480 uint32_t rxPrefix;
    -
    481 uint32_t txBase;
    -
    482 uint32_t txPrefix;
    -
    483 bool radioConfigured;
    -
    484 bool ackPayloadAvailable;
    -
    485 uint8_t ackAvailablePipeNo;
    -
    486 uint8_t lastPacketCounter;
    -
    487 uint16_t lastData;
    -
    488 bool dynamicAckEnabled;
    -
    489 uint8_t ARC;
    -
    490 uint8_t addressWidth;
    -
    491 uint16_t ackTimeout;
    -
    492 bool payloadAvailable;
    -
    493#if defined CCM_ENCRYPTION_ENABLED
    -
    494 uint8_t inBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
    -
    495 uint8_t scratchPTR[MAX_PACKET_SIZE + CCM_MODE_LENGTH_EXTENDED];
    -
    496 typedef struct
    -
    497 {
    -
    498 uint8_t key[CCM_KEY_SIZE];
    -
    499 uint64_t counter;
    -
    500 uint8_t direction;
    -
    501 uint8_t iv[CCM_IV_SIZE_ACTUAL];
    -
    502 } ccmData_t;
    -
    503 ccmData_t ccmData;
    -
    504 uint32_t packetCounter;
    -
    505#endif
    -
    506};
    +
    113public:
    +
    114
    +
    129 nrf_to_nrf();
    +
    130
    +
    131
    +
    138 bool begin();
    +
    139
    +
    143 bool available();
    +
    144
    +
    148 bool available(uint8_t* pipe_num);
    +
    149
    +
    153 void read(void* buf, uint8_t len);
    +
    154
    +
    158 bool write(void* buf, uint8_t len, bool multicast = false, bool doEncryption = true);
    +
    159
    +
    164 void startListening(bool resetAddresses = true);
    +
    165
    +
    171 void stopListening(bool setWritingPipe = true, bool resetAddresses = true);
    +
    172
    +
    176 void openReadingPipe(uint8_t child, const uint8_t* address);
    +
    177
    +
    181 void openWritingPipe(const uint8_t* address);
    +
    182
    +
    186 bool isChipConnected();
    +
    187
    +
    188
    + +
    204
    +
    208 bool writeFast(void* buf, uint8_t len, bool multicast = 0);
    +
    209
    +
    218 bool startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption = true);
    +
    219
    +
    223 bool writeAckPayload(uint8_t pipe, void* buf, uint8_t len);
    +
    224
    +
    228 void enableAckPayload();
    +
    229
    +
    233 void disableAckPayload();
    +
    234
    + +
    239
    +
    240
    +
    244 uint8_t getDynamicPayloadSize();
    +
    245
    +
    249 bool isValid();
    +
    250
    +
    254 void setChannel(uint8_t channel);
    +
    255
    +
    259 uint8_t getChannel();
    +
    260
    +
    264 bool setDataRate(uint8_t speed);
    +
    265
    +
    274 void setPALevel(uint8_t level, bool lnaEnable = true);
    +
    275
    +
    279 uint8_t getPALevel();
    +
    280
    +
    284 void setAutoAck(bool enable);
    +
    285
    +
    289 void setAutoAck(uint8_t pipe, bool enable);
    +
    290
    +
    296 void enableDynamicPayloads(uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE);
    +
    297
    + +
    302
    +
    306 void setPayloadSize(uint8_t size);
    +
    307
    +
    311 uint8_t getPayloadSize();
    +
    312
    +
    316 void setCRCLength(nrf_crclength_e length);
    +
    317
    + +
    322
    + +
    327
    +
    331 void setRetries(uint8_t retryVar, uint8_t attempts);
    +
    332
    +
    336 void openReadingPipe(uint8_t child, uint64_t address);
    +
    337
    +
    341 void openWritingPipe(uint64_t address);
    +
    342
    +
    346 void setAddressWidth(uint8_t a_width);
    +
    347
    +
    351 void printDetails();
    +
    352
    +
    356 void powerUp();
    +
    357
    +
    361 void powerDown();
    +
    362
    + +
    367
    +
    373 bool txStandBy();
    +
    374
    +
    380 bool txStandBy(uint32_t timeout, bool startTx = 0);
    +
    381
    +
    386 bool testCarrier(uint8_t RSSI = 65);
    +
    387
    +
    392 bool testRPD(uint8_t RSSI = 65);
    +
    393
    +
    397 uint8_t getARC();
    +
    398
    +
    399 uint8_t sample_ed(void);
    +
    400
    +
    412 uint32_t addrConv32(uint32_t addr);
    +
    413#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
    +
    414
    +
    418 uint8_t encrypt(void* bufferIn, uint8_t size);
    +
    419
    +
    423 uint8_t decrypt(void* bufferIn, uint8_t size);
    +
    424
    + +
    429
    +
    433 void setKey(uint8_t key[CCM_KEY_SIZE]);
    +
    434
    +
    438 void setCounter(uint64_t counter);
    +
    439
    +
    445 void setIV(uint8_t IV[CCM_IV_SIZE]);
    +
    446
    + +
    463#endif
    +
    464
    +
    465private:
    +
    466 bool acksEnabled(uint8_t pipe);
    +
    467 bool acksPerPipe[8];
    +
    468 uint8_t retries;
    +
    469 uint8_t retryDuration;
    +
    470 uint8_t rxBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
    +
    471 uint8_t ackBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
    +
    472 uint8_t rxFifoAvailable;
    +
    473 bool DPL;
    +
    474 bool ackPayloadsEnabled;
    +
    475 bool inRxMode;
    +
    476 uint8_t staticPayloadSize;
    +
    477 uint8_t ackPID;
    +
    478 uint8_t ackPipe;
    +
    479 bool lastTxResult;
    +
    480 bool overWrite;
    +
    481 uint32_t rxBase;
    +
    482 uint32_t rxPrefix;
    +
    483 uint32_t txBase;
    +
    484 uint32_t txPrefix;
    +
    485 bool radioConfigured;
    +
    486 bool ackPayloadAvailable;
    +
    487 uint8_t ackAvailablePipeNo;
    +
    488 uint8_t lastPacketCounter;
    +
    489 uint16_t lastData;
    +
    490 bool dynamicAckEnabled;
    +
    491 uint8_t ARC;
    +
    492 uint8_t addressWidth;
    +
    493 uint16_t ackTimeout;
    +
    494 bool payloadAvailable;
    +
    495#if defined CCM_ENCRYPTION_ENABLED
    +
    496 uint8_t inBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
    +
    497 uint8_t scratchPTR[MAX_PACKET_SIZE + CCM_MODE_LENGTH_EXTENDED];
    +
    498 typedef struct
    +
    499 {
    +
    500 uint8_t key[CCM_KEY_SIZE];
    +
    501 uint64_t counter;
    +
    502 uint8_t direction;
    +
    503 uint8_t iv[CCM_IV_SIZE_ACTUAL];
    +
    504 } ccmData_t;
    +
    505 ccmData_t ccmData;
    +
    506 uint32_t packetCounter;
    +
    507#endif
    +
    508};
    -
    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)
    -
    uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
    Definition nrf_to_nrf.h:201
    -
    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()
    +
    509
    +
    569#endif //__nrf52840_nrf24l01_H__
    +
    Driver class for nRF52840 2.4GHz Wireless Transceiver.
    Definition nrf_to_nrf.h:111
    +
    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:203
    +
    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 enableDynamicAck()
    - -
    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 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:461
    +
    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)
    -
    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 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()
    -
    #define CCM_MODE_LENGTH_EXTENDED
    Definition nrf_to_nrf.h:36
    +
    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:428
    +
    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:366
    +
    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:38
    #define DEFAULT_MAX_PAYLOAD_SIZE
    Definition nrf_to_nrf.h:16
    -
    nrf_pa_dbm_e
    Definition nrf_to_nrf.h:40
    -
    @ NRF_PA_MAX
    Definition nrf_to_nrf.h:56
    -
    @ NRF_PA_HIGH
    Definition nrf_to_nrf.h:52
    -
    @ NRF_PA_LOW
    Definition nrf_to_nrf.h:48
    -
    @ NRF_PA_MIN
    Definition nrf_to_nrf.h:44
    -
    @ NRF_PA_ERROR
    Definition nrf_to_nrf.h:60
    -
    nrf_crclength_e
    Definition nrf_to_nrf.h:94
    -
    @ NRF_CRC_8
    Definition nrf_to_nrf.h:98
    -
    @ NRF_CRC_DISABLED
    Definition nrf_to_nrf.h:96
    -
    @ NRF_CRC_16
    Definition nrf_to_nrf.h:100
    -
    #define CCM_IV_SIZE_ACTUAL
    Definition nrf_to_nrf.h:32
    -
    nrf_datarate_e
    Definition nrf_to_nrf.h:73
    -
    @ NRF_1MBPS
    Definition nrf_to_nrf.h:75
    -
    @ NRF_2MBPS
    Definition nrf_to_nrf.h:77
    -
    @ NRF_250KBPS
    Definition nrf_to_nrf.h:79
    -
    #define CCM_START_SIZE
    Definition nrf_to_nrf.h:35
    +
    nrf_pa_dbm_e
    Definition nrf_to_nrf.h:42
    +
    @ NRF_PA_MAX
    Definition nrf_to_nrf.h:58
    +
    @ NRF_PA_HIGH
    Definition nrf_to_nrf.h:54
    +
    @ NRF_PA_LOW
    Definition nrf_to_nrf.h:50
    +
    @ NRF_PA_MIN
    Definition nrf_to_nrf.h:46
    +
    @ NRF_PA_ERROR
    Definition nrf_to_nrf.h:62
    +
    nrf_crclength_e
    Definition nrf_to_nrf.h:96
    +
    @ NRF_CRC_8
    Definition nrf_to_nrf.h:100
    +
    @ NRF_CRC_DISABLED
    Definition nrf_to_nrf.h:98
    +
    @ NRF_CRC_16
    Definition nrf_to_nrf.h:102
    +
    #define CCM_IV_SIZE_ACTUAL
    Definition nrf_to_nrf.h:34
    +
    nrf_datarate_e
    Definition nrf_to_nrf.h:75
    +
    @ NRF_1MBPS
    Definition nrf_to_nrf.h:77
    +
    @ NRF_2MBPS
    Definition nrf_to_nrf.h:79
    +
    @ NRF_250KBPS
    Definition nrf_to_nrf.h:81
    +
    #define CCM_START_SIZE
    Definition nrf_to_nrf.h:37
    #define ACTUAL_MAX_PAYLOAD_SIZE
    Definition nrf_to_nrf.h:17
    -
    #define MAX_PACKET_SIZE
    Definition nrf_to_nrf.h:29
    -
    #define CCM_MIC_SIZE
    Definition nrf_to_nrf.h:34
    -
    #define CCM_KEY_SIZE
    Definition nrf_to_nrf.h:30
    -
    #define CCM_IV_SIZE
    Definition nrf_to_nrf.h:31
    +
    #define MAX_PACKET_SIZE
    Definition nrf_to_nrf.h:31
    +
    #define CCM_MIC_SIZE
    Definition nrf_to_nrf.h:36
    +
    #define CCM_KEY_SIZE
    Definition nrf_to_nrf.h:32
    +
    #define CCM_IV_SIZE
    Definition nrf_to_nrf.h:33
    diff --git a/html/search/all_0.js b/html/search/all_0.js index 941efca..256dc2e 100644 --- a/html/search/all_0.js +++ b/html/search/all_0.js @@ -3,10 +3,12 @@ var searchData= ['ack_5fpayload_5ftimeout_5foffset_0',['ACK_PAYLOAD_TIMEOUT_OFFSET',['../nrf__to__nrf_8h.html#a2dd505c7bafeca0827ed648669e6340f',1,'nrf_to_nrf.h']]], ['ack_5ftimeout_5f1mbps_1',['ACK_TIMEOUT_1MBPS',['../nrf__to__nrf_8h.html#ac2a8119d65fc07b14573f7e831318910',1,'nrf_to_nrf.h']]], ['ack_5ftimeout_5f1mbps_5foffset_2',['ACK_TIMEOUT_1MBPS_OFFSET',['../nrf__to__nrf_8h.html#a030c0e5971b11e84c1557267286efce4',1,'nrf_to_nrf.h']]], - ['ack_5ftimeout_5f2mbps_3',['ACK_TIMEOUT_2MBPS',['../nrf__to__nrf_8h.html#a709d6647f34a17c549e677e568bf5dc3',1,'nrf_to_nrf.h']]], - ['ack_5ftimeout_5f2mbps_5foffset_4',['ACK_TIMEOUT_2MBPS_OFFSET',['../nrf__to__nrf_8h.html#aafcf7551fc9a5d008c32094e9f6cafae',1,'nrf_to_nrf.h']]], - ['actual_5fmax_5fpayload_5fsize_5',['ACTUAL_MAX_PAYLOAD_SIZE',['../nrf__to__nrf_8h.html#a86f99279499412c45d603a56b52f15e1',1,'nrf_to_nrf.h']]], - ['addr_5fconv_6',['addr_conv',['../nrf__to__nrf_8cpp.html#aa7e5782f60d66a6f654f6a84b02e0876',1,'nrf_to_nrf.cpp']]], - ['addrconv32_7',['addrConv32',['../classnrf__to__nrf.html#a41d8dd2384f0c139623d15ac17f08bf7',1,'nrf_to_nrf']]], - ['available_8',['available',['../classnrf__to__nrf.html#a08df99a63e6dc2cbe4a8f014b7300ae4',1,'nrf_to_nrf::available()'],['../classnrf__to__nrf.html#a3521c78a008cfec0d6c87dcd7b7f8774',1,'nrf_to_nrf::available(uint8_t *pipe_num)']]] + ['ack_5ftimeout_5f250kbps_3',['ACK_TIMEOUT_250KBPS',['../nrf__to__nrf_8h.html#a609c96f213e335d2fd08fdce35506724',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f250kbps_5foffset_4',['ACK_TIMEOUT_250KBPS_OFFSET',['../nrf__to__nrf_8h.html#a4896730b35009d2286fbe07e2073398d',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f2mbps_5',['ACK_TIMEOUT_2MBPS',['../nrf__to__nrf_8h.html#a709d6647f34a17c549e677e568bf5dc3',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f2mbps_5foffset_6',['ACK_TIMEOUT_2MBPS_OFFSET',['../nrf__to__nrf_8h.html#aafcf7551fc9a5d008c32094e9f6cafae',1,'nrf_to_nrf.h']]], + ['actual_5fmax_5fpayload_5fsize_7',['ACTUAL_MAX_PAYLOAD_SIZE',['../nrf__to__nrf_8h.html#a86f99279499412c45d603a56b52f15e1',1,'nrf_to_nrf.h']]], + ['addr_5fconv_8',['addr_conv',['../nrf__to__nrf_8cpp.html#aa7e5782f60d66a6f654f6a84b02e0876',1,'nrf_to_nrf.cpp']]], + ['addrconv32_9',['addrConv32',['../classnrf__to__nrf.html#a41d8dd2384f0c139623d15ac17f08bf7',1,'nrf_to_nrf']]], + ['available_10',['available',['../classnrf__to__nrf.html#a08df99a63e6dc2cbe4a8f014b7300ae4',1,'nrf_to_nrf::available()'],['../classnrf__to__nrf.html#a3521c78a008cfec0d6c87dcd7b7f8774',1,'nrf_to_nrf::available(uint8_t *pipe_num)']]] ]; diff --git a/html/search/all_c.js b/html/search/all_c.js index 827b3a2..3fe24ec 100644 --- a/html/search/all_c.js +++ b/html/search/all_c.js @@ -1,6 +1,7 @@ var searchData= [ ['radio_20driver_0',['nrf_to_nrf - NRF52 radio driver',['../index.html',1,'']]], - ['radiodata_1',['radioData',['../classnrf__to__nrf.html#a3183dc6c9f8a06ca01ef9d015420791d',1,'nrf_to_nrf']]], - ['read_2',['read',['../classnrf__to__nrf.html#ae9457410ab65e1cf3109e45cc3155010',1,'nrf_to_nrf']]] + ['radio_5fmode_5fmode_5fnrf_5f250kbit_1',['RADIO_MODE_MODE_Nrf_250Kbit',['../nrf__to__nrf_8cpp.html#a0195d51696da7b4323456b757d1e260d',1,'nrf_to_nrf.cpp']]], + ['radiodata_2',['radioData',['../classnrf__to__nrf.html#a3183dc6c9f8a06ca01ef9d015420791d',1,'nrf_to_nrf']]], + ['read_3',['read',['../classnrf__to__nrf.html#ae9457410ab65e1cf3109e45cc3155010',1,'nrf_to_nrf']]] ]; diff --git a/html/search/defines_0.js b/html/search/defines_0.js index bba7006..f2ce9a8 100644 --- a/html/search/defines_0.js +++ b/html/search/defines_0.js @@ -3,7 +3,9 @@ var searchData= ['ack_5fpayload_5ftimeout_5foffset_0',['ACK_PAYLOAD_TIMEOUT_OFFSET',['../nrf__to__nrf_8h.html#a2dd505c7bafeca0827ed648669e6340f',1,'nrf_to_nrf.h']]], ['ack_5ftimeout_5f1mbps_1',['ACK_TIMEOUT_1MBPS',['../nrf__to__nrf_8h.html#ac2a8119d65fc07b14573f7e831318910',1,'nrf_to_nrf.h']]], ['ack_5ftimeout_5f1mbps_5foffset_2',['ACK_TIMEOUT_1MBPS_OFFSET',['../nrf__to__nrf_8h.html#a030c0e5971b11e84c1557267286efce4',1,'nrf_to_nrf.h']]], - ['ack_5ftimeout_5f2mbps_3',['ACK_TIMEOUT_2MBPS',['../nrf__to__nrf_8h.html#a709d6647f34a17c549e677e568bf5dc3',1,'nrf_to_nrf.h']]], - ['ack_5ftimeout_5f2mbps_5foffset_4',['ACK_TIMEOUT_2MBPS_OFFSET',['../nrf__to__nrf_8h.html#aafcf7551fc9a5d008c32094e9f6cafae',1,'nrf_to_nrf.h']]], - ['actual_5fmax_5fpayload_5fsize_5',['ACTUAL_MAX_PAYLOAD_SIZE',['../nrf__to__nrf_8h.html#a86f99279499412c45d603a56b52f15e1',1,'nrf_to_nrf.h']]] + ['ack_5ftimeout_5f250kbps_3',['ACK_TIMEOUT_250KBPS',['../nrf__to__nrf_8h.html#a609c96f213e335d2fd08fdce35506724',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f250kbps_5foffset_4',['ACK_TIMEOUT_250KBPS_OFFSET',['../nrf__to__nrf_8h.html#a4896730b35009d2286fbe07e2073398d',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f2mbps_5',['ACK_TIMEOUT_2MBPS',['../nrf__to__nrf_8h.html#a709d6647f34a17c549e677e568bf5dc3',1,'nrf_to_nrf.h']]], + ['ack_5ftimeout_5f2mbps_5foffset_6',['ACK_TIMEOUT_2MBPS_OFFSET',['../nrf__to__nrf_8h.html#aafcf7551fc9a5d008c32094e9f6cafae',1,'nrf_to_nrf.h']]], + ['actual_5fmax_5fpayload_5fsize_7',['ACTUAL_MAX_PAYLOAD_SIZE',['../nrf__to__nrf_8h.html#a86f99279499412c45d603a56b52f15e1',1,'nrf_to_nrf.h']]] ]; diff --git a/html/search/defines_6.js b/html/search/defines_6.js new file mode 100644 index 0000000..2c19c48 --- /dev/null +++ b/html/search/defines_6.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['radio_5fmode_5fmode_5fnrf_5f250kbit_0',['RADIO_MODE_MODE_Nrf_250Kbit',['../nrf__to__nrf_8cpp.html#a0195d51696da7b4323456b757d1e260d',1,'nrf_to_nrf.cpp']]] +]; diff --git a/html/search/searchdata.js b/html/search/searchdata.js index 79b3c9b..6e49fa8 100644 --- a/html/search/searchdata.js +++ b/html/search/searchdata.js @@ -7,7 +7,7 @@ var indexSectionsWithContent = 4: "efor", 5: "n", 6: "n", - 7: "acdemn", + 7: "acdemnr", 8: "dnr" }; diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index d074625..e09c03e 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -2,6 +2,12 @@ #include "nrf_to_nrf.h" +// Note that 250Kbit mode is deprecated and might not work reliably on all devices. +// See: https://devzone.nordicsemi.com/f/nordic-q-a/78469/250-kbit-s-nordic-proprietary-radio-mode-on-nrf52840 +#ifndef RADIO_MODE_MODE_Nrf_250Kbit +#define RADIO_MODE_MODE_Nrf_250Kbit (2UL) +#endif + /**********************************************************************************************************/ // Function to do bytewise bit-swap on an unsigned 32-bit value @@ -448,8 +454,9 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption if (!DPL) { if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos)) { realAckTimeout -= ACK_TIMEOUT_1MBPS_OFFSET; - } - else { + } else if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_250Kbit << RADIO_MODE_MODE_Pos)) { + realAckTimeout -= ACK_TIMEOUT_250KBPS_OFFSET; + } else { realAckTimeout -= ACK_TIMEOUT_2MBPS_OFFSET; } }else{ @@ -1032,14 +1039,19 @@ bool nrf_to_nrf::isChipConnected() { return isValid(); } bool nrf_to_nrf::setDataRate(uint8_t speed) { - if (!speed) { + if (speed == NRF_1MBPS) { NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos); ackTimeout = ACK_TIMEOUT_1MBPS; } - else { + else if (speed == NRF_250KBPS) { + NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_250Kbit << RADIO_MODE_MODE_Pos); + ackTimeout = ACK_TIMEOUT_250KBPS; + } + else { // NRF_2MBPS NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos); ackTimeout = ACK_TIMEOUT_2MBPS; } + return 1; } diff --git a/src/nrf_to_nrf.h b/src/nrf_to_nrf.h index ab00abe..1edcffa 100644 --- a/src/nrf_to_nrf.h +++ b/src/nrf_to_nrf.h @@ -17,8 +17,10 @@ #define ACTUAL_MAX_PAYLOAD_SIZE 127 #define ACK_TIMEOUT_1MBPS 500 // 200 with static payloads #define ACK_TIMEOUT_2MBPS 300 // 165 with static payloads +#define ACK_TIMEOUT_250KBPS 500 #define ACK_TIMEOUT_1MBPS_OFFSET 300 #define ACK_TIMEOUT_2MBPS_OFFSET 135 +#define ACK_TIMEOUT_250KBPS_OFFSET 300 #define ACK_PAYLOAD_TIMEOUT_OFFSET 750 // AES CCM ENCRYPTION