From e536e4bebc7c23079115a57de38ed0462700427e Mon Sep 17 00:00:00 2001 From: Andrew Andrianov Date: Thu, 7 Jan 2021 12:08:39 +0300 Subject: [PATCH 1/5] RF24: Implement MY_RF24_INVERTED_ACK hack This hack allows better nRF24L01<-->SI24R01 interoperability Signed-off-by: Andrew Andrianov --- MyConfig.h | 42 ++++++++++++++++++++++++++++++ hal/transport/RF24/driver/RF24.cpp | 2 ++ keywords.txt | 1 + 3 files changed, 45 insertions(+) diff --git a/MyConfig.h b/MyConfig.h index 0aa451420..b4e776d4c 100755 --- a/MyConfig.h +++ b/MyConfig.h @@ -420,6 +420,48 @@ #define MY_RF24_CHANNEL (76) #endif +/** + * @def MY_RF24_INVERTED_ACK + * @brief Assume that this node's radio auto-ack bit is reversed + * + * Define this if this node has a wireless chip with AutoACK bit reversed + * compared to wireless chip in the gateway. Read this for more details. + * + * There are a dozen nRF24L01+ clones out there in the wild. A few of them (SI24R01) + * have their AutoACK bit inverted, due to a bug in the original doc they ripped off + * + * If this define doesn't help with your setup (and your clones are even weirder), + * here are a few more tricks: + * + * 1. Assign a static Parent ID and Node ID for your node. + * + * #define MY_NODE_ID 1 + * #define MY_PARENT_NODE_ID 0 + * #define MY_PARENT_NODE_IS_STATIC + * + * However you loose the automated 'mesh' organisation function of the network. + * That is not fun, but it's okay for some leak sensors that should have this static + * anyway. + * + * 2. Try different speeds. Some of the fakes I got don't play along with genuine + * chips nicely when the speed is 250Kbps. 1Mbps and 2Mbps work fine. + * + * 3. Put your finger on the PCB antenna. If the thing starts working, you are missing + * a 1 pF capacitor on the module. See this post: + * + * https://ncrmnt.org/2021/01/03/nrf24l01-fixing-the-magic-finger-problem/ + * + * + * Obligatory reading material: + * + * https://sigrok.org/wiki/Protocol_decoder:Nrf24l01 - A list of clones and their 'features' + * https://hackaday.com/2015/02/23/nordic-nrf24l01-real-vs-fake/ - Hack-a-Day article describing the problem + * https://forum.mysensors.org/topic/9947/nrf24l01-si24r1 - mysensors forum thread + * https://ncrmnt.org/2015/03/13/how-do-i-cost-optimize-nrf24l01/ - Missing components on some COB fakes + * + */ +//#define MY_RF24_INVERTED_ACK + /** * @def MY_RF24_DATARATE * @brief RF24 data rate. diff --git a/hal/transport/RF24/driver/RF24.cpp b/hal/transport/RF24/driver/RF24.cpp index 38217b673..45fadfe25 100644 --- a/hal/transport/RF24/driver/RF24.cpp +++ b/hal/transport/RF24/driver/RF24.cpp @@ -385,7 +385,9 @@ LOCAL void RF24_setNodeAddress(const uint8_t address) // enable node pipe RF24_setPipe(_BV(RF24_ERX_P0 + RF24_BROADCAST_PIPE) | _BV(RF24_ERX_P0)); // enable autoACK on pipe 0 +#ifndef MY_RF24_INVERTED_ACK RF24_setAutoACK(_BV(RF24_ENAA_P0)); +#endif } } diff --git a/keywords.txt b/keywords.txt index d63941799..4a94ded78 100755 --- a/keywords.txt +++ b/keywords.txt @@ -158,6 +158,7 @@ MY_RF24_BASE_RADIO_ID LITERAL1 MY_RF24_ENABLE_ENCRYPTION LITERAL1 MY_RF24_CE_PIN LITERAL1 MY_RF24_CHANNEL LITERAL1 +MY_RF24_INVERTED_ACK LITERAL1 MY_RF24_CS_PIN LITERAL1 MY_RF24_DATARATE LITERAL1 MY_RF24_IRQ_PIN LITERAL1 From 0defe3d2e31f19feee21be847deba17af347fe65 Mon Sep 17 00:00:00 2001 From: Andrew Andrianov Date: Fri, 26 Feb 2021 22:24:30 +0300 Subject: [PATCH 2/5] MyTransportHal: Implement MY_TRANSPORT_SEND_RETRIES Signed-off-by: Andrew Andrianov --- MyConfig.h | 9 +++++++++ hal/transport/MyTransportHAL.cpp | 8 ++++++++ keywords.txt | 1 + 3 files changed, 18 insertions(+) diff --git a/MyConfig.h b/MyConfig.h index b4e776d4c..e7d1c3dda 100755 --- a/MyConfig.h +++ b/MyConfig.h @@ -1153,6 +1153,15 @@ #define MY_TRANSPORT_DISCOVERY_INTERVAL_MS (20*60*1000ul) #endif +/** + * @def MY_TRANSPORT_SEND_RETRIES + * @brief If defined to a positive number N, the node will try to send the payload to the + * uplink up to N times before actually failing. Useful when working in a noisy environment + * @note Setting this option too high will + * + */ +//#define MY_TRANSPORT_SEND_RETRIES (5) + /** *@def MY_TRANSPORT_UPLINK_CHECK_DISABLED *@brief If defined, disables uplink check to GW during transport initialisation diff --git a/hal/transport/MyTransportHAL.cpp b/hal/transport/MyTransportHAL.cpp index 7fdd6cd9d..369cab397 100644 --- a/hal/transport/MyTransportHAL.cpp +++ b/hal/transport/MyTransportHAL.cpp @@ -173,7 +173,15 @@ bool transportHALSend(const uint8_t nextRecipient, const MyMessage *outMsg, cons const uint8_t finalLength = len; #endif +#ifdef MY_TRANSPORT_SEND_RETRIES + uint8_t retries = MY_TRANSPORT_RETRIES; + bool result = false; + while (retries-- && (!result)) { + result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK); + } +#else bool result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK); +#endif TRANSPORT_HAL_DEBUG(PSTR("THA:SND:MSG LEN=%" PRIu8 ",RES=%" PRIu8 "\n"), finalLength, result); return result; } diff --git a/keywords.txt b/keywords.txt index 4a94ded78..831d2e046 100755 --- a/keywords.txt +++ b/keywords.txt @@ -66,6 +66,7 @@ MY_SIGNAL_REPORT_ENABLED LITERAL1 MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS LITERAL1 MY_SMART_SLEEP_WAIT_DURATION_MS LITERAL1 MY_TRANSPORT_CHKUPL_INTERVAL_MS LITERAL1 +MY_TRANSPORT_SEND_RETRIES LITERAL1 MY_TRANSPORT_DISCOVERY_INTERVAL_MS LITERAL1 MY_TRANSPORT_MAX_TSM_FAILURES LITERAL1 MY_TRANSPORT_MAX_TX_FAILURES LITERAL1 From ddc71a2e871a66838035d5d72dbad1c03bf4df13 Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 21 Oct 2023 10:46:10 +0200 Subject: [PATCH 3/5] Update MyTransportHAL.cpp --- hal/transport/MyTransportHAL.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hal/transport/MyTransportHAL.cpp b/hal/transport/MyTransportHAL.cpp index 369cab397..5166bc35f 100644 --- a/hal/transport/MyTransportHAL.cpp +++ b/hal/transport/MyTransportHAL.cpp @@ -174,7 +174,7 @@ bool transportHALSend(const uint8_t nextRecipient, const MyMessage *outMsg, cons #endif #ifdef MY_TRANSPORT_SEND_RETRIES - uint8_t retries = MY_TRANSPORT_RETRIES; + uint8_t retries = MY_TRANSPORT_SEND_RETRIES; bool result = false; while (retries-- && (!result)) { result = transportSend(nextRecipient, (void *)tx_data, finalLength, noACK); From b8d920894f00cc7481c2e4587f7de163111857dd Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 21 Oct 2023 10:46:39 +0200 Subject: [PATCH 4/5] Update keywords.txt --- keywords.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 831d2e046..75ba80e76 100755 --- a/keywords.txt +++ b/keywords.txt @@ -66,7 +66,7 @@ MY_SIGNAL_REPORT_ENABLED LITERAL1 MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS LITERAL1 MY_SMART_SLEEP_WAIT_DURATION_MS LITERAL1 MY_TRANSPORT_CHKUPL_INTERVAL_MS LITERAL1 -MY_TRANSPORT_SEND_RETRIES LITERAL1 +MY_TRANSPORT_SEND_RETRIES LITERAL1 MY_TRANSPORT_DISCOVERY_INTERVAL_MS LITERAL1 MY_TRANSPORT_MAX_TSM_FAILURES LITERAL1 MY_TRANSPORT_MAX_TX_FAILURES LITERAL1 From 7f01cdd27bc6c18e46f1e984f6c958f011d4b0e8 Mon Sep 17 00:00:00 2001 From: Olivier Date: Sat, 21 Oct 2023 10:49:06 +0200 Subject: [PATCH 5/5] Update keywords.txt --- keywords.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 75ba80e76..ff09e8ebd 100755 --- a/keywords.txt +++ b/keywords.txt @@ -66,7 +66,7 @@ MY_SIGNAL_REPORT_ENABLED LITERAL1 MY_SLEEP_TRANSPORT_RECONNECT_TIMEOUT_MS LITERAL1 MY_SMART_SLEEP_WAIT_DURATION_MS LITERAL1 MY_TRANSPORT_CHKUPL_INTERVAL_MS LITERAL1 -MY_TRANSPORT_SEND_RETRIES LITERAL1 +MY_TRANSPORT_SEND_RETRIES LITERAL1 MY_TRANSPORT_DISCOVERY_INTERVAL_MS LITERAL1 MY_TRANSPORT_MAX_TSM_FAILURES LITERAL1 MY_TRANSPORT_MAX_TX_FAILURES LITERAL1