diff --git a/html/annotated.html b/html/annotated.html index 1530152..bd964db 100644 --- a/html/annotated.html +++ b/html/annotated.html @@ -105,7 +105,7 @@ diff --git a/html/classes.html b/html/classes.html index b7eb8a4..14372ff 100644 --- a/html/classes.html +++ b/html/classes.html @@ -106,7 +106,7 @@ diff --git a/html/classnrf__to__nrf-members.html b/html/classnrf__to__nrf-members.html index f2612d3..e23baf4 100644 --- a/html/classnrf__to__nrf-members.html +++ b/html/classnrf__to__nrf-members.html @@ -159,7 +159,7 @@ diff --git a/html/classnrf__to__nrf.html b/html/classnrf__to__nrf.html index 6ae6c0c..4879035 100644 --- a/html/classnrf__to__nrf.html +++ b/html/classnrf__to__nrf.html @@ -356,7 +356,7 @@

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

Definition at line 317 of file nrf_to_nrf.cpp.

+

Definition at line 319 of file nrf_to_nrf.cpp.

@@ -401,7 +401,7 @@

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

Definition at line 329 of file nrf_to_nrf.cpp.

+

Definition at line 331 of file nrf_to_nrf.cpp.

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

+

Definition at line 669 of file nrf_to_nrf.cpp.

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

+

Definition at line 692 of file nrf_to_nrf.cpp.

@@ -501,7 +501,7 @@

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

Definition at line 897 of file nrf_to_nrf.cpp.

+

Definition at line 899 of file nrf_to_nrf.cpp.

@@ -524,7 +524,7 @@

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

Definition at line 939 of file nrf_to_nrf.cpp.

+

Definition at line 941 of file nrf_to_nrf.cpp.

@@ -546,7 +546,7 @@

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

Definition at line 1015 of file nrf_to_nrf.cpp.

+

Definition at line 1017 of file nrf_to_nrf.cpp.

@@ -583,7 +583,7 @@

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

-

Definition at line 996 of file nrf_to_nrf.cpp.

+

Definition at line 998 of file nrf_to_nrf.cpp.

@@ -628,7 +628,7 @@

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

-

Definition at line 517 of file nrf_to_nrf.cpp.

+

Definition at line 519 of file nrf_to_nrf.cpp.

@@ -667,7 +667,7 @@

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

Definition at line 617 of file nrf_to_nrf.cpp.

+

Definition at line 619 of file nrf_to_nrf.cpp.

@@ -689,7 +689,7 @@

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

Definition at line 659 of file nrf_to_nrf.cpp.

+

Definition at line 661 of file nrf_to_nrf.cpp.

@@ -709,7 +709,7 @@

Same as NRF24

-

Definition at line 663 of file nrf_to_nrf.cpp.

+

Definition at line 665 of file nrf_to_nrf.cpp.

@@ -749,7 +749,7 @@

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

Definition at line 714 of file nrf_to_nrf.cpp.

+

Definition at line 716 of file nrf_to_nrf.cpp.

@@ -769,7 +769,7 @@

Same as NRF24

-

Definition at line 722 of file nrf_to_nrf.cpp.

+

Definition at line 724 of file nrf_to_nrf.cpp.

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

+

Definition at line 738 of file nrf_to_nrf.cpp.

@@ -812,7 +812,7 @@

Same as NRF24

-

Definition at line 740 of file nrf_to_nrf.cpp.

+

Definition at line 742 of file nrf_to_nrf.cpp.

@@ -833,7 +833,7 @@

Supported speeds: NRF_1MBPS NRF_2MBPS

-

Definition at line 1019 of file nrf_to_nrf.cpp.

+

Definition at line 1021 of file nrf_to_nrf.cpp.

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

+

Definition at line 1037 of file nrf_to_nrf.cpp.

@@ -887,7 +887,7 @@

Same as NRF24

-

Definition at line 1057 of file nrf_to_nrf.cpp.

+

Definition at line 1059 of file nrf_to_nrf.cpp.

@@ -910,7 +910,7 @@

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

Definition at line 744 of file nrf_to_nrf.cpp.

+

Definition at line 746 of file nrf_to_nrf.cpp.

@@ -941,7 +941,7 @@

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

Definition at line 757 of file nrf_to_nrf.cpp.

+

Definition at line 759 of file nrf_to_nrf.cpp.

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

+

Definition at line 770 of file nrf_to_nrf.cpp.

@@ -990,7 +990,7 @@

Same as NRF24

-

Definition at line 788 of file nrf_to_nrf.cpp.

+

Definition at line 790 of file nrf_to_nrf.cpp.

@@ -1013,7 +1013,7 @@

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

Definition at line 803 of file nrf_to_nrf.cpp.

+

Definition at line 805 of file nrf_to_nrf.cpp.

@@ -1035,7 +1035,7 @@

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

Definition at line 819 of file nrf_to_nrf.cpp.

+

Definition at line 821 of file nrf_to_nrf.cpp.

