From 508894075163e53a05e2ffd413d364014c340eba Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 28 Apr 2022 20:11:03 -0500 Subject: [PATCH] Set tx/rx en correctly as well as rf ant switch (#1420) --- src/mesh/SX126xInterface.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/mesh/SX126xInterface.cpp b/src/mesh/SX126xInterface.cpp index b0c48d55a..901c6e035 100644 --- a/src/mesh/SX126xInterface.cpp +++ b/src/mesh/SX126xInterface.cpp @@ -65,7 +65,7 @@ bool SX126xInterface::init() #ifdef SX126X_TXEN // lora.begin sets Dio2 as RF switch control, which is not true if we are manually controlling RX and TX if (res == ERR_NONE) - res = lora.setDio2AsRfSwitch(false); + res = lora.setDio2AsRfSwitch(true); #endif #if 0 @@ -129,9 +129,6 @@ bool SX126xInterface::reconfigure() err = lora.setSyncWord(syncWord); assert(err == ERR_NONE); - err = lora.setCurrentLimit(currentLimit); - assert(err == ERR_NONE); - err = lora.setPreambleLength(preambleLength); assert(err == ERR_NONE); @@ -143,7 +140,7 @@ bool SX126xInterface::reconfigure() power = 22; err = lora.setOutputPower(power); assert(err == ERR_NONE); - + startReceive(); // restart receiving return ERR_NONE; @@ -191,7 +188,11 @@ void SX126xInterface::addReceiveMetadata(MeshPacket *mp) template void SX126xInterface::configHardwareForSend() { -#ifdef SX126X_TXEN // we have RXEN/TXEN control - turn on TX power / off RX power +// If we have RXEN/TXEN control - turn on TX power / off RX power +#ifdef SX126X_RXEN + digitalWrite(SX126X_RXEN, LOW); +#endif +#ifdef SX126X_TXEN digitalWrite(SX126X_TXEN, HIGH); #endif @@ -210,7 +211,11 @@ void SX126xInterface::startReceive() setStandby(); -#ifdef SX126X_RXEN // we have RXEN/TXEN control - turn on RX power / off TX power +// If we have RXEN/TXEN control - turn on RX power / off TX power +#ifdef SX126X_TXEN + digitalWrite(SX126X_TXEN, LOW); +#endif +#ifdef SX126X_RXEN digitalWrite(SX126X_RXEN, HIGH); #endif