From 7000009c1b7217b60d3558cbd5bf76e17016e2f9 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Wed, 3 Jul 2024 23:54:52 +0000 Subject: [PATCH] deploy: bf0c86054f65bbe832be3e85ba2f0c2d5d3788a9 --- html/annotated.html | 20 +- html/classes.html | 20 +- html/classnrf__to__nrf-members.html | 91 +- html/classnrf__to__nrf.html | 246 +- .../dir_68267d1309a1af8e8297ef4c3efbcdba.html | 20 +- html/doxygen.css | 31 +- html/doxygen_crawl.html | 128 +- html/dynsections.js | 4 + html/examples.html | 20 +- ..._2mqtt_basic_2mqtt_basic_8ino-example.html | 22 +- ...24Mesh_ExampleEncryption_8ino-example.html | 32 +- ...xample_2RF24Mesh_Example_8ino-example.html | 24 +- ...Example_MasterEncryption_8ino-example.html | 28 +- ...2helloworld_rxEncryption_8ino-example.html | 30 +- ...oworld_rx_2helloworld_rx_8ino-example.html | 24 +- ...2helloworld_txEncryption_8ino-example.html | 30 +- ...oworld_tx_2helloworld_tx_8ino-example.html | 24 +- ...2AcknowledgementPayloads_8ino-example.html | 46 +- ...GettingStartedEncryption_8ino-example.html | 46 +- ...gStarted_2GettingStarted_8ino-example.html | 42 +- ..._2RF24_2scanner_2scanner_8ino-example.html | 32 +- html/files.html | 20 +- html/functions.html | 21 +- html/functions_func.html | 21 +- html/functions_vars.html | 20 +- html/globals.html | 20 +- html/globals_defs.html | 20 +- html/globals_enum.html | 20 +- html/globals_eval.html | 20 +- html/globals_func.html | 20 +- html/index.html | 20 +- html/navtree.css | 149 + html/nrf__to__nrf_8cpp.html | 20 +- html/nrf__to__nrf_8cpp_source.html | 2776 +++++++++-------- html/nrf__to__nrf_8h.html | 20 +- html/nrf__to__nrf_8h_source.html | 461 +-- html/resize.js | 145 + html/search/all_6.js | 3 +- html/search/all_9.js | 9 +- html/search/functions_4.js | 3 +- src/nrf_to_nrf.cpp | 246 +- src/nrf_to_nrf.h | 70 +- 42 files changed, 2997 insertions(+), 2067 deletions(-) create mode 100644 html/navtree.css create mode 100644 html/resize.js diff --git a/html/annotated.html b/html/annotated.html index d5568da..74dfe2c 100644 --- a/html/annotated.html +++ b/html/annotated.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Class List + + @@ -39,11 +41,16 @@ - + + +
+
+
diff --git a/html/classes.html b/html/classes.html index 896a9f8..aaeba3c 100644 --- a/html/classes.html +++ b/html/classes.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Class Index + + @@ -39,11 +41,16 @@
- + + +
+
+
diff --git a/html/classnrf__to__nrf-members.html b/html/classnrf__to__nrf-members.html index 6d06f08..9378445 100644 --- a/html/classnrf__to__nrf-members.html +++ b/html/classnrf__to__nrf-members.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Member List + + @@ -39,11 +41,16 @@
- + + +
+
nrf_to_nrf Member List
@@ -122,45 +135,47 @@ getDynamicPayloadSize()nrf_to_nrf getPALevel()nrf_to_nrf getPayloadSize()nrf_to_nrf - isChipConnected()nrf_to_nrf - isValid()nrf_to_nrf - nrf_to_nrf()nrf_to_nrf - openReadingPipe(uint8_t child, const uint8_t *address)nrf_to_nrf - openReadingPipe(uint8_t child, uint64_t address)nrf_to_nrf - openWritingPipe(const uint8_t *address)nrf_to_nrf - openWritingPipe(uint64_t address)nrf_to_nrf - outBuffernrf_to_nrf - powerDown()nrf_to_nrf - powerUp()nrf_to_nrf - printDetails()nrf_to_nrf - radioDatanrf_to_nrf - read(void *buf, uint8_t len)nrf_to_nrf - setAddressWidth(uint8_t a_width)nrf_to_nrf - setAutoAck(bool enable)nrf_to_nrf - setAutoAck(uint8_t pipe, bool enable)nrf_to_nrf - setChannel(uint8_t channel)nrf_to_nrf - setCounter(uint64_t counter)nrf_to_nrf - setCRCLength(nrf_crclength_e length)nrf_to_nrf - setDataRate(uint8_t speed)nrf_to_nrf - setIV(uint8_t IV[CCM_IV_SIZE])nrf_to_nrf - setKey(uint8_t key[CCM_KEY_SIZE])nrf_to_nrf - setPALevel(uint8_t level, bool lnaEnable=true)nrf_to_nrf - setPayloadSize(uint8_t size)nrf_to_nrf - setRetries(uint8_t retryVar, uint8_t attempts)nrf_to_nrf - startListening(bool resetAddresses=true)nrf_to_nrf - startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)nrf_to_nrf - stopListening(bool setWritingPipe=true, bool resetAddresses=true)nrf_to_nrf - testCarrier(uint8_t RSSI=65)nrf_to_nrf - testRPD(uint8_t RSSI=65)nrf_to_nrf - txStandBy()nrf_to_nrf - txStandBy(uint32_t timeout, bool startTx=0)nrf_to_nrf - write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)nrf_to_nrf - writeAckPayload(uint8_t pipe, void *buf, uint8_t len)nrf_to_nrf - writeFast(void *buf, uint8_t len, bool multicast=0)nrf_to_nrf + getRSSI()nrf_to_nrf + isChipConnected()nrf_to_nrf + isValid()nrf_to_nrf + nrf_to_nrf()nrf_to_nrf + openReadingPipe(uint8_t child, const uint8_t *address)nrf_to_nrf + openReadingPipe(uint8_t child, uint64_t address)nrf_to_nrf + openWritingPipe(const uint8_t *address)nrf_to_nrf + openWritingPipe(uint64_t address)nrf_to_nrf + outBuffernrf_to_nrf + powerDown()nrf_to_nrf + powerUp()nrf_to_nrf + printDetails()nrf_to_nrf + radioDatanrf_to_nrf + read(void *buf, uint8_t len)nrf_to_nrf + setAddressWidth(uint8_t a_width)nrf_to_nrf + setAutoAck(bool enable)nrf_to_nrf + setAutoAck(uint8_t pipe, bool enable)nrf_to_nrf + setChannel(uint8_t channel)nrf_to_nrf + setCounter(uint64_t counter)nrf_to_nrf + setCRCLength(nrf_crclength_e length)nrf_to_nrf + setDataRate(uint8_t speed)nrf_to_nrf + setIV(uint8_t IV[CCM_IV_SIZE])nrf_to_nrf + setKey(uint8_t key[CCM_KEY_SIZE])nrf_to_nrf + setPALevel(uint8_t level, bool lnaEnable=true)nrf_to_nrf + setPayloadSize(uint8_t size)nrf_to_nrf + setRetries(uint8_t retryVar, uint8_t attempts)nrf_to_nrf + startListening(bool resetAddresses=true)nrf_to_nrf + startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)nrf_to_nrf + stopListening(bool setWritingPipe=true, bool resetAddresses=true)nrf_to_nrf + testCarrier(uint8_t RSSI=65)nrf_to_nrf + testRPD(uint8_t RSSI=65)nrf_to_nrf + txStandBy()nrf_to_nrf + txStandBy(uint32_t timeout, bool startTx=0)nrf_to_nrf + write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)nrf_to_nrf + writeAckPayload(uint8_t pipe, void *buf, uint8_t len)nrf_to_nrf + writeFast(void *buf, uint8_t len, bool multicast=0)nrf_to_nrf
+ diff --git a/html/classnrf__to__nrf.html b/html/classnrf__to__nrf.html index a65cef5..6ae0fc7 100644 --- a/html/classnrf__to__nrf.html +++ b/html/classnrf__to__nrf.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: nrf_to_nrf Class Reference + + @@ -39,11 +41,16 @@ - + + +
+
@@ -292,7 +307,7 @@

bool nrf_to_nrf::available ( - ) + ) @@ -301,7 +316,7 @@

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

Definition at line 177 of file nrf_to_nrf.cpp.

+

Definition at line 172 of file nrf_to_nrf.cpp.

@@ -321,7 +336,7 @@

Same as NRF24 radio.available();

-

Definition at line 185 of file nrf_to_nrf.cpp.

+

Definition at line 180 of file nrf_to_nrf.cpp.

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

void nrf_to_nrf::read ( - void * buf, + void * buf, @@ -347,7 +362,7 @@

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

Definition at line 368 of file nrf_to_nrf.cpp.

+

Definition at line 363 of file nrf_to_nrf.cpp.

@@ -360,22 +375,22 @@

bool nrf_to_nrf::write ( - void * buf, + void * buf, - uint8_t len, + uint8_t len, - bool multicast = false, + bool multicast = false, - bool doEncryption = true ) + bool doEncryption = true ) @@ -396,7 +411,7 @@

void nrf_to_nrf::startListening ( - bool resetAddresses = true) + bool resetAddresses = true) @@ -410,7 +425,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 716 of file nrf_to_nrf.cpp.

+

Definition at line 714 of file nrf_to_nrf.cpp.

@@ -423,12 +438,12 @@

void nrf_to_nrf::stopListening ( - bool setWritingPipe = true, + bool setWritingPipe = true, - bool resetAddresses = true ) + bool resetAddresses = true ) @@ -455,7 +470,7 @@

void nrf_to_nrf::openReadingPipe ( - uint8_t child, + uint8_t child, @@ -468,7 +483,7 @@

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

Definition at line 946 of file nrf_to_nrf.cpp.

+

Definition at line 944 of file nrf_to_nrf.cpp.

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

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

Definition at line 988 of file nrf_to_nrf.cpp.

+

Definition at line 986 of file nrf_to_nrf.cpp.

@@ -503,7 +518,7 @@

bool nrf_to_nrf::isChipConnected ( - ) + ) @@ -512,7 +527,7 @@

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

Definition at line 1064 of file nrf_to_nrf.cpp.

+

Definition at line 1065 of file nrf_to_nrf.cpp.

@@ -525,23 +540,23 @@

bool nrf_to_nrf::writeFast ( - void * buf, + void * buf, - uint8_t len, + uint8_t len, - bool multicast = 0 ) + bool multicast = 0 )

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

-

Definition at line 1045 of file nrf_to_nrf.cpp.

+

Definition at line 1046 of file nrf_to_nrf.cpp.

@@ -554,22 +569,22 @@