@@ -1056,7 +1056,7 @@

Same as NRF24

-

Definition at line 1088 of file nrf_to_nrf.cpp.

+

Definition at line 1090 of file nrf_to_nrf.cpp.

@@ -1076,7 +1076,7 @@

Same as NRF24

-

Definition at line 1110 of file nrf_to_nrf.cpp.

+

Definition at line 1112 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 826 of file nrf_to_nrf.cpp.

+

Definition at line 828 of file nrf_to_nrf.cpp.

@@ -1156,7 +1156,7 @@

Same as NRF24

-

Definition at line 835 of file nrf_to_nrf.cpp.

+

Definition at line 837 of file nrf_to_nrf.cpp.

@@ -1177,7 +1177,7 @@

Same as NRF24

-

Definition at line 876 of file nrf_to_nrf.cpp.

+

Definition at line 878 of file nrf_to_nrf.cpp.

@@ -1198,7 +1198,7 @@

Same as NRF24

-

Definition at line 1162 of file nrf_to_nrf.cpp.

+

Definition at line 1164 of file nrf_to_nrf.cpp.

@@ -1220,7 +1220,7 @@

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

Definition at line 1177 of file nrf_to_nrf.cpp.

+

Definition at line 1179 of file nrf_to_nrf.cpp.

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

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

-

Definition at line 1147 of file nrf_to_nrf.cpp.

+

Definition at line 1149 of file nrf_to_nrf.cpp.

@@ -1260,7 +1260,7 @@

When called ALL radio settings will be reverted to default

-

Definition at line 1155 of file nrf_to_nrf.cpp.

+

Definition at line 1157 of file nrf_to_nrf.cpp.

@@ -1281,7 +1281,7 @@

Definition at line 959 of file nrf_to_nrf.cpp.

+

Definition at line 961 of file nrf_to_nrf.cpp.

@@ -1313,7 +1313,7 @@

Definition at line 977 of file nrf_to_nrf.cpp.

+

Definition at line 979 of file nrf_to_nrf.cpp.

@@ -1341,7 +1341,7 @@

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

Definition at line 1125 of file nrf_to_nrf.cpp.

+

Definition at line 1127 of file nrf_to_nrf.cpp.

@@ -1367,7 +1367,7 @@

Definition at line 1140 of file nrf_to_nrf.cpp.

+

Definition at line 1142 of file nrf_to_nrf.cpp.

@@ -1387,7 +1387,7 @@

Same as NRF24

-

Definition at line 1081 of file nrf_to_nrf.cpp.

+

Definition at line 1083 of file nrf_to_nrf.cpp.

@@ -1459,7 +1459,7 @@

Function to encrypt data

-

Definition at line 1271 of file nrf_to_nrf.cpp.

+

Definition at line 1273 of file nrf_to_nrf.cpp.

@@ -1490,7 +1490,7 @@

Function to decrypt data

-

Definition at line 1303 of file nrf_to_nrf.cpp.

+

Definition at line 1305 of file nrf_to_nrf.cpp.

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

+

Definition at line 1338 of file nrf_to_nrf.cpp.

@@ -1536,7 +1536,7 @@

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

Definition at line 1344 of file nrf_to_nrf.cpp.

+

Definition at line 1346 of file nrf_to_nrf.cpp.

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

+

Definition at line 1354 of file nrf_to_nrf.cpp.

@@ -1642,7 +1642,7 @@

diff --git a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index a540933..7adaad7 100644 --- a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -111,7 +111,7 @@ diff --git a/html/examples.html b/html/examples.html index 001e254..201f9f5 100644 --- a/html/examples.html +++ b/html/examples.html @@ -107,7 +107,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 4f9fa37..0b0f459 100644 --- a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html +++ b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html @@ -230,12 +230,12 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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 6ede62d..62d385e 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html @@ -196,18 +196,18 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:455
-
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:40
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 483cce3..8f752c7 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html @@ -189,14 +189,14 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:40
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 47802b2..e79842a 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 @@ -177,15 +177,15 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:455
-
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 1d16492..ab8f7b0 100644 --- a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html @@ -147,16 +147,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:455
-
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 6cdfa84..51960ce 100644 --- a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html @@ -140,13 +140,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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 7f7b54d..200bfc0 100644 --- a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html @@ -155,16 +155,16 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:455
-
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 96ee49f..859c429 100644 --- a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html @@ -147,13 +147,13 @@
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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 7074a90..9765126 100644 --- a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html +++ b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html @@ -288,25 +288,25 @@
}
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:52
diff --git a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html index fa6f6a8..4704477 100644 --- a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html +++ b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html @@ -251,25 +251,25 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:455
-
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:44
diff --git a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html index d3eeb90..8ba9a0e 100644 --- a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html +++ b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html @@ -237,23 +237,23 @@
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:105
-
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:44
diff --git a/html/examples_2RF24_2scanner_2scanner_8ino-example.html b/html/examples_2RF24_2scanner_2scanner_8ino-example.html index 1e76b12..1b2426f 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:105
-
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 47b9699..68e0de4 100644 --- a/html/files.html +++ b/html/files.html @@ -106,7 +106,7 @@ diff --git a/html/functions.html b/html/functions.html index b2fc7cd..315a07d 100644 --- a/html/functions.html +++ b/html/functions.html @@ -229,7 +229,7 @@

