From 7a1a597a6541ef995e34fe324160e0cd0c873372 Mon Sep 17 00:00:00 2001 From: Avamander Date: Sat, 18 Jan 2020 02:23:18 +0200 Subject: [PATCH] Add function to get automatic retransmission count (#558) Added getARC() to get automatic retransmission count (ARC_CNT) Co-authored-by: Georgios Karnas --- RF24.cpp | 8 ++++++++ RF24.h | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index 8ae931064..52edfe2e6 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -1478,6 +1478,14 @@ uint8_t RF24::getPALevel(void) /****************************************************************************/ +uint8_t RF24::getARC(void) +{ + + return read_register(OBSERVE_TX) & 0x0F; +} + +/****************************************************************************/ + bool RF24::setDataRate(rf24_datarate_e speed) { bool result = false; diff --git a/RF24.h b/RF24.h index 5a6673c12..828236ea1 100644 --- a/RF24.h +++ b/RF24.h @@ -889,13 +889,22 @@ class RF24 { uint8_t getPALevel(void); /** - * Set the transmission data rate + * Returns automatic retransmission count (ARC_CNT) * - * @warning setting RF24_250KBPS will fail for non-plus units + * Value resets with each new transmission. Allows roughly estimating signal strength. * - * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps - * @return true if the change was successful + * @return Returns values from 0 to 15. */ + uint8_t getARC(void); + + /** + * Set the transmission data rate + * + * @warning setting RF24_250KBPS will fail for non-plus units + * + * @param speed RF24_250KBPS for 250kbs, RF24_1MBPS for 1Mbps, or RF24_2MBPS for 2Mbps + * @return true if the change was successful + */ bool setDataRate(rf24_datarate_e speed); /** @@ -1118,7 +1127,7 @@ class RF24 { */ uint8_t get_status(void); - #if ! defined (MINIMAL) + #if !defined (MINIMAL) /** * Decode and print the given status to stdout