Revamp yaml config for Raspbian

This commit is contained in:
Jonathan Bennett 2023-11-19 14:00:03 -06:00
parent 08297bb0b7
commit 4af90eeb39
5 changed files with 40 additions and 53 deletions

View File

@ -1,26 +1,21 @@
# Define your devices here. # Define your devices here using Broadcom pin numbering
# Use Broadcom pin numbering # Uncomment the block that corresponds to your hardware
---
Lora:
# Module: sx1262 # Waveshare SX126X XXXM
# DIO2_AS_RF_SWITCH: true
# CS: 21
# IRQ: 16
# Busy: 20
# Reset: 18
#Waveshare SX126X XXXM # Module: sx1262 # Waveshare SX1302 LISTEN ONLY AT THIS TIME!
# CS: 7
# IRQ: 17
# Reset: 22
#USE_SX1262: true # Module: RF95 # Adafruit RFM9x
#SX126X_DIO2_AS_RF_SWITCH: true # Reset: 25
#SX126X_CS: 21 # CS: 7
#SX126X_DIO1: 16 # IRQ: 22
#SX126X_BUSY: 20 # Busy: 23
#SX126X_RESET: 18
#Waveshare SX1302 LISTEN ONLY AT THIS TIME!
#USE_SX1262: true
#SX126X_CS: 7
#SX126X_DIO1: 17
#SX126X_RESET: 22
#Adafruit RFM9x
#USE_RF95: true
#RF95_RESET: 25
#RF95_NSS: 7
#RF95_IRQ: 22
#RF95_DIO1: 23

View File

@ -694,8 +694,8 @@ void setup()
if (settingsMap[use_sx1262]) { if (settingsMap[use_sx1262]) {
if (!rIf) { if (!rIf) {
PiHal *RadioLibHAL = new PiHal(1); PiHal *RadioLibHAL = new PiHal(1);
rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[sx126x_cs], settingsMap[sx126x_dio1], rIf = new SX1262Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[sx126x_reset], settingsMap[sx126x_busy]); settingsMap[busy]);
if (!rIf->init()) { if (!rIf->init()) {
LOG_ERROR("Failed to find SX1262 radio\n"); LOG_ERROR("Failed to find SX1262 radio\n");
delete rIf; delete rIf;
@ -707,8 +707,8 @@ void setup()
} else if (settingsMap[use_rf95]) { } else if (settingsMap[use_rf95]) {
if (!rIf) { if (!rIf) {
PiHal *RadioLibHAL = new PiHal(1); PiHal *RadioLibHAL = new PiHal(1);
rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[rf95_nss], settingsMap[rf95_irq], rIf = new RF95Interface((LockingArduinoHal *)RadioLibHAL, settingsMap[cs], settingsMap[irq], settingsMap[reset],
settingsMap[rf95_reset], settingsMap[rf95_dio1]); settingsMap[busy]);
if (!rIf->init()) { if (!rIf->init()) {
LOG_ERROR("Failed to find RF95 radio\n"); LOG_ERROR("Failed to find RF95 radio\n");
delete rIf; delete rIf;

View File

@ -79,7 +79,7 @@ template <typename T> bool SX126xInterface<T>::init()
bool dio2AsRfSwitch = true; bool dio2AsRfSwitch = true;
#elif defined(ARCH_RASPBERRY_PI) #elif defined(ARCH_RASPBERRY_PI)
bool dio2AsRfSwitch = false; bool dio2AsRfSwitch = false;
if (settingsMap[sx126x_dio2_as_rf_switch]) { if (settingsMap[dio2_as_rf_switch]) {
LOG_DEBUG("Setting DIO2 as RF switch\n"); LOG_DEBUG("Setting DIO2 as RF switch\n");
dio2AsRfSwitch = true; dio2AsRfSwitch = true;
} }

View File

@ -123,17 +123,21 @@ void portduinoSetup()
} }
try { try {
settingsMap[use_sx1262] = yamlConfig["USE_SX1262"].as<bool>(false); if (yamlConfig["Lora"]) {
settingsMap[sx126x_dio2_as_rf_switch] = yamlConfig["SX126X_DIO2_AS_RF_SWITCH"].as<bool>(false); settingsMap[use_sx1262] = false;
settingsMap[sx126x_cs] = yamlConfig["SX126X_CS"].as<int>(RADIOLIB_NC); settingsMap[use_rf95] = false;
settingsMap[sx126x_dio1] = yamlConfig["SX126X_DIO1"].as<int>(RADIOLIB_NC);
settingsMap[sx126x_busy] = yamlConfig["SX126X_BUSY"].as<int>(RADIOLIB_NC); if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "sx1262") {
settingsMap[sx126x_reset] = yamlConfig["SX126X_RESET"].as<int>(RADIOLIB_NC); settingsMap[use_sx1262] = true;
settingsMap[use_rf95] = yamlConfig["USE_RF95"].as<bool>(false); } else if (yamlConfig["Lora"]["Module"] && yamlConfig["Lora"]["Module"].as<std::string>("") == "RF95") {
settingsMap[rf95_nss] = yamlConfig["RF95_NSS"].as<int>(RADIOLIB_NC); settingsMap[use_rf95] = true;
settingsMap[rf95_irq] = yamlConfig["RF95_IRQ"].as<int>(RADIOLIB_NC); }
settingsMap[rf95_reset] = yamlConfig["RF95_RESET"].as<int>(RADIOLIB_NC); settingsMap[dio2_as_rf_switch] = yamlConfig["Lora"]["DIO2_AS_RF_SWITCH"].as<bool>(false);
settingsMap[rf95_dio1] = yamlConfig["RF95_DIO1"].as<int>(RADIOLIB_NC); settingsMap[cs] = yamlConfig["Lora"]["CS"].as<int>(RADIOLIB_NC);
settingsMap[irq] = yamlConfig["Lora"]["IRQ"].as<int>(RADIOLIB_NC);
settingsMap[busy] = yamlConfig["Lora"]["Busy"].as<int>(RADIOLIB_NC);
settingsMap[reset] = yamlConfig["Lora"]["Reset"].as<int>(RADIOLIB_NC);
}
} catch (YAML::Exception e) { } catch (YAML::Exception e) {
std::cout << "*** Exception " << e.what() << std::endl; std::cout << "*** Exception " << e.what() << std::endl;

View File

@ -4,18 +4,6 @@
extern std::map<int, int> settingsMap; extern std::map<int, int> settingsMap;
enum { enum { use_sx1262, cs, irq, busy, reset, dio2_as_rf_switch, use_rf95 };
use_sx1262,
sx126x_cs,
sx126x_dio1,
sx126x_busy,
sx126x_reset,
sx126x_dio2_as_rf_switch,
use_rf95,
rf95_nss,
rf95_irq,
rf95_reset,
rf95_dio1
};
#endif #endif