diff --git a/html/annotated.html b/html/annotated.html index ba45557..d5568da 100644 --- a/html/annotated.html +++ b/html/annotated.html @@ -107,7 +107,7 @@ diff --git a/html/classes.html b/html/classes.html index 900fb05..896a9f8 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 988d40b..6d06f08 100644 --- a/html/classnrf__to__nrf-members.html +++ b/html/classnrf__to__nrf-members.html @@ -160,7 +160,7 @@ diff --git a/html/classnrf__to__nrf.html b/html/classnrf__to__nrf.html index 79cc9d4..a65cef5 100644 --- a/html/classnrf__to__nrf.html +++ b/html/classnrf__to__nrf.html @@ -347,7 +347,7 @@

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

Definition at line 353 of file nrf_to_nrf.cpp.

+

Definition at line 368 of file nrf_to_nrf.cpp.

@@ -383,7 +383,7 @@

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

Definition at line 365 of file nrf_to_nrf.cpp.

+

Definition at line 377 of file nrf_to_nrf.cpp.

@@ -410,7 +410,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 704 of file nrf_to_nrf.cpp.

+

Definition at line 716 of file nrf_to_nrf.cpp.

@@ -442,7 +442,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 727 of file nrf_to_nrf.cpp.

+

Definition at line 739 of file nrf_to_nrf.cpp.

@@ -468,7 +468,7 @@

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

Definition at line 934 of file nrf_to_nrf.cpp.

+

Definition at line 946 of file nrf_to_nrf.cpp.

@@ -490,7 +490,7 @@

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

Definition at line 976 of file nrf_to_nrf.cpp.

+

Definition at line 988 of file nrf_to_nrf.cpp.

@@ -512,7 +512,7 @@

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

Definition at line 1052 of file nrf_to_nrf.cpp.

+

Definition at line 1064 of file nrf_to_nrf.cpp.

@@ -541,7 +541,7 @@

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

-

Definition at line 1033 of file nrf_to_nrf.cpp.

+

Definition at line 1045 of file nrf_to_nrf.cpp.

@@ -577,7 +577,7 @@

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

-

Definition at line 554 of file nrf_to_nrf.cpp.

+

Definition at line 566 of file nrf_to_nrf.cpp.

@@ -608,7 +608,7 @@

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

Definition at line 654 of file nrf_to_nrf.cpp.

+

Definition at line 666 of file nrf_to_nrf.cpp.

@@ -630,7 +630,7 @@

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

Definition at line 696 of file nrf_to_nrf.cpp.

+

Definition at line 708 of file nrf_to_nrf.cpp.

@@ -650,7 +650,7 @@

Same as NRF24

-

Definition at line 700 of file nrf_to_nrf.cpp.

+

Definition at line 712 of file nrf_to_nrf.cpp.

@@ -690,7 +690,7 @@

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

Definition at line 751 of file nrf_to_nrf.cpp.

+

Definition at line 763 of file nrf_to_nrf.cpp.

@@ -710,7 +710,7 @@

Same as NRF24

-

Definition at line 759 of file nrf_to_nrf.cpp.

+

Definition at line 771 of file nrf_to_nrf.cpp.

@@ -732,7 +732,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 773 of file nrf_to_nrf.cpp.

+

Definition at line 785 of file nrf_to_nrf.cpp.

@@ -752,7 +752,7 @@

Same as NRF24

-

Definition at line 777 of file nrf_to_nrf.cpp.

+

Definition at line 789 of file nrf_to_nrf.cpp.

@@ -772,7 +772,7 @@

Supported speeds: NRF_1MBPS NRF_2MBPS

-

Definition at line 1056 of file nrf_to_nrf.cpp.

+

Definition at line 1068 of file nrf_to_nrf.cpp.

@@ -799,7 +799,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 1077 of file nrf_to_nrf.cpp.

+

Definition at line 1089 of file nrf_to_nrf.cpp.

@@ -819,7 +819,7 @@

Same as NRF24

-

Definition at line 1099 of file nrf_to_nrf.cpp.

+

Definition at line 1111 of file nrf_to_nrf.cpp.

@@ -841,7 +841,7 @@

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

Definition at line 781 of file nrf_to_nrf.cpp.

+

Definition at line 793 of file nrf_to_nrf.cpp.

@@ -865,7 +865,7 @@

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

Definition at line 794 of file nrf_to_nrf.cpp.

+

Definition at line 806 of file nrf_to_nrf.cpp.

@@ -893,7 +893,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 805 of file nrf_to_nrf.cpp.

+

Definition at line 817 of file nrf_to_nrf.cpp.

@@ -913,7 +913,7 @@

Same as NRF24

-

Definition at line 825 of file nrf_to_nrf.cpp.