bool nrf_to_nrf::startWrite ( - void * buf, + void * buf, - uint8_t len, + uint8_t len, - bool multicast, + bool multicast, - bool doEncryption = true ) + bool doEncryption = true )
@@ -577,7 +592,7 @@

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

-

Definition at line 566 of file nrf_to_nrf.cpp.

+

Definition at line 565 of file nrf_to_nrf.cpp.

@@ -590,12 +605,12 @@

bool nrf_to_nrf::writeAckPayload ( - uint8_t pipe, + uint8_t pipe, - void * buf, + void * buf, @@ -608,7 +623,7 @@

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

Definition at line 666 of file nrf_to_nrf.cpp.

+

Definition at line 663 of file nrf_to_nrf.cpp.

@@ -621,7 +636,7 @@

void nrf_to_nrf::enableAckPayload ( - ) + ) @@ -630,7 +645,7 @@

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

Definition at line 708 of file nrf_to_nrf.cpp.

+

Definition at line 706 of file nrf_to_nrf.cpp.

@@ -643,14 +658,14 @@

void nrf_to_nrf::disableAckPayload ( - ) + ) @@ -663,7 +678,7 @@

void nrf_to_nrf::enableDynamicAck ( - ) + ) @@ -681,7 +696,7 @@

uint8_t nrf_to_nrf::getDynamicPayloadSize ( - ) + ) @@ -690,7 +705,7 @@

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

Definition at line 763 of file nrf_to_nrf.cpp.

+

Definition at line 761 of file nrf_to_nrf.cpp.

@@ -703,14 +718,14 @@

bool nrf_to_nrf::isValid ( - ) + ) @@ -732,7 +747,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 785 of file nrf_to_nrf.cpp.

+

Definition at line 783 of file nrf_to_nrf.cpp.

@@ -745,14 +760,14 @@

uint8_t nrf_to_nrf::getChannel ( - ) + ) @@ -772,7 +787,7 @@

Supported speeds: NRF_1MBPS NRF_2MBPS

-

Definition at line 1068 of file nrf_to_nrf.cpp.

+

Definition at line 1069 of file nrf_to_nrf.cpp.

@@ -785,12 +800,12 @@

void nrf_to_nrf::setPALevel ( - uint8_t level, + uint8_t level, - bool lnaEnable = true ) + bool lnaEnable = true ) @@ -812,14 +827,14 @@

uint8_t nrf_to_nrf::getPALevel ( - ) + ) @@ -841,7 +856,7 @@

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

Definition at line 793 of file nrf_to_nrf.cpp.

+

Definition at line 791 of file nrf_to_nrf.cpp.

@@ -854,7 +869,7 @@

void nrf_to_nrf::setAutoAck ( - uint8_t pipe, + uint8_t pipe, @@ -865,7 +880,7 @@

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

Definition at line 806 of file nrf_to_nrf.cpp.

+

Definition at line 804 of file nrf_to_nrf.cpp.

@@ -878,7 +893,7 @@

void nrf_to_nrf::enableDynamicPayloads ( - uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE) + uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE) @@ -893,7 +908,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 817 of file nrf_to_nrf.cpp.

+

Definition at line 815 of file nrf_to_nrf.cpp.

@@ -906,14 +921,14 @@

void nrf_to_nrf::disableDynamicPayloads ( - ) + ) @@ -935,7 +950,7 @@

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

Definition at line 852 of file nrf_to_nrf.cpp.

+

Definition at line 850 of file nrf_to_nrf.cpp.

@@ -948,7 +963,7 @@

uint8_t nrf_to_nrf::getPayloadSize ( - ) + ) @@ -957,7 +972,7 @@

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

Definition at line 868 of file nrf_to_nrf.cpp.

+

Definition at line 866 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1142 of file nrf_to_nrf.cpp.

+

Definition at line 1143 of file nrf_to_nrf.cpp.

@@ -990,14 +1005,14 @@

nrf_crclength_e nrf_to_nrf::getCRCLength ( - ) + )

Same as NRF24

-

Definition at line 1164 of file nrf_to_nrf.cpp.

+

Definition at line 1165 of file nrf_to_nrf.cpp.

@@ -1010,7 +1025,7 @@

void nrf_to_nrf::disableCRC ( - ) + ) @@ -1028,7 +1043,7 @@

void nrf_to_nrf::setRetries ( - uint8_t retryVar, + uint8_t retryVar, @@ -1039,7 +1054,7 @@

Same as NRF24

-

Definition at line 875 of file nrf_to_nrf.cpp.

+

Definition at line 873 of file nrf_to_nrf.cpp.

@@ -1052,7 +1067,7 @@

void nrf_to_nrf::openReadingPipe ( - uint8_t child, + uint8_t child, @@ -1063,7 +1078,7 @@

Same as NRF24

-

Definition at line 884 of file nrf_to_nrf.cpp.

+

Definition at line 882 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 925 of file nrf_to_nrf.cpp.

+

Definition at line 923 of file nrf_to_nrf.cpp.

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

Same as NRF24

-

Definition at line 1216 of file nrf_to_nrf.cpp.

+

Definition at line 1226 of file nrf_to_nrf.cpp.

@@ -1116,7 +1131,7 @@

void nrf_to_nrf::printDetails ( - ) + ) @@ -1125,7 +1140,7 @@

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

Definition at line 1231 of file nrf_to_nrf.cpp.

+

Definition at line 1241 of file nrf_to_nrf.cpp.

@@ -1138,14 +1153,14 @@

void nrf_to_nrf::powerUp ( - ) + ) @@ -1158,14 +1173,14 @@

void nrf_to_nrf::powerDown ( - ) + ) @@ -1178,7 +1193,7 @@

bool nrf_to_nrf::txStandBy ( - ) + ) @@ -1186,7 +1201,7 @@

Definition at line 1008 of file nrf_to_nrf.cpp.

+

Definition at line 1006 of file nrf_to_nrf.cpp.

@@ -1199,12 +1214,12 @@

bool nrf_to_nrf::txStandBy ( - uint32_t timeout, + uint32_t timeout, - bool startTx = 0 ) + bool startTx = 0 ) @@ -1251,7 +1266,7 @@

bool nrf_to_nrf::testRPD ( - uint8_t RSSI = 65) + uint8_t RSSI = 65) @@ -1263,7 +1278,27 @@

Definition at line 1194 of file nrf_to_nrf.cpp.

+

Definition at line 1195 of file nrf_to_nrf.cpp.

+ + + + +

◆ getRSSI()

+ +
+
+ + + + + + + +
uint8_t nrf_to_nrf::getRSSI ()
+
+

A new function specific to the NRF52x devices, not available on NRF24

Returns
The function will return the RSSI, which is measured continuously and the value filtered using a single-pole IIR filter. This is a negative value: received signal strength = -A dBm
+ +

Definition at line 1202 of file nrf_to_nrf.cpp.

@@ -1276,14 +1311,14 @@

uint8_t nrf_to_nrf::getARC ( - ) + ) @@ -1316,7 +1351,7 @@

uint8_t nrf_to_nrf::encrypt ( - void * bufferIn, + void * bufferIn, @@ -1327,7 +1362,7 @@

Function to encrypt data

-

Definition at line 1325 of file nrf_to_nrf.cpp.

+

Definition at line 1335 of file nrf_to_nrf.cpp.

@@ -1340,7 +1375,7 @@

uint8_t nrf_to_nrf::decrypt ( - void * bufferIn, + void * bufferIn, @@ -1351,7 +1386,7 @@

Function to decrypt data

-

Definition at line 1357 of file nrf_to_nrf.cpp.

+

Definition at line 1367 of file nrf_to_nrf.cpp.

@@ -1364,7 +1399,7 @@

void nrf_to_nrf::setKey ( - uint8_t key[CCM_KEY_SIZE]) + uint8_t key[CCM_KEY_SIZE]) @@ -1373,7 +1408,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 1390 of file nrf_to_nrf.cpp.

+

Definition at line 1400 of file nrf_to_nrf.cpp.

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

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

Definition at line 1398 of file nrf_to_nrf.cpp.

+

Definition at line 1408 of file nrf_to_nrf.cpp.

@@ -1408,14 +1443,14 @@

void nrf_to_nrf::setIV ( - uint8_t IV[CCM_IV_SIZE]) + uint8_t IV[CCM_IV_SIZE]) @@ -1433,7 +1468,7 @@

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

-

Definition at line 207 of file nrf_to_nrf.h.

+

Definition at line 204 of file nrf_to_nrf.h.

@@ -1450,7 +1485,7 @@

Not implemented due to SOC

-

Definition at line 370 of file nrf_to_nrf.h.

+

Definition at line 366 of file nrf_to_nrf.h.

@@ -1467,7 +1502,7 @@

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

-

Definition at line 434 of file nrf_to_nrf.h.

+

Definition at line 437 of file nrf_to_nrf.h.

@@ -1489,7 +1524,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 467 of file nrf_to_nrf.h.

+

Definition at line 470 of file nrf_to_nrf.h.

@@ -1500,7 +1535,8 @@

