Don't log "Setting DIO2 as RF switch" unless we're actually going to do it. Also, if there's an error setting DIO2, log the error code.

This commit is contained in:
David Huang 2024-09-27 21:52:12 -05:00
parent 8efc15f4d9
commit 36a66df923

View File

@ -103,21 +103,19 @@ template <typename T> bool SX126xInterface<T>::init()
LOG_DEBUG("Current limit set to %f\n", currentLimit); LOG_DEBUG("Current limit set to %f\n", currentLimit);
LOG_DEBUG("Current limit set result %d\n", res); LOG_DEBUG("Current limit set result %d\n", res);
#ifdef SX126X_DIO2_AS_RF_SWITCH
LOG_DEBUG("Setting DIO2 as RF switch\n");
bool dio2AsRfSwitch = true;
#elif defined(ARCH_PORTDUINO)
bool dio2AsRfSwitch = false;
if (settingsMap[dio2_as_rf_switch]) {
LOG_DEBUG("Setting DIO2 as RF switch\n");
dio2AsRfSwitch = true;
}
#else
LOG_DEBUG("Setting DIO2 as not RF switch\n");
bool dio2AsRfSwitch = false;
#endif
if (res == RADIOLIB_ERR_NONE) { if (res == RADIOLIB_ERR_NONE) {
#ifdef SX126X_DIO2_AS_RF_SWITCH
bool dio2AsRfSwitch = true;
#elif defined(ARCH_PORTDUINO)
bool dio2AsRfSwitch = false;
if (settingsMap[dio2_as_rf_switch]) {
dio2AsRfSwitch = true;
}
#else
bool dio2AsRfSwitch = false;
#endif
res = lora.setDio2AsRfSwitch(dio2AsRfSwitch); res = lora.setDio2AsRfSwitch(dio2AsRfSwitch);
LOG_DEBUG("Set DIO2 as %sRF switch, result: %d\n", dio2AsRfSwitch ? "" : "not ", res);
} }
// If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has // If a pin isn't defined, we set it to RADIOLIB_NC, it is safe to always do external RF switching with RADIOLIB_NC as it has