+

Definition at line 837 of file nrf_to_nrf.cpp.

@@ -935,7 +935,7 @@

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

Definition at line 840 of file nrf_to_nrf.cpp.

+

Definition at line 852 of file nrf_to_nrf.cpp.

@@ -957,7 +957,7 @@

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

Definition at line 856 of file nrf_to_nrf.cpp.

+

Definition at line 868 of file nrf_to_nrf.cpp.

@@ -977,7 +977,7 @@

Same as NRF24

-

Definition at line 1130 of file nrf_to_nrf.cpp.

+

Definition at line 1142 of file nrf_to_nrf.cpp.

@@ -997,7 +997,7 @@

Same as NRF24

-

Definition at line 1152 of file nrf_to_nrf.cpp.

+

Definition at line 1164 of file nrf_to_nrf.cpp.

@@ -1039,7 +1039,7 @@

Same as NRF24

-

Definition at line 863 of file nrf_to_nrf.cpp.

+

Definition at line 875 of file nrf_to_nrf.cpp.

@@ -1063,7 +1063,7 @@

Same as NRF24

-

Definition at line 872 of file nrf_to_nrf.cpp.

+

Definition at line 884 of file nrf_to_nrf.cpp.

@@ -1083,7 +1083,7 @@

Same as NRF24

-

Definition at line 913 of file nrf_to_nrf.cpp.

+

Definition at line 925 of file nrf_to_nrf.cpp.

@@ -1103,7 +1103,7 @@

Same as NRF24

-

Definition at line 1204 of file nrf_to_nrf.cpp.

+

Definition at line 1216 of file nrf_to_nrf.cpp.

@@ -1125,7 +1125,7 @@

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

Definition at line 1219 of file nrf_to_nrf.cpp.

+

Definition at line 1231 of file nrf_to_nrf.cpp.

@@ -1145,7 +1145,7 @@

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

-

Definition at line 1189 of file nrf_to_nrf.cpp.

+

Definition at line 1201 of file nrf_to_nrf.cpp.

@@ -1165,7 +1165,7 @@

When called ALL radio settings will be reverted to default

-

Definition at line 1197 of file nrf_to_nrf.cpp.

+

Definition at line 1209 of file nrf_to_nrf.cpp.

@@ -1186,7 +1186,7 @@

Definition at line 996 of file nrf_to_nrf.cpp.

+

Definition at line 1008 of file nrf_to_nrf.cpp.

@@ -1211,7 +1211,7 @@

Definition at line 1014 of file nrf_to_nrf.cpp.

+

Definition at line 1026 of file nrf_to_nrf.cpp.

@@ -1238,7 +1238,7 @@

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

Definition at line 1167 of file nrf_to_nrf.cpp.

+

Definition at line 1179 of file nrf_to_nrf.cpp.

@@ -1263,7 +1263,7 @@

Definition at line 1182 of file nrf_to_nrf.cpp.

+

Definition at line 1194 of file nrf_to_nrf.cpp.

@@ -1283,7 +1283,7 @@

Same as NRF24

-

Definition at line 1123 of file nrf_to_nrf.cpp.

+

Definition at line 1135 of file nrf_to_nrf.cpp.

@@ -1327,7 +1327,7 @@

Function to encrypt data

-

Definition at line 1313 of file nrf_to_nrf.cpp.

+

Definition at line 1325 of file nrf_to_nrf.cpp.

@@ -1351,7 +1351,7 @@

Function to decrypt data

-

Definition at line 1345 of file nrf_to_nrf.cpp.

+

Definition at line 1357 of file nrf_to_nrf.cpp.

@@ -1373,7 +1373,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 1378 of file nrf_to_nrf.cpp.

+

Definition at line 1390 of file nrf_to_nrf.cpp.

@@ -1395,7 +1395,7 @@

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

Definition at line 1386 of file nrf_to_nrf.cpp.

+

Definition at line 1398 of file nrf_to_nrf.cpp.

@@ -1415,7 +1415,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 1394 of file nrf_to_nrf.cpp.

+

Definition at line 1406 of file nrf_to_nrf.cpp.

@@ -1500,7 +1500,7 @@