+ diff --git a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html index 37272c0..f07d6f5 100644 --- a/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html +++ b/html/dir_68267d1309a1af8e8297ef4c3efbcdba.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: src Directory Reference + + @@ -39,11 +41,16 @@ - + + + +
src Directory Reference
@@ -113,7 +126,8 @@
+ diff --git a/html/doxygen.css b/html/doxygen.css index 9cf4f26..d6d0679 100644 --- a/html/doxygen.css +++ b/html/doxygen.css @@ -1,4 +1,4 @@ -/* The standard CSS for doxygen 1.10.0*/ +/* The standard CSS for doxygen 1.11.0*/ html { /* page base colors */ @@ -655,7 +655,24 @@ dl.el { margin-left: -1cm; } +ul.check { + list-style:none; + text-indent: -16px; + padding-left: 38px; +} +li.unchecked:before { + content: "\2610\A0"; +} +li.checked:before { + content: "\2611\A0"; +} + +ol { + text-indent: 0px; +} + ul { + text-indent: 0px; overflow: visible; } @@ -1612,7 +1629,7 @@ dl.note { border-color: #D0C000; } -dl.warning, dl.attention { +dl.warning, dl.attention, dl.important { margin-left: -7px; padding-left: 3px; border-left: 4px solid; @@ -1660,7 +1677,7 @@ dl.bug dt a, dl.deprecated dt a, dl.todo dt a, dl.test a { font-weight: bold !important; } -dl.warning, dl.attention, dl.note, dl.deprecated, dl.bug, +dl.warning, dl.attention, dl.important, dl.note, dl.deprecated, dl.bug, dl.invariant, dl.pre, dl.post, dl.todo, dl.test, dl.remark { padding: 10px; margin: 10px 0px; @@ -1673,13 +1690,13 @@ dl.section dd { margin-bottom: 2px; } -dl.warning, dl.attention { +dl.warning, dl.attention, dl.important { background: var(--warning-color-bg); border-left: 8px solid var(--warning-color-hl); color: var(--warning-color-text); } -dl.warning dt, dl.attention dt { +dl.warning dt, dl.attention dt, dl.important dt { color: var(--warning-color-hl); } @@ -1737,7 +1754,9 @@ dl.deprecated dt a { color: var(--deprecated-color-hl) !important; } -dl.section dd, dl.bug dd, dl.deprecated dd, dl.todo dd, dl.test dd { +dl.note dd, dl.warning dd, dl.pre dd, dl.post dd, +dl.remark dd, dl.attention dd, dl.important dd, dl.invariant dd, +dl.bug dd, dl.deprecated dd, dl.todo dd, dl.test dd { margin-inline-start: 0px; } diff --git a/html/doxygen_crawl.html b/html/doxygen_crawl.html index 698aa78..74f34bd 100644 --- a/html/doxygen_crawl.html +++ b/html/doxygen_crawl.html @@ -4,7 +4,7 @@ Validator / crawler helper - + @@ -83,5 +83,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/html/dynsections.js b/html/dynsections.js index 24dfe9c..8985f42 100644 --- a/html/dynsections.js +++ b/html/dynsections.js @@ -23,6 +23,10 @@ @licend The above is the entire license notice for the JavaScript code in this file */ +function toggleVisibility(linkObj) { + return dynsection.toggleVisibility(linkObj); +} + let dynsection = { // helper function diff --git a/html/examples.html b/html/examples.html index 86434f1..53503f9 100644 --- a/html/examples.html +++ b/html/examples.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Examples + + @@ -39,11 +41,16 @@ - + + +
+
+
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 a49755c..8967eb0 100644 --- a/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html +++ b/html/examples_2RF24Ethernet_2mqtt_basic_2mqtt_basic_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Ethernet/mqtt_basic/mqtt_basic.ino + + @@ -39,11 +41,16 @@
- + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void printDetails()
+
void printDetails()
+ diff --git a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html index 839f2a3..729dcdf 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_ExampleEncryption_2RF24Mesh_ExampleEncryption_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_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:470
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
@ NRF_PA_MIN
Definition nrf_to_nrf.h:50
+ diff --git a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html index 2e8c5ec..b6a8d57 100644 --- a/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html +++ b/html/examples_2RF24Mesh_2RF24Mesh_Example_2RF24Mesh_Example_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Mesh/RF24Mesh_Example/RF24Mesh_Example.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool isChipConnected()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool isChipConnected()
@ NRF_PA_MIN
Definition nrf_to_nrf.h:50
+ diff --git a/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html b/html/examples_2RF24Mesh_2RF24Mesh_Example_MasterEncryption_2RF24Mesh_Example_MasterEncryption_8ino-example.html index b3281ea..80fbebe 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 @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Mesh/RF24Mesh_Example_MasterEncryption/RF24Mesh_Example_MasterEncryption.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:470
+
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 b8d7115..7c1cf43 100644 --- a/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rxEncryption_2helloworld_rxEncryption_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:470
+
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 eaa2e48..816f100 100644 --- a/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_rx_2helloworld_rx_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Network/helloworld_rx/helloworld_rx.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
bool begin()
+
void setChannel(uint8_t channel)
+
bool begin()
+ diff --git a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html index 1a53cf0..5c2cce8 100644 --- a/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_txEncryption_2helloworld_txEncryption_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void setChannel(uint8_t channel)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:470
+
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 8de355e..646136d 100644 --- a/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html +++ b/html/examples_2RF24Network_2helloworld_tx_2helloworld_tx_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24Network/helloworld_tx/helloworld_tx.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void setChannel(uint8_t channel)
-
bool begin()
+
void setChannel(uint8_t channel)
+
bool begin()
+ diff --git a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html index 6a19a0f..13a1792 100644 --- a/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html +++ b/html/examples_2RF24_2AcknowledgementPayloads_2AcknowledgementPayloads_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24/AcknowledgementPayloads/AcknowledgementPayloads.ino + + @@ -39,11 +41,16 @@ - + + +
+
}
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
uint8_t getDynamicPayloadSize()
-
bool begin()
-
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
-
void enableAckPayload()
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
uint8_t getDynamicPayloadSize()
+
bool begin()
+
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void enableAckPayload()
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
@ NRF_PA_MAX
Definition nrf_to_nrf.h:62
+ diff --git a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html index 2da32aa..687984c 100644 --- a/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html +++ b/html/examples_2RF24_2GettingStartedEncryption_2GettingStartedEncryption_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24/GettingStartedEncryption/GettingStartedEncryption.ino + + @@ -39,11 +41,16 @@ - + + +
+
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
void setCounter(uint64_t counter)
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
void setCounter(uint64_t counter)
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool enableEncryption
Definition nrf_to_nrf.h:470
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setPayloadSize(uint8_t size)
@ NRF_PA_LOW
Definition nrf_to_nrf.h:54
+ diff --git a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html index 3191a98..16332f2 100644 --- a/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html +++ b/html/examples_2RF24_2GettingStarted_2GettingStarted_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24/GettingStarted/GettingStarted.ino + + @@ -39,11 +41,16 @@ - + + +
+
} // loop
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
-
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
bool begin()
-
void openWritingPipe(const uint8_t *address)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setPayloadSize(uint8_t size)
-
uint8_t getPayloadSize()
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
bool begin()
+
void openWritingPipe(const uint8_t *address)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setPayloadSize(uint8_t size)
+
uint8_t getPayloadSize()
@ NRF_PA_LOW
Definition nrf_to_nrf.h:54
+ diff --git a/html/examples_2RF24_2scanner_2scanner_8ino-example.html b/html/examples_2RF24_2scanner_2scanner_8ino-example.html index b00f829..d8f0bc8 100644 --- a/html/examples_2RF24_2scanner_2scanner_8ino-example.html +++ b/html/examples_2RF24_2scanner_2scanner_8ino-example.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: examples/RF24/scanner/scanner.ino + + @@ -39,11 +41,16 @@ - + + +
+
} //If constCarrierMode == 0
}
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
bool testCarrier(uint8_t RSSI=65)
-
void setChannel(uint8_t channel)
-
bool begin()
-
void setAutoAck(bool enable)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void startListening(bool resetAddresses=true)
+
bool testCarrier(uint8_t RSSI=65)
+
void setChannel(uint8_t channel)
+
bool begin()
+
void setAutoAck(bool enable)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+ diff --git a/html/files.html b/html/files.html index 9c07c07..c2ba87a 100644 --- a/html/files.html +++ b/html/files.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File List + + @@ -39,11 +41,16 @@ - + + +
+
+
diff --git a/html/functions.html b/html/functions.html index 8e51a5e..6a647c7 100644 --- a/html/functions.html +++ b/html/functions.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Class Members + + @@ -39,11 +41,16 @@
- + + +
+
- g -

@@ -230,7 +244,8 @@

- w -

    + diff --git a/html/functions_func.html b/html/functions_func.html index 509f016..a193d5e 100644 --- a/html/functions_func.html +++ b/html/functions_func.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Class Members - Functions + + @@ -39,11 +41,16 @@ - + + +
    +
    - g -

@@ -221,7 +235,8 @@

- w -

    + diff --git a/html/functions_vars.html b/html/functions_vars.html index 8c12ee1..e0727bf 100644 --- a/html/functions_vars.html +++ b/html/functions_vars.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: Class Members - Variables + + @@ -39,11 +41,16 @@ - + + +
    +
    +
    diff --git a/html/globals.html b/html/globals.html index abe7b31..194b699 100644 --- a/html/globals.html +++ b/html/globals.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File Members + + @@ -39,11 +41,16 @@
    - + + +
    +
    - t -

    + diff --git a/html/globals_defs.html b/html/globals_defs.html index 1f9b282..feb1b11 100644 --- a/html/globals_defs.html +++ b/html/globals_defs.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File Members + + @@ -39,11 +41,16 @@ - + + +
    +
    +
    diff --git a/html/globals_enum.html b/html/globals_enum.html index 5c08162..45db725 100644 --- a/html/globals_enum.html +++ b/html/globals_enum.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File Members + + @@ -39,11 +41,16 @@
    - + + +
    +
    +
    diff --git a/html/globals_eval.html b/html/globals_eval.html index 7ab9b3f..526c6b0 100644 --- a/html/globals_eval.html +++ b/html/globals_eval.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File Members + + @@ -39,11 +41,16 @@
    - + + +
    +
    +
    diff --git a/html/globals_func.html b/html/globals_func.html index c7d3cd7..49508b4 100644 --- a/html/globals_func.html +++ b/html/globals_func.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: File Members + + @@ -39,11 +41,16 @@
    - + + +
    +
    +
    diff --git a/html/index.html b/html/index.html index f54cca1..88ef000 100644 --- a/html/index.html +++ b/html/index.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: nrf_to_nrf - NRF52 radio driver + + @@ -39,11 +41,16 @@
    - + + +
    +
    +
    diff --git a/html/navtree.css b/html/navtree.css new file mode 100644 index 0000000..69211d4 --- /dev/null +++ b/html/navtree.css @@ -0,0 +1,149 @@ +#nav-tree .children_ul { + margin:0; + padding:4px; +} + +#nav-tree ul { + list-style:none outside none; + margin:0px; + padding:0px; +} + +#nav-tree li { + white-space:nowrap; + margin:0px; + padding:0px; +} + +#nav-tree .plus { + margin:0px; +} + +#nav-tree .selected { + background-image: url('tab_a.png'); + background-repeat:repeat-x; + color: var(--nav-text-active-color); + text-shadow: var(--nav-text-active-shadow); +} + +#nav-tree .selected .arrow { + color: var(--nav-arrow-selected-color); + text-shadow: none; +} + +#nav-tree img { + margin:0px; + padding:0px; + border:0px; + vertical-align: middle; +} + +#nav-tree a { + text-decoration:none; + padding:0px; + margin:0px; +} + +#nav-tree .label { + margin:0px; + padding:0px; + font: 12px var(--font-family-nav); +} + +#nav-tree .label a { + padding:2px; +} + +#nav-tree .selected a { + text-decoration:none; + color:var(--nav-text-active-color); +} + +#nav-tree .children_ul { + margin:0px; + padding:0px; +} + +#nav-tree .item { + margin:0px; + padding:0px; +} + +#nav-tree { + padding: 0px 0px; + font-size:14px; + overflow:auto; +} + +#doc-content { + overflow:auto; + display:block; + padding:0px; + margin:0px; + -webkit-overflow-scrolling : touch; /* iOS 5+ */ +} + +#side-nav { + padding:0 6px 0 0; + margin: 0px; + display:block; + position: absolute; + left: 0px; + width: $width; + overflow : hidden; +} + +.ui-resizable .ui-resizable-handle { + display:block; +} + +.ui-resizable-e { + background-image:var(--nav-splitbar-image); + background-size:100%; + background-repeat:repeat-y; + background-attachment: scroll; + cursor:ew-resize; + height:100%; + right:0; + top:0; + width:6px; +} + +.ui-resizable-handle { + display:none; + font-size:0.1px; + position:absolute; + z-index:1; +} + +#nav-tree-contents { + margin: 6px 0px 0px 0px; +} + +#nav-tree { + background-repeat:repeat-x; + background-color: var(--nav-background-color); + -webkit-overflow-scrolling : touch; /* iOS 5+ */ +} + +#nav-sync { + position:absolute; + top:5px; + right:24px; + z-index:0; +} + +#nav-sync img { + opacity:0.3; +} + +#nav-sync img:hover { + opacity:0.9; +} + +@media print +{ + #nav-tree { display: none; } + div.ui-resizable-handle { display: none; position: relative; } +} + diff --git a/html/nrf__to__nrf_8cpp.html b/html/nrf__to__nrf_8cpp.html index 3ef74db..c90c3c6 100644 --- a/html/nrf__to__nrf_8cpp.html +++ b/html/nrf__to__nrf_8cpp.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: src/nrf_to_nrf.cpp File Reference + + @@ -39,11 +41,16 @@
    - + + +