- w -

    diff --git a/html/functions_func.html b/html/functions_func.html index 02b0ab2..7ad30d0 100644 --- a/html/functions_func.html +++ b/html/functions_func.html @@ -220,7 +220,7 @@

    - w -

      diff --git a/html/functions_vars.html b/html/functions_vars.html index 6093526..f395961 100644 --- a/html/functions_vars.html +++ b/html/functions_vars.html @@ -110,7 +110,7 @@ diff --git a/html/globals.html b/html/globals.html index 62fc8e9..c9b0ea0 100644 --- a/html/globals.html +++ b/html/globals.html @@ -178,7 +178,7 @@

      - n -

        diff --git a/html/globals_defs.html b/html/globals_defs.html index d54fff1..c190cfd 100644 --- a/html/globals_defs.html +++ b/html/globals_defs.html @@ -125,7 +125,7 @@ diff --git a/html/globals_enum.html b/html/globals_enum.html index 5153eee..5b7d75e 100644 --- a/html/globals_enum.html +++ b/html/globals_enum.html @@ -110,7 +110,7 @@ diff --git a/html/globals_eval.html b/html/globals_eval.html index 90003d6..928ca51 100644 --- a/html/globals_eval.html +++ b/html/globals_eval.html @@ -118,7 +118,7 @@ diff --git a/html/globals_func.html b/html/globals_func.html index d60c1f0..a57462a 100644 --- a/html/globals_func.html +++ b/html/globals_func.html @@ -109,7 +109,7 @@ diff --git a/html/index.html b/html/index.html index 8135cda..d64e4b7 100644 --- a/html/index.html +++ b/html/index.html @@ -98,7 +98,7 @@ diff --git a/html/nrf__to__nrf_8cpp.html b/html/nrf__to__nrf_8cpp.html index 3c447c3..37830d3 100644 --- a/html/nrf__to__nrf_8cpp.html +++ b/html/nrf__to__nrf_8cpp.html @@ -196,7 +196,7 @@

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

        diff --git a/html/nrf__to__nrf_8h_source.html b/html/nrf__to__nrf_8h_source.html index b6a5381..b66b5a7 100644 --- a/html/nrf__to__nrf_8h_source.html +++ b/html/nrf__to__nrf_8h_source.html @@ -334,57 +334,57 @@
        503
        563#endif //__nrf52840_nrf24l01_H__
        Driver class for nRF52840 2.4GHz Wireless Transceiver.
        Definition nrf_to_nrf.h:105
        -
        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)
        +
        void setPALevel(uint8_t level, bool lnaEnable=true)
        uint8_t sample_ed(void)
        -
        bool testCarrier(uint8_t RSSI=65)
        -
        bool txStandBy()
        -
        uint8_t decrypt(void *bufferIn, uint8_t size)
        +
        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:197
        -
        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:455
        -
        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:422
        -
        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:360
        -
        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:32
        #define DEFAULT_MAX_PAYLOAD_SIZE
        Definition nrf_to_nrf.h:12
        nrf_pa_dbm_e
        Definition nrf_to_nrf.h:36
        @@ -411,7 +411,7 @@

        diff --git a/library.json b/library.json index 2317f9d..b8c66c7 100644 --- a/library.json +++ b/library.json @@ -7,7 +7,7 @@ "type": "git", "url": "https://github.com/TMRh20/nrf_to_nrf" }, - "version": "1.2.8", + "version": "1.2.9", "export": { "exclude": [ ".github/*" diff --git a/library.properties b/library.properties index c90ddf6..2be5f0a 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=nrf_to_nrf -version=1.2.8 +version=1.2.9 author=TMRh20 maintainer=TMRh20 sentence=NRF52840 to NRF24L01+ ESB communication diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index c7f1cfb..0f32a49 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -181,6 +181,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) uint8_t tmpIV[CCM_IV_SIZE]; NRF_RADIO->EVENTS_CRCOK = 0; if (DPL && radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4) { + NRF_RADIO->TASKS_START = 1; return 0; } *pipe_num = (uint8_t)NRF_RADIO->RXMATCH; @@ -277,12 +278,14 @@ 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; return 0; } } else { if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); + NRF_RADIO->TASKS_START = 1; return 0; } } @@ -304,11 +307,10 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) payloadAvailable = true; return 1; } - if (NRF_RADIO->EVENTS_CRCERROR) { + if(NRF_RADIO->EVENTS_CRCERROR) { NRF_RADIO->EVENTS_CRCERROR = 0; NRF_RADIO->TASKS_START = 1; } - return 0; }