diff --git a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 730ea69..37272c0 100644 --- a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -113,7 +113,7 @@ diff --git a/html/examples.html b/html/examples.html index 698c7e5..86434f1 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 7179336..a49755c 100644 --- a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html +++ b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html @@ -232,12 +232,12 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void printDetails()
+
void printDetails()
diff --git a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html index 4742335..839f2a3 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html @@ -198,18 +198,18 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
-
void setKey(uint8_t key[CCM_KEY_SIZE])
+
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:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
@ NRF_PA_MIN
Definition nrf_to_nrf.h:50
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 f59c935..2e8c5ec 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html @@ -191,14 +191,14 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool isChipConnected()
@ NRF_PA_MIN
Definition nrf_to_nrf.h:50
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 5df3885..b3281ea 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html @@ -179,15 +179,15 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setKey(uint8_t key[CCM_KEY_SIZE])
+
void setKey(uint8_t key[CCM_KEY_SIZE])
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html index 28d621d..b8d7115 100644 --- a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html @@ -149,16 +149,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html index 6d5246a..eaa2e48 100644 --- a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html @@ -142,13 +142,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
+
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 838208f..1a53cf0 100644 --- a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html @@ -157,16 +157,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
bool begin()
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
diff --git a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html index ec0853f..8de355e 100644 --- a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html @@ -149,13 +149,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
+
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 1b72118..6a19a0f 100644 --- a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html +++ b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html @@ -290,25 +290,25 @@
}
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
+
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()
+
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)
+
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:62
diff --git a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html index 4c9a27e..2da32aa 100644 --- a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html +++ b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html @@ -253,25 +253,25 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
+
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])
+
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:467
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setPayloadSize(uint8_t size)
@ NRF_PA_LOW
Definition nrf_to_nrf.h:54
diff --git a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html index 20169b4..3191a98 100644 --- a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html +++ b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html @@ -239,23 +239,23 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
+
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 setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
bool begin()
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
-
uint8_t getPayloadSize()
+
void 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:54
diff --git a/html/examples_2RF24_2scanner_2scanner_8ino-example.html b/html/examples_2RF24_2scanner_2scanner_8ino-example.html index c27f071..b00f829 100644 --- a/html/examples_2RF24_2scanner_2scanner_8ino-example.html +++ b/html/examples_2RF24_2scanner_2scanner_8ino-example.html @@ -226,17 +226,17 @@
} //If constCarrierMode == 0
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
bool testCarrier(uint8_t RSSI=65)
-
void setChannel(uint8_t channel)
+
void startListening(bool resetAddresses=true)
+
bool testCarrier(uint8_t RSSI=65)
+
void setChannel(uint8_t channel)
bool begin()
-
void setAutoAck(bool enable)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setAutoAck(bool enable)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
diff --git a/html/files.html b/html/files.html index a0038b5..9c07c07 100644 --- a/html/files.html +++ b/html/files.html @@ -108,7 +108,7 @@ diff --git a/html/functions.html b/html/functions.html index d6c96ff..8e51a5e 100644 --- a/html/functions.html +++ b/html/functions.html @@ -230,7 +230,7 @@

