replace delete in RadioInterface.cpp with std::unique_ptr (#9645)

Is part of the unique_ptr modernization effort.
This commit is contained in:
Jorropo
2026-02-14 21:39:26 +01:00
committed by GitHub
co-authored by GitHub
parent 184e4ddd83
commit ff485d5ff8
4 changed files with 64 additions and 71 deletions
+7 -10
View File
@@ -248,7 +248,6 @@ uint32_t timeLastPowered = 0;
static OSThread *powerFSMthread; static OSThread *powerFSMthread;
OSThread *ambientLightingThread; OSThread *ambientLightingThread;
RadioInterface *rIf = NULL;
#ifdef ARCH_PORTDUINO #ifdef ARCH_PORTDUINO
RadioLibHal *RadioLibHAL = NULL; RadioLibHal *RadioLibHAL = NULL;
#endif #endif
@@ -954,7 +953,7 @@ void setup()
#endif #endif
#endif #endif
initLoRa(); auto rIf = initLoRa();
lateInitVariant(); // Do board specific init (see extra_variants/README.md for documentation) lateInitVariant(); // Do board specific init (see extra_variants/README.md for documentation)
@@ -1003,12 +1002,12 @@ void setup()
if (!rIf) if (!rIf)
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_NO_RADIO); RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_NO_RADIO);
else { else {
router->addInterface(rIf);
// Log bit rate to debug output // Log bit rate to debug output
LOG_DEBUG("LoRA bitrate = %f bytes / sec", (float(meshtastic_Constants_DATA_PAYLOAD_LEN) / LOG_DEBUG("LoRA bitrate = %f bytes / sec", (float(meshtastic_Constants_DATA_PAYLOAD_LEN) /
(float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) * (float(rIf->getPacketTime(meshtastic_Constants_DATA_PAYLOAD_LEN)))) *
1000); 1000);
router->addInterface(std::move(rIf));
} }
// This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values // This must be _after_ service.init because we need our preferences loaded from flash to have proper timeout values
@@ -1150,10 +1149,7 @@ void loop()
} }
if (portduino_status.LoRa_in_error && rebootAtMsec == 0) { if (portduino_status.LoRa_in_error && rebootAtMsec == 0) {
LOG_ERROR("LoRa in error detected, attempting to recover"); LOG_ERROR("LoRa in error detected, attempting to recover");
if (rIf != nullptr) { router->addInterface(nullptr);
delete rIf;
rIf = nullptr;
}
if (portduino_config.lora_spi_dev == "ch341") { if (portduino_config.lora_spi_dev == "ch341") {
if (ch341Hal != nullptr) { if (ch341Hal != nullptr) {
delete ch341Hal; delete ch341Hal;
@@ -1169,8 +1165,9 @@ void loop()
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
if (initLoRa()) { auto rIf = initLoRa();
router->addInterface(rIf); if (rIf) {
router->addInterface(std::move(rIf));
portduino_status.LoRa_in_error = false; portduino_status.LoRa_in_error = false;
} else { } else {
LOG_WARN("Reconfigure failed, rebooting"); LOG_WARN("Reconfigure failed, rebooting");
+52 -58
View File
@@ -227,18 +227,14 @@ static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1];
// Global LoRa radio type // Global LoRa radio type
LoRaRadioType radioType = NO_RADIO; LoRaRadioType radioType = NO_RADIO;
extern RadioInterface *rIf;
extern RadioLibHal *RadioLibHAL; extern RadioLibHal *RadioLibHAL;
#if defined(HW_SPI1_DEVICE) && defined(ARCH_ESP32) #if defined(HW_SPI1_DEVICE) && defined(ARCH_ESP32)
extern SPIClass SPI1; extern SPIClass SPI1;
#endif #endif
bool initLoRa() std::unique_ptr<RadioInterface> initLoRa()
{ {
if (rIf != nullptr) { std::unique_ptr<RadioInterface> rIf = nullptr;
delete rIf;
rIf = nullptr;
}
#if ARCH_PORTDUINO #if ARCH_PORTDUINO
SPISettings spiSettings(portduino_config.spiSpeed, MSBFIRST, SPI_MODE0); SPISettings spiSettings(portduino_config.spiSpeed, MSBFIRST, SPI_MODE0);
@@ -252,26 +248,26 @@ bool initLoRa()
RADIOLIB_PIN_TYPE busy) { RADIOLIB_PIN_TYPE busy) {
switch (portduino_config.lora_module) { switch (portduino_config.lora_module) {
case use_rf95: case use_rf95:
return (RadioInterface *)new RF95Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new RF95Interface(hal, cs, irq, rst, busy));
case use_sx1262: case use_sx1262:
return (RadioInterface *)new SX1262Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new SX1262Interface(hal, cs, irq, rst, busy));
case use_sx1268: case use_sx1268:
return (RadioInterface *)new SX1268Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new SX1268Interface(hal, cs, irq, rst, busy));
case use_sx1280: case use_sx1280:
return (RadioInterface *)new SX1280Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new SX1280Interface(hal, cs, irq, rst, busy));
case use_lr1110: case use_lr1110:
return (RadioInterface *)new LR1110Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new LR1110Interface(hal, cs, irq, rst, busy));
case use_lr1120: case use_lr1120:
return (RadioInterface *)new LR1120Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new LR1120Interface(hal, cs, irq, rst, busy));
case use_lr1121: case use_lr1121:
return (RadioInterface *)new LR1121Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new LR1121Interface(hal, cs, irq, rst, busy));
case use_llcc68: case use_llcc68:
return (RadioInterface *)new LLCC68Interface(hal, cs, irq, rst, busy); return std::unique_ptr<RadioInterface>(new LLCC68Interface(hal, cs, irq, rst, busy));
case use_simradio: case use_simradio:
return (RadioInterface *)new SimRadio; return std::unique_ptr<RadioInterface>(new SimRadio);
default: default:
assert(0); // shouldn't happen assert(0); // shouldn't happen
return (RadioInterface *)nullptr; return std::unique_ptr<RadioInterface>(nullptr);
} }
}; };
@@ -292,8 +288,7 @@ bool initLoRa()
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No %s radio", portduino_config.loraModules[portduino_config.lora_module].c_str()); LOG_WARN("No %s radio", portduino_config.loraModules[portduino_config.lora_module].c_str());
delete rIf; rIf = nullptr;
rIf = NULL;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} else { } else {
LOG_INFO("%s init success", portduino_config.loraModules[portduino_config.lora_module].c_str()); LOG_INFO("%s init success", portduino_config.loraModules[portduino_config.lora_module].c_str());
@@ -308,11 +303,11 @@ bool initLoRa()
// radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init) // radio init MUST BE AFTER service.init, so we have our radio config settings (from nodedb init)
#if defined(USE_STM32WLx) #if defined(USE_STM32WLx)
if (!rIf) { if (!rIf) {
rIf = new STM32WLE5JCInterface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); rIf = std::unique_ptr<STM32WLE5JCInterface>(
new STM32WLE5JCInterface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No STM32WL radio"); LOG_WARN("No STM32WL radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("STM32WL init success"); LOG_INFO("STM32WL init success");
radioType = STM32WLx_RADIO; radioType = STM32WLx_RADIO;
@@ -322,11 +317,10 @@ bool initLoRa()
#if defined(RF95_IRQ) && RADIOLIB_EXCLUDE_SX127X != 1 #if defined(RF95_IRQ) && RADIOLIB_EXCLUDE_SX127X != 1
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new RF95Interface(RadioLibHAL, LORA_CS, RF95_IRQ, RF95_RESET, RF95_DIO1); rIf = std::unique_ptr<RF95Interface>(new RF95Interface(RadioLibHAL, LORA_CS, RF95_IRQ, RF95_RESET, RF95_DIO1));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No RF95 radio"); LOG_WARN("No RF95 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("RF95 init success"); LOG_INFO("RF95 init success");
radioType = RF95_RADIO; radioType = RF95_RADIO;
@@ -336,17 +330,17 @@ bool initLoRa()
#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && !defined(TCXO_OPTIONAL) && RADIOLIB_EXCLUDE_SX126X != 1 #if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && !defined(TCXO_OPTIONAL) && RADIOLIB_EXCLUDE_SX126X != 1
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
auto *sxIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); auto sxIf =
std::unique_ptr<SX1262Interface>(new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
#ifdef SX126X_DIO3_TCXO_VOLTAGE #ifdef SX126X_DIO3_TCXO_VOLTAGE
sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE);
#endif #endif
if (!sxIf->init()) { if (!sxIf->init()) {
LOG_WARN("No SX1262 radio"); LOG_WARN("No SX1262 radio");
delete sxIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1262 init success"); LOG_INFO("SX1262 init success");
rIf = sxIf; rIf = std::move(sxIf);
radioType = SX1262_RADIO; radioType = SX1262_RADIO;
} }
} }
@@ -355,26 +349,26 @@ bool initLoRa()
#if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && defined(TCXO_OPTIONAL) #if defined(USE_SX1262) && !defined(ARCH_PORTDUINO) && defined(TCXO_OPTIONAL)
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
// try using the specified TCXO voltage // try using the specified TCXO voltage
auto *sxIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); auto sxIf =
std::unique_ptr<SX1262Interface>(new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE);
if (!sxIf->init()) { if (!sxIf->init()) {
LOG_WARN("No SX1262 radio with TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); LOG_WARN("No SX1262 radio with TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE);
delete sxIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1262 init success, TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); LOG_INFO("SX1262 init success, TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE);
rIf = sxIf; rIf = std::move(sxIf);
radioType = SX1262_RADIO; radioType = SX1262_RADIO;
} }
} }
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
// If specified TCXO voltage fails, attempt to use DIO3 as a reference instead // If specified TCXO voltage fails, attempt to use DIO3 as a reference instead
rIf = new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); rIf =
std::unique_ptr<SX1262Interface>(new SX1262Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No SX1262 radio with XTAL, Vref 0.0V"); LOG_WARN("No SX1262 radio with XTAL, Vref 0.0V");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1262 init success, XTAL, Vref 0.0V"); LOG_INFO("SX1262 init success, XTAL, Vref 0.0V");
radioType = SX1262_RADIO; radioType = SX1262_RADIO;
@@ -386,25 +380,25 @@ bool initLoRa()
#if defined(SX126X_DIO3_TCXO_VOLTAGE) && defined(TCXO_OPTIONAL) #if defined(SX126X_DIO3_TCXO_VOLTAGE) && defined(TCXO_OPTIONAL)
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
// try using the specified TCXO voltage // try using the specified TCXO voltage
auto *sxIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); auto sxIf =
std::unique_ptr<SX1268Interface>(new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE); sxIf->setTCXOVoltage(SX126X_DIO3_TCXO_VOLTAGE);
if (!sxIf->init()) { if (!sxIf->init()) {
LOG_WARN("No SX1268 radio with TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); LOG_WARN("No SX1268 radio with TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE);
delete sxIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1268 init success, TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE); LOG_INFO("SX1268 init success, TCXO, Vref %fV", SX126X_DIO3_TCXO_VOLTAGE);
rIf = sxIf; rIf = std::move(sxIf);
radioType = SX1268_RADIO; radioType = SX1268_RADIO;
} }
} }
#endif #endif
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); rIf =
std::unique_ptr<SX1268Interface>(new SX1268Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No SX1268 radio"); LOG_WARN("No SX1268 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1268 init success"); LOG_INFO("SX1268 init success");
radioType = SX1268_RADIO; radioType = SX1268_RADIO;
@@ -414,11 +408,11 @@ bool initLoRa()
#if defined(USE_LLCC68) #if defined(USE_LLCC68)
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new LLCC68Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY); rIf =
std::unique_ptr<LLCC68Interface>(new LLCC68Interface(RadioLibHAL, SX126X_CS, SX126X_DIO1, SX126X_RESET, SX126X_BUSY));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No LLCC68 radio"); LOG_WARN("No LLCC68 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("LLCC68 init success"); LOG_INFO("LLCC68 init success");
radioType = LLCC68_RADIO; radioType = LLCC68_RADIO;
@@ -428,11 +422,11 @@ bool initLoRa()
#if defined(USE_LR1110) && RADIOLIB_EXCLUDE_LR11X0 != 1 #if defined(USE_LR1110) && RADIOLIB_EXCLUDE_LR11X0 != 1
if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) { if ((!rIf) && (config.lora.region != meshtastic_Config_LoRaConfig_RegionCode_LORA_24)) {
rIf = new LR1110Interface(RadioLibHAL, LR1110_SPI_NSS_PIN, LR1110_IRQ_PIN, LR1110_NRESET_PIN, LR1110_BUSY_PIN); rIf = std::unique_ptr<LR1110Interface>(
new LR1110Interface(RadioLibHAL, LR1110_SPI_NSS_PIN, LR1110_IRQ_PIN, LR1110_NRESET_PIN, LR1110_BUSY_PIN));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No LR1110 radio"); LOG_WARN("No LR1110 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("LR1110 init success"); LOG_INFO("LR1110 init success");
radioType = LR1110_RADIO; radioType = LR1110_RADIO;
@@ -442,11 +436,11 @@ bool initLoRa()
#if defined(USE_LR1120) && RADIOLIB_EXCLUDE_LR11X0 != 1 #if defined(USE_LR1120) && RADIOLIB_EXCLUDE_LR11X0 != 1
if (!rIf) { if (!rIf) {
rIf = new LR1120Interface(RadioLibHAL, LR1120_SPI_NSS_PIN, LR1120_IRQ_PIN, LR1120_NRESET_PIN, LR1120_BUSY_PIN); rIf = std::unique_ptr<LR1120Interface>(
new LR1120Interface(RadioLibHAL, LR1120_SPI_NSS_PIN, LR1120_IRQ_PIN, LR1120_NRESET_PIN, LR1120_BUSY_PIN));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No LR1120 radio"); LOG_WARN("No LR1120 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("LR1120 init success"); LOG_INFO("LR1120 init success");
radioType = LR1120_RADIO; radioType = LR1120_RADIO;
@@ -456,11 +450,11 @@ bool initLoRa()
#if defined(USE_LR1121) && RADIOLIB_EXCLUDE_LR11X0 != 1 #if defined(USE_LR1121) && RADIOLIB_EXCLUDE_LR11X0 != 1
if (!rIf) { if (!rIf) {
rIf = new LR1121Interface(RadioLibHAL, LR1121_SPI_NSS_PIN, LR1121_IRQ_PIN, LR1121_NRESET_PIN, LR1121_BUSY_PIN); rIf = std::unique_ptr<LR1121Interface>(
new LR1121Interface(RadioLibHAL, LR1121_SPI_NSS_PIN, LR1121_IRQ_PIN, LR1121_NRESET_PIN, LR1121_BUSY_PIN));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No LR1121 radio"); LOG_WARN("No LR1121 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("LR1121 init success"); LOG_INFO("LR1121 init success");
radioType = LR1121_RADIO; radioType = LR1121_RADIO;
@@ -470,11 +464,11 @@ bool initLoRa()
#if defined(USE_SX1280) && RADIOLIB_EXCLUDE_SX128X != 1 #if defined(USE_SX1280) && RADIOLIB_EXCLUDE_SX128X != 1
if (!rIf) { if (!rIf) {
rIf = new SX1280Interface(RadioLibHAL, SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY); rIf =
std::unique_ptr<SX1280Interface>(new SX1280Interface(RadioLibHAL, SX128X_CS, SX128X_DIO1, SX128X_RESET, SX128X_BUSY));
if (!rIf->init()) { if (!rIf->init()) {
LOG_WARN("No SX1280 radio"); LOG_WARN("No SX1280 radio");
delete rIf; rIf = nullptr;
rIf = NULL;
} else { } else {
LOG_INFO("SX1280 init success"); LOG_INFO("SX1280 init success");
radioType = SX1280_RADIO; radioType = SX1280_RADIO;
@@ -496,7 +490,7 @@ bool initLoRa()
rebootAtMsec = millis() + 5000; rebootAtMsec = millis() + 5000;
} }
} }
return rIf != nullptr; return rIf;
} }
void initRegion() void initRegion()
+2 -1
View File
@@ -6,6 +6,7 @@
#include "PointerQueue.h" #include "PointerQueue.h"
#include "airtime.h" #include "airtime.h"
#include "error.h" #include "error.h"
#include <memory>
// Forward decl to avoid a direct include of generated config headers / full LoRaConfig definition in this widely-included file. // Forward decl to avoid a direct include of generated config headers / full LoRaConfig definition in this widely-included file.
typedef struct _meshtastic_Config_LoRaConfig meshtastic_Config_LoRaConfig; typedef struct _meshtastic_Config_LoRaConfig meshtastic_Config_LoRaConfig;
@@ -279,7 +280,7 @@ class RadioInterface
} }
}; };
bool initLoRa(); std::unique_ptr<RadioInterface> initLoRa();
/// Debug printing for packets /// Debug printing for packets
void printPacket(const char *prefix, const meshtastic_MeshPacket *p); void printPacket(const char *prefix, const meshtastic_MeshPacket *p);
+3 -2
View File
@@ -8,6 +8,7 @@
#include "PointerQueue.h" #include "PointerQueue.h"
#include "RadioInterface.h" #include "RadioInterface.h"
#include "concurrency/OSThread.h" #include "concurrency/OSThread.h"
#include <memory>
/** /**
* A mesh aware router that supports multiple interfaces. * A mesh aware router that supports multiple interfaces.
@@ -20,7 +21,7 @@ class Router : protected concurrency::OSThread, protected PacketHistory
PointerQueue<meshtastic_MeshPacket> fromRadioQueue; PointerQueue<meshtastic_MeshPacket> fromRadioQueue;
protected: protected:
RadioInterface *iface = NULL; std::unique_ptr<RadioInterface> iface = nullptr;
public: public:
/** /**
@@ -32,7 +33,7 @@ class Router : protected concurrency::OSThread, protected PacketHistory
/** /**
* Currently we only allow one interface, that may change in the future * Currently we only allow one interface, that may change in the future
*/ */
void addInterface(RadioInterface *_iface) { iface = _iface; } void addInterface(std::unique_ptr<RadioInterface> _iface) { iface = std::move(_iface); }
/** /**
* do idle processing * do idle processing