+
Macros | @@ -268,7 +281,8 @@

+

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

+

diff --git a/html/nrf__to__nrf_8h_source.html b/html/nrf__to__nrf_8h_source.html index 39fade8..d5a1ccd 100644 --- a/html/nrf__to__nrf_8h_source.html +++ b/html/nrf__to__nrf_8h_source.html @@ -3,13 +3,15 @@ - + nrf_to_nrf - NRF52 Radio Driver: src/nrf_to_nrf.h Source File + + @@ -39,11 +41,16 @@
- + + @@ -103,6 +110,7 @@
+
nrf_to_nrf.h
@@ -112,22 +120,22 @@
8#define __nrf52840_nrf24l01_H__
9#include <Arduino.h>
10#if defined(USE_TINYUSB)
-
11// Needed for Serial.print on non-MBED enabled or adafruit-based nRF52 cores
-
12#include "Adafruit_TinyUSB.h"
+
11 // Needed for Serial.print on non-MBED enabled or adafruit-based nRF52 cores
+
12 #include "Adafruit_TinyUSB.h"
13#endif
14
-
15#if defined (NRF52811_XXAA) || defined (NRF52820_XXAA) || defined (NRF52833_XXAA) || defined (NRF52840_XXAA)
-
16#define NRF_HAS_ENERGY_DETECT
+
15#if defined(NRF52811_XXAA) || defined(NRF52820_XXAA) || defined(NRF52833_XXAA) || defined(NRF52840_XXAA)
+
16 #define NRF_HAS_ENERGY_DETECT
17#endif
18
19#define NRF52_RADIO_LIBRARY
-
20#define DEFAULT_MAX_PAYLOAD_SIZE 32
-
21#define ACTUAL_MAX_PAYLOAD_SIZE 127
-
22#define ACK_TIMEOUT_1MBPS 600 // 300 with static payloads
-
23#define ACK_TIMEOUT_2MBPS 400 // 265 with static payloads
-
24#define ACK_TIMEOUT_250KBPS 800 // 500 with staticPayloads
-
25#define ACK_TIMEOUT_1MBPS_OFFSET 300
-
26#define ACK_TIMEOUT_2MBPS_OFFSET 135
+
20#define DEFAULT_MAX_PAYLOAD_SIZE 32
+
21#define ACTUAL_MAX_PAYLOAD_SIZE 127
+
22#define ACK_TIMEOUT_1MBPS 600 // 300 with static payloads
+
23#define ACK_TIMEOUT_2MBPS 400 // 265 with static payloads
+
24#define ACK_TIMEOUT_250KBPS 800 // 500 with staticPayloads
+
25#define ACK_TIMEOUT_1MBPS_OFFSET 300
+
26#define ACK_TIMEOUT_2MBPS_OFFSET 135
27#define ACK_TIMEOUT_250KBPS_OFFSET 300
28#define ACK_PAYLOAD_TIMEOUT_OFFSET 750
29
@@ -180,224 +188,222 @@
115{
116
117public:
-
118
-
133 nrf_to_nrf();
-
134
-
135
-
142 bool begin();
-
143
-
147 bool available();
-
148
-
152 bool available(uint8_t* pipe_num);
-
153
-
157 void read(void* buf, uint8_t len);
-
158
-
162 bool write(void* buf, uint8_t len, bool multicast = false, bool doEncryption = true);
-
163
-
168 void startListening(bool resetAddresses = true);
-
169
-
175 void stopListening(bool setWritingPipe = true, bool resetAddresses = true);
-
176
-
180 void openReadingPipe(uint8_t child, const uint8_t* address);
-
181
-
185 void openWritingPipe(const uint8_t* address);
-
186
-
190 bool isChipConnected();
-
191
-
192
- -
208
-
212 bool writeFast(void* buf, uint8_t len, bool multicast = 0);
-
213
-
222 bool startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption = true);
-
223
-
227 bool writeAckPayload(uint8_t pipe, void* buf, uint8_t len);
-
228
-
232 void enableAckPayload();
-
233
-
237 void disableAckPayload();
-
238
- -
243
-
244
-
248 uint8_t getDynamicPayloadSize();
-
249
-
253 bool isValid();
-
254
-
258 void setChannel(uint8_t channel);
-
259
-
263 uint8_t getChannel();
-
264
-
268 bool setDataRate(uint8_t speed);
-
269
-
278 void setPALevel(uint8_t level, bool lnaEnable = true);
-
279
-
283 uint8_t getPALevel();
-
284
-
288 void setAutoAck(bool enable);
-
289
-
293 void setAutoAck(uint8_t pipe, bool enable);
-
294
-
300 void enableDynamicPayloads(uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE);
-
301
- -
306
-
310 void setPayloadSize(uint8_t size);
-
311
-
315 uint8_t getPayloadSize();
-
316
-
320 void setCRCLength(nrf_crclength_e length);
-
321
- -
326
- -
331
-
335 void setRetries(uint8_t retryVar, uint8_t attempts);
-
336
-
340 void openReadingPipe(uint8_t child, uint64_t address);
-
341
-
345 void openWritingPipe(uint64_t address);
-
346
-
350 void setAddressWidth(uint8_t a_width);
-
351
-
355 void printDetails();
-
356
-
360 void powerUp();
-
361
-
365 void powerDown();
-
366
- -
371
-
377 bool txStandBy();
-
378
-
384 bool txStandBy(uint32_t timeout, bool startTx = 0);
-
385
-
390 bool testCarrier(uint8_t RSSI = 65);
-
391
-
396 bool testRPD(uint8_t RSSI = 65);
-
397
-
401 uint8_t getARC();
-
402
-
403#ifdef NRF_HAS_ENERGY_DETECT
-
404 uint8_t sample_ed(void);
-
405#endif
-
406
-
418 uint32_t addrConv32(uint32_t addr);
-
419#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
-
420
-
424 uint8_t encrypt(void* bufferIn, uint8_t size);
-
425
-
429 uint8_t decrypt(void* bufferIn, uint8_t size);
-
430
- -
435
-
439 void setKey(uint8_t key[CCM_KEY_SIZE]);
-
440
-
444 void setCounter(uint64_t counter);
-
445
-
451 void setIV(uint8_t IV[CCM_IV_SIZE]);
-
452
- -
469#endif
-
470
-
471private:
-
472 bool acksEnabled(uint8_t pipe);
-
473 bool acksPerPipe[8];
-
474 uint8_t retries;
-
475 uint8_t retryDuration;
-
476 uint8_t rxBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
-
477 uint8_t ackBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
-
478 uint8_t rxFifoAvailable;
-
479 bool DPL;
-
480 bool ackPayloadsEnabled;
-
481 bool inRxMode;
-
482 uint8_t staticPayloadSize;
-
483 uint8_t ackPID;
-
484 uint8_t ackPipe;
-
485 bool lastTxResult;
-
486 bool overWrite;
-
487 uint32_t rxBase;
-
488 uint32_t rxPrefix;
-
489 uint32_t txBase;
-
490 uint32_t txPrefix;
-
491 bool radioConfigured;
-
492 bool ackPayloadAvailable;
-
493 uint8_t ackAvailablePipeNo;
-
494 uint8_t lastPacketCounter;
-
495 uint16_t lastData;
-
496 bool dynamicAckEnabled;
-
497 uint8_t ARC;
-
498 uint8_t addressWidth;
-
499 uint16_t ackTimeout;
-
500 bool payloadAvailable;
-
501#if defined CCM_ENCRYPTION_ENABLED
-
502 uint8_t inBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
-
503 uint8_t scratchPTR[MAX_PACKET_SIZE + CCM_MODE_LENGTH_EXTENDED];
-
504 typedef struct
-
505 {
-
506 uint8_t key[CCM_KEY_SIZE];
-
507 uint64_t counter;
-
508 uint8_t direction;
-
509 uint8_t iv[CCM_IV_SIZE_ACTUAL];
-
510 } ccmData_t;
-
511 ccmData_t ccmData;
-
512 uint32_t packetCounter;
-
513#endif
-
514};
+
132 nrf_to_nrf();
+
133
+
140 bool begin();
+
141
+
145 bool available();
+
146
+
150 bool available(uint8_t* pipe_num);
+
151
+
155 void read(void* buf, uint8_t len);
+
156
+
160 bool write(void* buf, uint8_t len, bool multicast = false, bool doEncryption = true);
+
161
+
166 void startListening(bool resetAddresses = true);
+
167
+
173 void stopListening(bool setWritingPipe = true, bool resetAddresses = true);
+
174
+
178 void openReadingPipe(uint8_t child, const uint8_t* address);
+
179
+
183 void openWritingPipe(const uint8_t* address);
+
184
+
188 bool isChipConnected();
+
189
+ +
205
+
209 bool writeFast(void* buf, uint8_t len, bool multicast = 0);
+
210
+
219 bool startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption = true);
+
220
+
224 bool writeAckPayload(uint8_t pipe, void* buf, uint8_t len);
+
225
+
229 void enableAckPayload();
+
230
+
234 void disableAckPayload();
+
235
+ +
240
+
244 uint8_t getDynamicPayloadSize();
+
245
+
249 bool isValid();
+
250
+
254 void setChannel(uint8_t channel);
+
255
+
259 uint8_t getChannel();
+
260
+
264 bool setDataRate(uint8_t speed);
+
265
+
274 void setPALevel(uint8_t level, bool lnaEnable = true);
+
275
+
279 uint8_t getPALevel();
+
280
+
284 void setAutoAck(bool enable);
+
285
+
289 void setAutoAck(uint8_t pipe, bool enable);
+
290
+
296 void enableDynamicPayloads(uint8_t payloadSize = DEFAULT_MAX_PAYLOAD_SIZE);
+
297
+ +
302
+
306 void setPayloadSize(uint8_t size);
+
307
+
311 uint8_t getPayloadSize();
+
312
+
316 void setCRCLength(nrf_crclength_e length);
+
317
+ +
322
+ +
327
+
331 void setRetries(uint8_t retryVar, uint8_t attempts);
+
332
+
336 void openReadingPipe(uint8_t child, uint64_t address);
+
337
+
341 void openWritingPipe(uint64_t address);
+
342
+
346 void setAddressWidth(uint8_t a_width);
+
347
+
351 void printDetails();
+
352
+
356 void powerUp();
+
357
+
361 void powerDown();
+
362
+ +
367
+
373 bool txStandBy();
+
374
+
380 bool txStandBy(uint32_t timeout, bool startTx = 0);
+
381
+
386 bool testCarrier(uint8_t RSSI = 65);
+
387
+
392 bool testRPD(uint8_t RSSI = 65);
+
393
+
399 uint8_t getRSSI();
+
400
+
404 uint8_t getARC();
+
405
+
406#ifdef NRF_HAS_ENERGY_DETECT
+
407 uint8_t sample_ed(void);
+
408#endif
+
409
+
421 uint32_t addrConv32(uint32_t addr);
+
422#if defined CCM_ENCRYPTION_ENABLED || defined(DOXYGEN)
+
423
+
427 uint8_t encrypt(void* bufferIn, uint8_t size);
+
428
+
432 uint8_t decrypt(void* bufferIn, uint8_t size);
+
433
+ +
438
+
442 void setKey(uint8_t key[CCM_KEY_SIZE]);
+
443
+
447 void setCounter(uint64_t counter);
+
448
+
454 void setIV(uint8_t IV[CCM_IV_SIZE]);
+
455
+ +
472#endif
+
473
+
474private:
+
475 bool acksEnabled(uint8_t pipe);
+
476 bool acksPerPipe[8];
+
477 uint8_t retries;
+
478 uint8_t retryDuration;
+
479 uint8_t rxBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
+
480 uint8_t ackBuffer[ACTUAL_MAX_PAYLOAD_SIZE + 1];
+
481 uint8_t rxFifoAvailable;
+
482 bool DPL;
+
483 bool ackPayloadsEnabled;
+
484 bool inRxMode;
+
485 uint8_t staticPayloadSize;
+
486 uint8_t ackPID;
+
487 uint8_t ackPipe;
+
488 bool lastTxResult;
+
489 bool overWrite;
+
490 uint32_t rxBase;
+
491 uint32_t rxPrefix;
+
492 uint32_t txBase;
+
493 uint32_t txPrefix;
+
494 bool ackPayloadAvailable;
+
495 uint8_t ackAvailablePipeNo;
+
496 uint8_t lastPacketCounter;
+
497 uint16_t lastData;
+
498 bool dynamicAckEnabled;
+
499 uint8_t ARC;
+
500 uint8_t addressWidth;
+
501 uint16_t ackTimeout;
+
502 bool payloadAvailable;
+
503#if defined CCM_ENCRYPTION_ENABLED
+
504 uint8_t inBuffer[MAX_PACKET_SIZE + CCM_MIC_SIZE + CCM_START_SIZE];
+
505 uint8_t scratchPTR[MAX_PACKET_SIZE + CCM_MODE_LENGTH_EXTENDED];
+
506 typedef struct
+
507 {
+
508 uint8_t key[CCM_KEY_SIZE];
+
509 uint64_t counter;
+
510 uint8_t direction;
+
511 uint8_t iv[CCM_IV_SIZE_ACTUAL];
+
512 } ccmData_t;
+
513 ccmData_t ccmData;
+
514 uint32_t packetCounter;
+
515#endif
+
516};
-
515
-
575#endif //__nrf52840_nrf24l01_H__
+
517
+
577#endif //__nrf52840_nrf24l01_H__
Driver class for nRF52840 2.4GHz Wireless Transceiver.
Definition nrf_to_nrf.h:115
-
void startListening(bool resetAddresses=true)
-
void openReadingPipe(uint8_t child, const uint8_t *address)
- -
bool available()
-
void setPALevel(uint8_t level, bool lnaEnable=true)
-
bool testCarrier(uint8_t RSSI=65)
-
bool txStandBy()
-
uint8_t decrypt(void *bufferIn, uint8_t size)
-
uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
Definition nrf_to_nrf.h:207
-
void setChannel(uint8_t channel)
+
void startListening(bool resetAddresses=true)
+
void openReadingPipe(uint8_t child, const uint8_t *address)
+ +
bool available()
+
void setPALevel(uint8_t level, bool lnaEnable=true)
+
bool testCarrier(uint8_t RSSI=65)
+
bool txStandBy()
+
uint8_t decrypt(void *bufferIn, uint8_t size)
+
uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE+2]
Definition nrf_to_nrf.h:204
+
void setChannel(uint8_t channel)
uint32_t addrConv32(uint32_t addr)
-
void disableDynamicPayloads()
-
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
-
bool testRPD(uint8_t RSSI=65)
-
void setCounter(uint64_t counter)
-
bool isChipConnected()
-
void setAddressWidth(uint8_t a_width)
-
uint8_t getDynamicPayloadSize()
-
bool setDataRate(uint8_t speed)
-
bool isValid()
+
void disableDynamicPayloads()
+
bool write(void *buf, uint8_t len, bool multicast=false, bool doEncryption=true)
+
bool testRPD(uint8_t RSSI=65)
+
void setCounter(uint64_t counter)
+
bool isChipConnected()
+
void setAddressWidth(uint8_t a_width)
+
uint8_t getDynamicPayloadSize()
+
bool setDataRate(uint8_t speed)
+
bool isValid()
void enableDynamicAck()
-
void setKey(uint8_t key[CCM_KEY_SIZE])
-
bool begin()
-
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
-
bool enableEncryption
Definition nrf_to_nrf.h:467
-
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
-
void disableAckPayload()
+
void setKey(uint8_t key[CCM_KEY_SIZE])
+
bool begin()
+
bool writeAckPayload(uint8_t pipe, void *buf, uint8_t len)
+
bool enableEncryption
Definition nrf_to_nrf.h:470
+
void enableDynamicPayloads(uint8_t payloadSize=DEFAULT_MAX_PAYLOAD_SIZE)
+
void disableAckPayload()
void disableCRC()
-
void powerDown()
-
uint8_t getARC()
-
uint8_t encrypt(void *bufferIn, uint8_t size)
-
void printDetails()
-
uint8_t getChannel()
-
bool startWrite(void *buf, uint8_t len, bool multicast, bool doEncryption=true)
-
uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
Definition nrf_to_nrf.h:434
-
void setRetries(uint8_t retryVar, uint8_t attempts)
-
void enableAckPayload()
-
void openWritingPipe(const uint8_t *address)
-
void setCRCLength(nrf_crclength_e length)
-
bool failureDetected
Definition nrf_to_nrf.h:370
-
bool writeFast(void *buf, uint8_t len, bool multicast=0)
-
uint8_t getPALevel()
-
void setAutoAck(bool enable)
-
void read(void *buf, uint8_t len)
-
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
-
void setIV(uint8_t IV[CCM_IV_SIZE])
-
void setPayloadSize(uint8_t size)
-
nrf_crclength_e getCRCLength()
-
uint8_t getPayloadSize()
+
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 getRSSI()
+
uint8_t outBuffer[MAX_PACKET_SIZE+CCM_MIC_SIZE+CCM_START_SIZE]
Definition nrf_to_nrf.h:437
+
void setRetries(uint8_t retryVar, uint8_t attempts)
+
void enableAckPayload()
+
void openWritingPipe(const uint8_t *address)
+
void setCRCLength(nrf_crclength_e length)
+
bool failureDetected
Definition nrf_to_nrf.h:366
+
bool writeFast(void *buf, uint8_t len, bool multicast=0)
+
uint8_t getPALevel()
+
void setAutoAck(bool enable)
+
void read(void *buf, uint8_t len)
+
void stopListening(bool setWritingPipe=true, bool resetAddresses=true)
+
void setIV(uint8_t IV[CCM_IV_SIZE])
+
void setPayloadSize(uint8_t size)
+
nrf_crclength_e getCRCLength()
+
uint8_t getPayloadSize()
#define CCM_MODE_LENGTH_EXTENDED
Definition nrf_to_nrf.h:42
#define DEFAULT_MAX_PAYLOAD_SIZE
Definition nrf_to_nrf.h:20
nrf_pa_dbm_e
Definition nrf_to_nrf.h:46
@@ -424,7 +430,8 @@
+
diff --git a/html/resize.js b/html/resize.js new file mode 100644 index 0000000..7d8cdc7 --- /dev/null +++ b/html/resize.js @@ -0,0 +1,145 @@ +/* + @licstart The following is the entire license notice for the JavaScript code in this file. + + The MIT License (MIT) + + Copyright (C) 1997-2020 by Dimitri van Heesch + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software + and associated documentation files (the "Software"), to deal in the Software without restriction, + including without limitation the rights to use, copy, modify, merge, publish, distribute, + sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or + substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + @licend The above is the entire license notice for the JavaScript code in this file + */ + +function initResizable(treeview) { + let sidenav,navtree,content,header,footer,barWidth=6; + const RESIZE_COOKIE_NAME = ''+'width'; + + function resizeWidth() { + const sidenavWidth = $(sidenav).outerWidth(); + content.css({marginLeft:parseInt(sidenavWidth)+"px"}); + if (typeof page_layout!=='undefined' && page_layout==1) { + footer.css({marginLeft:parseInt(sidenavWidth)+"px"}); + } + Cookie.writeSetting(RESIZE_COOKIE_NAME,sidenavWidth-barWidth); + } + + function restoreWidth(navWidth) { + content.css({marginLeft:parseInt(navWidth)+barWidth+"px"}); + if (typeof page_layout!=='undefined' && page_layout==1) { + footer.css({marginLeft:parseInt(navWidth)+barWidth+"px"}); + } + sidenav.css({width:navWidth + "px"}); + } + + function resizeHeight(treeview) { + const headerHeight = header.outerHeight(); + const windowHeight = $(window).height(); + let contentHeight; + if (treeview) + { + const footerHeight = footer.outerHeight(); + let navtreeHeight,sideNavHeight; + if (typeof page_layout==='undefined' || page_layout==0) { /* DISABLE_INDEX=NO */ + contentHeight = windowHeight - headerHeight - footerHeight; + navtreeHeight = contentHeight; + sideNavHeight = contentHeight; + } else if (page_layout==1) { /* DISABLE_INDEX=YES */ + contentHeight = windowHeight - footerHeight; + navtreeHeight = windowHeight - headerHeight; + sideNavHeight = windowHeight; + } + navtree.css({height:navtreeHeight + "px"}); + sidenav.css({height:sideNavHeight + "px"}); + } + else + { + contentHeight = windowHeight - headerHeight; + } + content.css({height:contentHeight + "px"}); + if (location.hash.slice(1)) { + (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView(); + } + } + + function collapseExpand() { + let newWidth; + if (sidenav.width()>0) { + newWidth=0; + } else { + const width = Cookie.readSetting(RESIZE_COOKIE_NAME,250); + newWidth = (width>250 && width<$(window).width()) ? width : 250; + } + restoreWidth(newWidth); + const sidenavWidth = $(sidenav).outerWidth(); + Cookie.writeSetting(RESIZE_COOKIE_NAME,sidenavWidth-barWidth); + } + + header = $("#top"); + content = $("#doc-content"); + footer = $("#nav-path"); + sidenav = $("#side-nav"); + if (!treeview) { +// title = $("#titlearea"); +// titleH = $(title).height(); +// let animating = false; +// content.on("scroll", function() { +// slideOpts = { duration: 200, +// step: function() { +// contentHeight = $(window).height() - header.outerHeight(); +// content.css({ height : contentHeight + "px" }); +// }, +// done: function() { animating=false; } +// }; +// if (content.scrollTop()>titleH && title.css('display')!='none' && !animating) { +// title.slideUp(slideOpts); +// animating=true; +// } else if (content.scrollTop()<=titleH && title.css('display')=='none' && !animating) { +// title.slideDown(slideOpts); +// animating=true; +// } +// }); + } else { + navtree = $("#nav-tree"); + $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(); } }); + $(sidenav).resizable({ minWidth: 0 }); + } + $(window).resize(function() { resizeHeight(treeview); }); + if (treeview) + { + const device = navigator.userAgent.toLowerCase(); + const touch_device = device.match(/(iphone|ipod|ipad|android)/); + if (touch_device) { /* wider split bar for touch only devices */ + $(sidenav).css({ paddingRight:'20px' }); + $('.ui-resizable-e').css({ width:'20px' }); + $('#nav-sync').css({ right:'34px' }); + barWidth=20; + } + const width = Cookie.readSetting(RESIZE_COOKIE_NAME,250); + if (width) { restoreWidth(width); } else { resizeWidth(); } + } + resizeHeight(treeview); + const url = location.href; + const i=url.indexOf("#"); + if (i>=0) window.location.hash=url.substr(i); + const _preventDefault = function(evt) { evt.preventDefault(); }; + if (treeview) + { + $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault); + $(".ui-resizable-handle").dblclick(collapseExpand); + } + $(window).on('load',resizeHeight); +} +/* @license-end */ diff --git a/html/search/all_6.js b/html/search/all_6.js index 89525d3..65cfa50 100644 --- a/html/search/all_6.js +++ b/html/search/all_6.js @@ -5,5 +5,6 @@ var searchData= ['getcrclength_2',['getCRCLength',['../classnrf__to__nrf.html#af7bcd44a7f8d32db31c40d302364180a',1,'nrf_to_nrf']]], ['getdynamicpayloadsize_3',['getDynamicPayloadSize',['../classnrf__to__nrf.html#a543bbc33034094b5be199efdb77c2a7a',1,'nrf_to_nrf']]], ['getpalevel_4',['getPALevel',['../classnrf__to__nrf.html#acbfd7a6baf9f697f6b06485e561dc388',1,'nrf_to_nrf']]], - ['getpayloadsize_5',['getPayloadSize',['../classnrf__to__nrf.html#af8cdf0351e55cb9784e96f9385ece778',1,'nrf_to_nrf']]] + ['getpayloadsize_5',['getPayloadSize',['../classnrf__to__nrf.html#af8cdf0351e55cb9784e96f9385ece778',1,'nrf_to_nrf']]], + ['getrssi_6',['getRSSI',['../classnrf__to__nrf.html#aa05eb66e748ff5cbff931bce1d87d5a8',1,'nrf_to_nrf']]] ]; diff --git a/html/search/all_9.js b/html/search/all_9.js index 6b90b01..86172b5 100644 --- a/html/search/all_9.js +++ b/html/search/all_9.js @@ -16,9 +16,8 @@ var searchData= ['nrf_5fpa_5flow_13',['NRF_PA_LOW',['../nrf__to__nrf_8h.html#a30d719167ee0e6839d6653faa420d8a6abb73fba095816348ffa4f62c7c30a3e2',1,'nrf_to_nrf.h']]], ['nrf_5fpa_5fmax_14',['NRF_PA_MAX',['../nrf__to__nrf_8h.html#a30d719167ee0e6839d6653faa420d8a6a6f9553b4da62426766cba57ac4f56487',1,'nrf_to_nrf.h']]], ['nrf_5fpa_5fmin_15',['NRF_PA_MIN',['../nrf__to__nrf_8h.html#a30d719167ee0e6839d6653faa420d8a6abe9ed3ab507dfb52d15766e62542d2d4',1,'nrf_to_nrf.h']]], - ['nrf_5fto_5fnrf_16',['for nrf_to_nrf',['../index.html#Documentation',1,'']]], - ['nrf_5fto_5fnrf_17',['nrf_to_nrf',['../classnrf__to__nrf.html',1,'nrf_to_nrf'],['../classnrf__to__nrf.html#a6e3601bd9cbe9b176c489af224ea9e5b',1,'nrf_to_nrf::nrf_to_nrf()']]], - ['nrf_5fto_5fnrf_20nrf52_20radio_20driver_18',['nrf_to_nrf - NRF52 radio driver',['../index.html',1,'']]], - ['nrf_5fto_5fnrf_2ecpp_19',['nrf_to_nrf.cpp',['../nrf__to__nrf_8cpp.html',1,'']]], - ['nrf_5fto_5fnrf_2eh_20',['nrf_to_nrf.h',['../nrf__to__nrf_8h.html',1,'']]] + ['nrf_5fto_5fnrf_16',['nrf_to_nrf',['../index.html#Documentation',1,'for nrf_to_nrf'],['../classnrf__to__nrf.html',1,'nrf_to_nrf'],['../classnrf__to__nrf.html#a6e3601bd9cbe9b176c489af224ea9e5b',1,'nrf_to_nrf::nrf_to_nrf()']]], + ['nrf_5fto_5fnrf_20nrf52_20radio_20driver_17',['nrf_to_nrf - NRF52 radio driver',['../index.html',1,'']]], + ['nrf_5fto_5fnrf_2ecpp_18',['nrf_to_nrf.cpp',['../nrf__to__nrf_8cpp.html',1,'']]], + ['nrf_5fto_5fnrf_2eh_19',['nrf_to_nrf.h',['../nrf__to__nrf_8h.html',1,'']]] ]; diff --git a/html/search/functions_4.js b/html/search/functions_4.js index 89525d3..65cfa50 100644 --- a/html/search/functions_4.js +++ b/html/search/functions_4.js @@ -5,5 +5,6 @@ var searchData= ['getcrclength_2',['getCRCLength',['../classnrf__to__nrf.html#af7bcd44a7f8d32db31c40d302364180a',1,'nrf_to_nrf']]], ['getdynamicpayloadsize_3',['getDynamicPayloadSize',['../classnrf__to__nrf.html#a543bbc33034094b5be199efdb77c2a7a',1,'nrf_to_nrf']]], ['getpalevel_4',['getPALevel',['../classnrf__to__nrf.html#acbfd7a6baf9f697f6b06485e561dc388',1,'nrf_to_nrf']]], - ['getpayloadsize_5',['getPayloadSize',['../classnrf__to__nrf.html#af8cdf0351e55cb9784e96f9385ece778',1,'nrf_to_nrf']]] + ['getpayloadsize_5',['getPayloadSize',['../classnrf__to__nrf.html#af8cdf0351e55cb9784e96f9385ece778',1,'nrf_to_nrf']]], + ['getrssi_6',['getRSSI',['../classnrf__to__nrf.html#aa05eb66e748ff5cbff931bce1d87d5a8',1,'nrf_to_nrf']]] ]; diff --git a/src/nrf_to_nrf.cpp b/src/nrf_to_nrf.cpp index 22ac7f6..6db817a 100644 --- a/src/nrf_to_nrf.cpp +++ b/src/nrf_to_nrf.cpp @@ -2,24 +2,24 @@ #include "nrf_to_nrf.h" -#if defined (NRF52832_XXAA) || defined (NRF52832_XXAB) || defined (NRF52811_XXAA) || defined (NRF52810_XXAA) || defined (NRF52805_XXAA) -// TX power range (Product Specification): -20 .. +4dbm, configurable in 4 dB steps -#define TXPOWER_PA_MIN 0xF4 // -12dBm -#define TXPOWER_PA_LOW 0xFC // -4dBm -#define TXPOWER_PA_HIGH 0x00 // 0dBm -#define TXPOWER_PA_MAX 0x04 // 4dBm -#else // nRF52840, nRF52833, nRF52820 -// TX power range (Product Specification): -20 .. +8dbm, configurable in 4 dB steps -#define TXPOWER_PA_MIN 0xF4 // -12dBm -#define TXPOWER_PA_LOW 0x02 // 2dBm -#define TXPOWER_PA_HIGH 0x06 // 6dBm -#define TXPOWER_PA_MAX 0x08 // 8dBm +#if defined(NRF52832_XXAA) || defined(NRF52832_XXAB) || defined(NRF52811_XXAA) || defined(NRF52810_XXAA) || defined(NRF52805_XXAA) + // TX power range (Product Specification): -20 .. +4dbm, configurable in 4 dB steps + #define TXPOWER_PA_MIN 0xF4 // -12dBm + #define TXPOWER_PA_LOW 0xFC // -4dBm + #define TXPOWER_PA_HIGH 0x00 // 0dBm + #define TXPOWER_PA_MAX 0x04 // 4dBm +#else // nRF52840, nRF52833, nRF52820 + // TX power range (Product Specification): -20 .. +8dbm, configurable in 4 dB steps + #define TXPOWER_PA_MIN 0xF4 // -12dBm + #define TXPOWER_PA_LOW 0x02 // 2dBm + #define TXPOWER_PA_HIGH 0x06 // 6dBm + #define TXPOWER_PA_MAX 0x08 // 8dBm #endif // Note that 250Kbit mode is deprecated and might not work reliably on all devices. // See: https://devzone.nordicsemi.com/f/nordic-q-a/78469/250-kbit-s-nordic-proprietary-radio-mode-on-nrf52840 #ifndef RADIO_MODE_MODE_Nrf_250Kbit -#define RADIO_MODE_MODE_Nrf_250Kbit (2UL) + #define RADIO_MODE_MODE_Nrf_250Kbit (2UL) #endif /**********************************************************************************************************/ @@ -70,7 +70,6 @@ nrf_to_nrf::nrf_to_nrf() ackPayloadsEnabled = false; ackPipe = 0; inRxMode = false; - radioConfigured = false; ARC = 0; addressWidth = 5; ackTimeout = ACK_TIMEOUT_1MBPS; @@ -98,10 +97,6 @@ nrf_to_nrf::nrf_to_nrf() bool nrf_to_nrf::begin() { - if (radioConfigured) { - return 1; - } - NRF_CLOCK->EVENTS_HFCLKSTARTED = 0; NRF_CLOCK->TASKS_HFCLKSTART = 1; @@ -149,14 +144,14 @@ bool nrf_to_nrf::begin() NRF_RADIO->SHORTS = 1 << 19; NRF_RADIO->FREQUENCY = 0x4C; - radioConfigured = true; + DPL = false; return 1; } /**********************************************************************************************************/ #ifdef NRF_HAS_ENERGY_DETECT -#define ED_RSSISCALE 4 // From electrical specifications + #define ED_RSSISCALE 4 // From electrical specifications uint8_t nrf_to_nrf::sample_ed(void) { int val; @@ -184,12 +179,12 @@ bool nrf_to_nrf::available() bool nrf_to_nrf::available(uint8_t* pipe_num) { - - if(payloadAvailable){ + + if (payloadAvailable) { *pipe_num = (uint8_t)NRF_RADIO->RXMATCH; return true; } - + if (!inRxMode) { if (ackPayloadAvailable) { *pipe_num = ackAvailablePipeNo; @@ -202,27 +197,27 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) uint8_t tmpIV[CCM_IV_SIZE]; #endif NRF_RADIO->EVENTS_CRCOK = 0; - if (DPL){ - if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) { - if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + if (DPL) { + if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 4 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_Two) { + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } + return 0; } - return 0; - }else - if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) { - if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + else if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 3 && NRF_RADIO->CRCCNF == RADIO_CRCCNF_LEN_One) { + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } + return 0; } - return 0; - }else - if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) { - if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + else if (radioData[0] > ACTUAL_MAX_PAYLOAD_SIZE - 2 && NRF_RADIO->CRCCNF == 0) { + if (inRxMode) { + NRF_RADIO->TASKS_START = 1; + } + return 0; } - return 0; - } } - + *pipe_num = (uint8_t)NRF_RADIO->RXMATCH; if (!DPL && acksEnabled(*pipe_num) == false) { #if defined CCM_ENCRYPTION_ENABLED @@ -252,9 +247,10 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) } else { #endif - if(DPL) { + if (DPL) { memcpy(&rxBuffer[1], &radioData[2], radioData[0]); - }else{ + } + else { memcpy(&rxBuffer[1], &radioData[2], staticPayloadSize); } #if defined CCM_ENCRYPTION_ENABLED @@ -303,10 +299,10 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) // If the packet has the same ID number and data, it is most likely a // duplicate - if(NRF_RADIO->CRCCNF != 0) { //If CRC enabled, check this data + if (NRF_RADIO->CRCCNF != 0) { // If CRC enabled, check this data if (packetCtr == lastPacketCounter && packetData == lastData) { if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + NRF_RADIO->TASKS_START = 1; } return 0; } @@ -321,7 +317,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) if (!decrypt(&rxBuffer[1], rxBuffer[0] - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + NRF_RADIO->TASKS_START = 1; } return 0; } @@ -330,7 +326,7 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) if (!decrypt(&rxBuffer[1], staticPayloadSize - CCM_IV_SIZE - CCM_COUNTER_SIZE)) { Serial.println("DECRYPT FAIL"); if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + NRF_RADIO->TASKS_START = 1; } return 0; } @@ -341,7 +337,6 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) if (DPL) { rxBuffer[0] -= (CCM_MIC_SIZE + CCM_IV_SIZE + CCM_COUNTER_SIZE); memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], rxBuffer[0]); - } else { memcpy(&rxBuffer[1], &outBuffer[CCM_START_SIZE], staticPayloadSize - (CCM_MIC_SIZE - CCM_IV_SIZE - CCM_COUNTER_SIZE)); @@ -352,11 +347,11 @@ bool nrf_to_nrf::available(uint8_t* pipe_num) lastData = packetData; payloadAvailable = true; if (inRxMode) { - NRF_RADIO->TASKS_START = 1; + NRF_RADIO->TASKS_START = 1; } return 1; } - if(NRF_RADIO->EVENTS_CRCERROR) { + if (NRF_RADIO->EVENTS_CRCERROR) { NRF_RADIO->EVENTS_CRCERROR = 0; NRF_RADIO->TASKS_START = 1; } @@ -395,7 +390,8 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption if (len) { for (int i = 0; i < CCM_IV_SIZE; i++) { - while (!NRF_RNG->EVENTS_VALRDY) {} + while (!NRF_RNG->EVENTS_VALRDY) { + } NRF_RNG->EVENTS_VALRDY = 0; tmpIV[i] = NRF_RNG->VALUE; ccmData.iv[i] = tmpIV[i]; @@ -432,8 +428,6 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption #if defined CCM_ENCRYPTION_ENABLED - - if (enableEncryption && doEncryption) { dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2; } @@ -447,7 +441,7 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption #if defined CCM_ENCRYPTION_ENABLED if (enableEncryption && doEncryption) { memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE); - memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE); + memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE], &tmpIV[0], CCM_IV_SIZE); memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE)); } else { @@ -483,15 +477,19 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption if (!DPL) { if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_1Mbit << RADIO_MODE_MODE_Pos)) { realAckTimeout -= ACK_TIMEOUT_1MBPS_OFFSET; - } else if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_250Kbit << RADIO_MODE_MODE_Pos)) { + } + else if (NRF_RADIO->MODE == (RADIO_MODE_MODE_Nrf_250Kbit << RADIO_MODE_MODE_Pos)) { realAckTimeout -= ACK_TIMEOUT_250KBPS_OFFSET; - } else { + } + else { realAckTimeout -= ACK_TIMEOUT_2MBPS_OFFSET; } - }else{ - if(ackPayloadsEnabled && staticPayloadSize <= DEFAULT_MAX_PAYLOAD_SIZE ){ + } + else { + if (ackPayloadsEnabled && staticPayloadSize <= DEFAULT_MAX_PAYLOAD_SIZE) { realAckTimeout += 200; - }else{ + } + else { realAckTimeout += ACK_PAYLOAD_TIMEOUT_OFFSET; } } @@ -504,13 +502,14 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption if (NRF_RADIO->EVENTS_CRCOK) { if (ackPayloadsEnabled && radioData[0] > 0) { #if defined CCM_ENCRYPTION_ENABLED - if(enableEncryption && doEncryption){ - memcpy(&rxBuffer[1], &radioData[2 + CCM_COUNTER_SIZE + CCM_IV_SIZE] , max(0, radioData[0] - CCM_COUNTER_SIZE - CCM_IV_SIZE)); - }else{ - memcpy(&rxBuffer[1], &radioData[2] , radioData[0]); - } + if (enableEncryption && doEncryption) { + memcpy(&rxBuffer[1], &radioData[2 + CCM_COUNTER_SIZE + CCM_IV_SIZE], max(0, radioData[0] - CCM_COUNTER_SIZE - CCM_IV_SIZE)); + } + else { + memcpy(&rxBuffer[1], &radioData[2], radioData[0]); + } #else - memcpy(&rxBuffer[1], &radioData[2], radioData[0]); + memcpy(&rxBuffer[1], &radioData[2], radioData[0]); #endif #if defined CCM_ENCRYPTION_ENABLED @@ -566,7 +565,6 @@ bool nrf_to_nrf::write(void* buf, uint8_t len, bool multicast, bool doEncryption bool nrf_to_nrf::startWrite(void* buf, uint8_t len, bool multicast, bool doEncryption) { - uint8_t PID = ackPID; if (DPL) { PID = ((ackPID += 1) % 7) << 1; @@ -584,7 +582,8 @@ bool nrf_to_nrf::startWrite(void* buf, uint8_t len, bool multicast, bool doEncry if (len) { for (int i = 0; i < CCM_IV_SIZE; i++) { - while (!NRF_RNG->EVENTS_VALRDY) {} + while (!NRF_RNG->EVENTS_VALRDY) { + } NRF_RNG->EVENTS_VALRDY = 0; tmpIV[i] = NRF_RNG->VALUE; ccmData.iv[i] = tmpIV[i]; @@ -606,57 +605,55 @@ bool nrf_to_nrf::startWrite(void* buf, uint8_t len, bool multicast, bool doEncry } #endif - // for (int i = 0; i < retries; i++) { - ARC = 0; - if (DPL) { - radioData[0] = len; - radioData[1] = PID; - } - else { - radioData[1] = 0; - radioData[0] = PID; - } + // for (int i = 0; i < retries; i++) { + ARC = 0; + if (DPL) { + radioData[0] = len; + radioData[1] = PID; + } + else { + radioData[1] = 0; + radioData[0] = PID; + } - uint8_t dataStart = 0; + uint8_t dataStart = 0; #if defined CCM_ENCRYPTION_ENABLED - - - if (enableEncryption && doEncryption) { - dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2; - } - else { + if (enableEncryption && doEncryption) { + dataStart = (!DPL && acksEnabled(0) == false) ? CCM_IV_SIZE + CCM_COUNTER_SIZE : CCM_IV_SIZE + CCM_COUNTER_SIZE + 2; + } + else { #endif - dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2; + dataStart = (!DPL && acksEnabled(0) == false) ? 0 : 2; #if defined CCM_ENCRYPTION_ENABLED - } + } #endif #if defined CCM_ENCRYPTION_ENABLED - if (enableEncryption && doEncryption) { - memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE); - memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE],&tmpIV[0],CCM_IV_SIZE); - memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE)); - } - else { + if (enableEncryption && doEncryption) { + memcpy(&radioData[dataStart - CCM_COUNTER_SIZE], &tmpCounter, CCM_COUNTER_SIZE); + memcpy(&radioData[dataStart - CCM_IV_SIZE - CCM_COUNTER_SIZE], &tmpIV[0], CCM_IV_SIZE); + memcpy(&radioData[dataStart], &tmpBuffer[0], len - (CCM_IV_SIZE + CCM_COUNTER_SIZE)); + } + else { #endif - memcpy(&radioData[dataStart], buf, len); + memcpy(&radioData[dataStart], buf, len); #if defined CCM_ENCRYPTION_ENABLED - } + } #endif - if (NRF_RADIO->STATE < 9) { - NRF_RADIO->EVENTS_TXREADY = 0; - NRF_RADIO->TASKS_TXEN = 1; - while (NRF_RADIO->EVENTS_TXREADY == 0) { - } - NRF_RADIO->EVENTS_TXREADY = 0; + if (NRF_RADIO->STATE < 9) { + NRF_RADIO->EVENTS_TXREADY = 0; + NRF_RADIO->TASKS_TXEN = 1; + while (NRF_RADIO->EVENTS_TXREADY == 0) { } + NRF_RADIO->EVENTS_TXREADY = 0; + } - NRF_RADIO->EVENTS_END = 0; - NRF_RADIO->TASKS_START = 1; - lastTxResult = true; + NRF_RADIO->EVENTS_END = 0; + NRF_RADIO->TASKS_START = 1; + lastTxResult = true; return true; } @@ -667,7 +664,7 @@ bool nrf_to_nrf::writeAckPayload(uint8_t pipe, void* buf, uint8_t len) { #if defined CCM_ENCRYPTION_ENABLED - if(enableEncryption){ + if (enableEncryption) { if (len) { for (int i = 0; i < CCM_IV_SIZE; i++) { @@ -686,13 +683,14 @@ bool nrf_to_nrf::writeAckPayload(uint8_t pipe, void* buf, uint8_t len) } len += CCM_IV_SIZE + CCM_COUNTER_SIZE + CCM_MIC_SIZE; - memcpy(&ackBuffer[1 + CCM_IV_SIZE + CCM_COUNTER_SIZE], &outBuffer[CCM_START_SIZE],len - CCM_IV_SIZE - CCM_COUNTER_SIZE); + memcpy(&ackBuffer[1 + CCM_IV_SIZE + CCM_COUNTER_SIZE], &outBuffer[CCM_START_SIZE], len - CCM_IV_SIZE - CCM_COUNTER_SIZE); packetCounter++; if (packetCounter > 200000) { packetCounter = 0; } } - }else{ + } + else { #endif memcpy(&ackBuffer[1], buf, len); #if defined CCM_ENCRYPTION_ENABLED @@ -1005,11 +1003,13 @@ void nrf_to_nrf::openWritingPipe(const uint8_t* address) /**********************************************************************************************************/ -bool nrf_to_nrf::txStandBy() { +bool nrf_to_nrf::txStandBy() +{ - if(NRF_RADIO->STATE == 11){ - while (NRF_RADIO->EVENTS_END == 0) {} - NRF_RADIO->EVENTS_END = 0; + if (NRF_RADIO->STATE == 11) { + while (NRF_RADIO->EVENTS_END == 0) { + } + NRF_RADIO->EVENTS_END = 0; } NRF_RADIO->EVENTS_DISABLED = 0; @@ -1026,9 +1026,10 @@ bool nrf_to_nrf::txStandBy() { bool nrf_to_nrf::txStandBy(uint32_t timeout, bool startTx) { - if(NRF_RADIO->STATE == 11){ - while (NRF_RADIO->EVENTS_END == 0) {} - NRF_RADIO->EVENTS_END = 0; + if (NRF_RADIO->STATE == 11) { + while (NRF_RADIO->EVENTS_END == 0) { + } + NRF_RADIO->EVENTS_END = 0; } NRF_RADIO->EVENTS_DISABLED = 0; @@ -1198,17 +1199,26 @@ bool nrf_to_nrf::testRPD(uint8_t RSSI) /**********************************************************************************************************/ +uint8_t nrf_to_nrf::getRSSI() +{ + NRF_RADIO->EVENTS_RSSIEND = 0; + NRF_RADIO->TASKS_RSSISTART = 1; + while (!NRF_RADIO->EVENTS_RSSIEND) { + } + return (uint8_t)NRF_RADIO->RSSISAMPLE; +} + +/**********************************************************************************************************/ + void nrf_to_nrf::powerUp() { - radioConfigured = false; - begin(); + NRF_RADIO->POWER = 1; } /**********************************************************************************************************/ void nrf_to_nrf::powerDown() { - DPL = false; NRF_RADIO->POWER = 0; } @@ -1403,12 +1413,12 @@ void nrf_to_nrf::setCounter(uint64_t counter) } /**********************************************************************************************************/ -void nrf_to_nrf::setIV(uint8_t IV[CCM_IV_SIZE]){ +void nrf_to_nrf::setIV(uint8_t IV[CCM_IV_SIZE]) +{ - for(int i=0; i #if defined(USE_TINYUSB) -// Needed for Serial.print on non-MBED enabled or adafruit-based nRF52 cores -#include "Adafruit_TinyUSB.h" + // Needed for Serial.print on non-MBED enabled or adafruit-based nRF52 cores + #include "Adafruit_TinyUSB.h" #endif -#if defined (NRF52811_XXAA) || defined (NRF52820_XXAA) || defined (NRF52833_XXAA) || defined (NRF52840_XXAA) -#define NRF_HAS_ENERGY_DETECT +#if defined(NRF52811_XXAA) || defined(NRF52820_XXAA) || defined(NRF52833_XXAA) || defined(NRF52840_XXAA) + #define NRF_HAS_ENERGY_DETECT #endif #define NRF52_RADIO_LIBRARY -#define DEFAULT_MAX_PAYLOAD_SIZE 32 -#define ACTUAL_MAX_PAYLOAD_SIZE 127 -#define ACK_TIMEOUT_1MBPS 600 // 300 with static payloads -#define ACK_TIMEOUT_2MBPS 400 // 265 with static payloads -#define ACK_TIMEOUT_250KBPS 800 // 500 with staticPayloads -#define ACK_TIMEOUT_1MBPS_OFFSET 300 -#define ACK_TIMEOUT_2MBPS_OFFSET 135 +#define DEFAULT_MAX_PAYLOAD_SIZE 32 +#define ACTUAL_MAX_PAYLOAD_SIZE 127 +#define ACK_TIMEOUT_1MBPS 600 // 300 with static payloads +#define ACK_TIMEOUT_2MBPS 400 // 265 with static payloads +#define ACK_TIMEOUT_250KBPS 800 // 500 with staticPayloads +#define ACK_TIMEOUT_1MBPS_OFFSET 300 +#define ACK_TIMEOUT_2MBPS_OFFSET 135 #define ACK_TIMEOUT_250KBPS_OFFSET 300 #define ACK_PAYLOAD_TIMEOUT_OFFSET 750 @@ -115,14 +115,13 @@ class nrf_to_nrf { public: - /** * @name Primary public interface * * These are the main methods you need to operate the chip */ /**@{*/ - + /** * Constructor for nrf_to_nrf * @@ -132,7 +131,6 @@ class nrf_to_nrf */ nrf_to_nrf(); - /** * Call this before operating the radio * @code @@ -160,7 +158,7 @@ class nrf_to_nrf * Same as NRF24 radio.write(); */ bool write(void* buf, uint8_t len, bool multicast = false, bool doEncryption = true); - + /** * Same as NRF24 * @param resetAddresses Used internally to reset addresses @@ -188,8 +186,7 @@ class nrf_to_nrf * Same as NRF24 */ bool isChipConnected(); - - + /**@}*/ /** * @name Advanced Operation @@ -197,7 +194,7 @@ class nrf_to_nrf * Methods you can use to drive the chip in more advanced ways */ /**@{*/ - + /** * Data buffer for radio data * The radio can handle packets up to 127 bytes if CRC is disabled @@ -205,7 +202,7 @@ class nrf_to_nrf * */ uint8_t radioData[ACTUAL_MAX_PAYLOAD_SIZE + 2]; - + /** * Not currently fully functional, calls the regular write(); */ @@ -241,7 +238,6 @@ class nrf_to_nrf */ void enableDynamicAck(); - /** * Same as NRF24 */ @@ -395,11 +391,18 @@ class nrf_to_nrf */ bool testRPD(uint8_t RSSI = 65); + /** + * A new function specific to the NRF52x devices, not available on NRF24 + * @return The function will return the RSSI, which is measured continuously and the value + * filtered using a single-pole IIR filter. This is a negative value: received signal strength = -A dBm + */ + uint8_t getRSSI(); + /** * Same as NRF24 */ uint8_t getARC(); - + #ifdef NRF_HAS_ENERGY_DETECT uint8_t sample_ed(void); #endif @@ -411,7 +414,7 @@ class nrf_to_nrf * Methods you can use to enable encryption & authentication */ /**@{*/ - + /** * Used internally to convert addresses */ @@ -422,12 +425,12 @@ class nrf_to_nrf * Function to encrypt data */ uint8_t encrypt(void* bufferIn, uint8_t size); - + /** * Function to decrypt data */ uint8_t decrypt(void* bufferIn, uint8_t size); - + /** * The data buffer where encrypted data is placed. See the datasheet p115 for the CCM data structure */ @@ -442,14 +445,14 @@ class nrf_to_nrf * Set the (default 3-byte) packet counter used for encryption */ void setCounter(uint64_t counter); - + /** * 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. */ void setIV(uint8_t IV[CCM_IV_SIZE]); - + /** * Enable use of the on-board AES CCM mode encryption * @@ -460,12 +463,12 @@ class nrf_to_nrf * Users need to take extra steps to prevent specific attacks, such as replay attacks, which can be prevented by * transmitting a timestamp or counter value, and only accepting packets with a current timestamp/counter value, * rejecting old data. - * + * * Encryption uses a 5-byte IV and 3-byte counter, the sizes of which can be configured in nrf_to_nrf.h * Maximum: 8-byte IV, 4-byte counter, plus the MAC/MIC is 4-bytes */ bool enableEncryption; - /**@}*/ + /**@}*/ #endif private: @@ -488,7 +491,6 @@ class nrf_to_nrf uint32_t rxPrefix; uint32_t txBase; uint32_t txPrefix; - bool radioConfigured; bool ackPayloadAvailable; uint8_t ackAvailablePipeNo; uint8_t lastPacketCounter; @@ -521,7 +523,7 @@ class nrf_to_nrf * * These docs are considered supplimental to the NRF24 documentation, mainly documenting the differences between NRF52 and NRF24 drivers * - * + * */ /** @@ -543,7 +545,7 @@ class nrf_to_nrf /** * @example examples/RF24Network/helloworld_rx/helloworld_rx.ino */ - + /** * @example examples/RF24Network/helloworld_rxEncryption/helloworld_rxEncryption.ino */ @@ -551,7 +553,7 @@ class nrf_to_nrf /** * @example examples/RF24Network/helloworld_tx/helloworld_tx.ino */ - + /** * @example examples/RF24Network/helloworld_txEncryption/helloworld_txEncryption.ino */ @@ -559,11 +561,11 @@ class nrf_to_nrf /** * @example examples/RF24Mesh/RF24Mesh_Example/RF24Mesh_Example.ino */ - + /** * @example examples/RF24Mesh/RF24Mesh_ExampleEncryption/RF24Mesh_ExampleEncryption.ino */ - + /** * @example examples/RF24Mesh/RF24Mesh_Example_MasterEncryption/RF24Mesh_Example_MasterEncryption.ino */