- w -

    diff --git a/html/functions_func.html b/html/functions_func.html index cf0841d..509f016 100644 --- a/html/functions_func.html +++ b/html/functions_func.html @@ -221,7 +221,7 @@

    - w -

      diff --git a/html/functions_vars.html b/html/functions_vars.html index 1e568c4..8c12ee1 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 e7862c7..abe7b31 100644 --- a/html/globals.html +++ b/html/globals.html @@ -191,7 +191,7 @@

      - t -

        diff --git a/html/globals_defs.html b/html/globals_defs.html index a07a915..1f9b282 100644 --- a/html/globals_defs.html +++ b/html/globals_defs.html @@ -133,7 +133,7 @@ diff --git a/html/globals_enum.html b/html/globals_enum.html index 95b4006..5c08162 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 f47e96c..7ab9b3f 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 5324a59..c7d3cd7 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 dceed4e..f54cca1 100644 --- a/html/index.html +++ b/html/index.html @@ -101,7 +101,7 @@ diff --git a/html/nrf__to__nrf_8cpp.html b/html/nrf__to__nrf_8cpp.html index 48b6bee..3ef74db 100644 --- a/html/nrf__to__nrf_8cpp.html +++ b/html/nrf__to__nrf_8cpp.html @@ -268,7 +268,7 @@

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

        diff --git a/html/nrf__to__nrf_8h_source.html b/html/nrf__to__nrf_8h_source.html index 87c007a..39fade8 100644 --- a/html/nrf__to__nrf_8h_source.html +++ b/html/nrf__to__nrf_8h_source.html @@ -348,56 +348,56 @@
        515
        575#endif //__nrf52840_nrf24l01_H__
        Driver class for nRF52840 2.4GHz Wireless Transceiver.
        Definition nrf_to_nrf.h:115
        -
        void startListening(bool resetAddresses=true)
        -
        void openReadingPipe(uint8_t child, const uint8_t *address)
        - +
        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 testCarrier(uint8_t RSSI=65)
        -
        bool txStandBy()
        -
        uint8_t decrypt(void *bufferIn, uint8_t size)
        +
        void setPALevel(uint8_t level, bool lnaEnable=true)
        +
        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:207
        -
        void setChannel(uint8_t channel)
        +
        void setChannel(uint8_t channel)
        uint32_t addrConv32(uint32_t addr)
        -
        void disableDynamicPayloads()
        -
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        -
        bool testRPD(uint8_t RSSI=65)
        -
        void setCounter(uint64_t counter)
        -
        bool isChipConnected()
        -
        void setAddressWidth(uint8_t a_width)
        -
        uint8_t getDynamicPayloadSize()
        -
        bool setDataRate(uint8_t speed)
        -
        bool isValid()
        +
        void disableDynamicPayloads()
        +
        bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
        +
        bool testRPD(uint8_t RSSI=65)
        +
        void setCounter(uint64_t counter)
        +
        bool isChipConnected()
        +
        void setAddressWidth(uint8_t a_width)
        +
        uint8_t getDynamicPayloadSize()
        +
        bool setDataRate(uint8_t speed)
        +
        bool isValid()
        void enableDynamicAck()
        -
        void setKey(uint8_t key[CCM_KEY_SIZE])
        +
        void setKey(uint8_t key[CCM_KEY_SIZE])
        bool begin()
        -
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        +
        bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
        bool enableEncryption
        Definition nrf_to_nrf.h:467
        -
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        -
        void disableAckPayload()
        +
        void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
        +
        void disableAckPayload()
        void disableCRC()
        -
        void powerDown()
        -
        uint8_t getARC()
        -
        uint8_t encrypt(void *bufferIn, uint8_t size)
        -
        void printDetails()
        -
        uint8_t getChannel()
        -
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        +
        void powerDown()
        +
        uint8_t getARC()
        +
        uint8_t encrypt(void *bufferIn, uint8_t size)
        +
        void printDetails()
        +
        uint8_t getChannel()
        +
        bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
        uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
        Definition nrf_to_nrf.h:434
        -
        void setRetries(uint8_t retryVar, uint8_t attempts)
        -
        void enableAckPayload()
        -
        void openWritingPipe(const uint8_t *address)
        -
        void setCRCLength(nrf_crclength_e length)
        +
        void setRetries(uint8_t retryVar, uint8_t attempts)
        +
        void enableAckPayload()
        +
        void openWritingPipe(const uint8_t *address)
        +
        void setCRCLength(nrf_crclength_e length)
        bool failureDetected
        Definition nrf_to_nrf.h:370
        -
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        -
        uint8_t getPALevel()
        -
        void setAutoAck(bool enable)
        -
        void read(void *buf, uint8_t len)
        -
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        -
        void setIV(uint8_t IV[CCM_IV_SIZE])
        -
        void setPayloadSize(uint8_t size)
        -
        nrf_crclength_e getCRCLength()
        -
        uint8_t getPayloadSize()
        +
        bool writeFast(void *buf, uint8_t len, bool multicast=0)
        +
        uint8_t getPALevel()
        +
        void setAutoAck(bool enable)
        +
        void read(void *buf, uint8_t len)
        +
        void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
        +
        void setIV(uint8_t IV[CCM_IV_SIZE])
        +
        void setPayloadSize(uint8_t size)
        +
        nrf_crclength_e getCRCLength()
        +
        uint8_t getPayloadSize()
        #define CCM_MODE_LENGTH_EXTENDED
        Definition nrf_to_nrf.h:42
        #define DEFAULT_MAX_PAYLOAD_SIZE
        Definition nrf_to_nrf.h:20
        nrf_pa_dbm_e
        Definition nrf_to_nrf.h:46
        @@ -424,7 +424,7 @@

        diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index 6a602f2..22ac7f6 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -204,15 +204,21 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) NRF_RADIO->EVENTS_CRCOK = 0; if (DPL){ if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) { - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; }else if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) { - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; }else if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) { - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; } } @@ -299,7 +305,9 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) // duplicate if(NRF_RADIO->CRCCNF != 0) { //If CRC enabled, check this data if (packetCtr == lastPacketCounter && packetData == lastData) { - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; } } @@ -312,14 +320,18 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) if (DPL) { if (!decrypt(&rxBuffer[1], rxBuffer[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; } } else { if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); - NRF_RADIO->TASKS_START = 1; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 0; } } @@ -339,6 +351,9 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) lastPacketCounter = packetCtr; lastData = packetData; payloadAvailable = true; + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } return 1; } if(NRF_RADIO->EVENTS_CRCERROR) { @@ -354,9 +369,6 @@ void nrf_to_nrf::read(void* buf, uint8_t len) { memcpy(buf, &rxBuffer[1], len); ackPayloadAvailable = false; - if (inRxMode) { - NRF_RADIO->TASKS_START = 1; - } payloadAvailable = false; }