diff --git a/src/modules/LLCC68/LLCC68.cpp b/src/modules/LLCC68/LLCC68.cpp index ef1cbb62..a0d077aa 100644 --- a/src/modules/LLCC68/LLCC68.cpp +++ b/src/modules/LLCC68/LLCC68.cpp @@ -2,7 +2,7 @@ #if !defined(RADIOLIB_EXCLUDE_SX126X) LLCC68::LLCC68(Module* mod) : SX1262(mod) { - + _chipType = RADIOLIB_LLCC68_CHIP_TYPE; } int16_t LLCC68::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_t syncWord, int8_t power, uint16_t preambleLength, float tcxoVoltage, bool useRegulatorLDO) { diff --git a/src/modules/LLCC68/LLCC68.h b/src/modules/LLCC68/LLCC68.h index 2810041d..424563ad 100644 --- a/src/modules/LLCC68/LLCC68.h +++ b/src/modules/LLCC68/LLCC68.h @@ -8,6 +8,9 @@ #include "../../Module.h" #include "../SX126x/SX1262.h" +//RADIOLIB_SX126X_REG_VERSION_STRING +#define RADIOLIB_LLCC68_CHIP_TYPE "LLCC68" + /*! \class LLCC68 diff --git a/src/modules/SX126x/SX1261.h b/src/modules/SX126x/SX1261.h index 195b4327..13c5ff7d 100644 --- a/src/modules/SX126x/SX1261.h +++ b/src/modules/SX126x/SX1261.h @@ -13,7 +13,7 @@ #define RADIOLIB_SX126X_PA_CONFIG_SX1261 0x01 //RADIOLIB_SX126X_REG_VERSION_STRING -#define RADIOLIB_SX1261_CHIP_TYPE 1 +#define RADIOLIB_SX1261_CHIP_TYPE "SX1261" /*! \class SX1261 diff --git a/src/modules/SX126x/SX1262.h b/src/modules/SX126x/SX1262.h index 6da9e2a5..e9919b83 100644 --- a/src/modules/SX126x/SX1262.h +++ b/src/modules/SX126x/SX1262.h @@ -13,7 +13,7 @@ //RADIOLIB_SX126X_REG_VERSION_STRING // Note: this should really be "2", however, it seems that all SX1262 devices report as SX1261 -#define RADIOLIB_SX1262_CHIP_TYPE 1 +#define RADIOLIB_SX1262_CHIP_TYPE "SX1261" /*! \class SX1262 diff --git a/src/modules/SX126x/SX1268.h b/src/modules/SX126x/SX1268.h index d8dc0867..ab1bd222 100644 --- a/src/modules/SX126x/SX1268.h +++ b/src/modules/SX126x/SX1268.h @@ -12,7 +12,7 @@ #define RADIOLIB_SX126X_PA_CONFIG_SX1268 0x00 //RADIOLIB_SX126X_REG_VERSION_STRING -#define RADIOLIB_SX1268_CHIP_TYPE 8 +#define RADIOLIB_SX1268_CHIP_TYPE "SX1268" /*! \class SX1268 diff --git a/src/modules/SX126x/SX126x.cpp b/src/modules/SX126x/SX126x.cpp index 71f1b55b..78727347 100644 --- a/src/modules/SX126x/SX126x.cpp +++ b/src/modules/SX126x/SX126x.cpp @@ -1962,11 +1962,9 @@ int16_t SX126x::SPIparseStatus(uint8_t in) { return(RADIOLIB_ERR_NONE); } -bool SX126x::findChip(uint8_t ver) { +bool SX126x::findChip(const char* verStr) { uint8_t i = 0; bool flagFound = false; - char versionBuff[16]; - sprintf(versionBuff, "SX126%d", ver); while((i < 10) && !flagFound) { // reset the module reset(); @@ -1976,7 +1974,7 @@ bool SX126x::findChip(uint8_t ver) { _mod->SPIreadRegisterBurst(RADIOLIB_SX126X_REG_VERSION_STRING, 16, (uint8_t*)version); // check version register - if(strncmp(versionBuff, version, 6) == 0) { + if(strncmp(verStr, version, 6) == 0) { RADIOLIB_DEBUG_PRINTLN(F("Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:")); _mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING); RADIOLIB_DEBUG_PRINTLN(); @@ -1988,7 +1986,7 @@ bool SX126x::findChip(uint8_t ver) { RADIOLIB_DEBUG_PRINTLN(F(" of 10 tries) RADIOLIB_SX126X_REG_VERSION_STRING:")); _mod->hexdump((uint8_t*)version, 16, RADIOLIB_SX126X_REG_VERSION_STRING); RADIOLIB_DEBUG_PRINT(F("Expected string: ")); - RADIOLIB_DEBUG_PRINTLN(versionBuff); + RADIOLIB_DEBUG_PRINTLN(verStr); #endif _mod->delay(10); i++; diff --git a/src/modules/SX126x/SX126x.h b/src/modules/SX126x/SX126x.h index 5953adc1..92b0f2c6 100644 --- a/src/modules/SX126x/SX126x.h +++ b/src/modules/SX126x/SX126x.h @@ -1184,13 +1184,13 @@ class SX126x: public PhysicalLayer { uint32_t _tcxoDelay = 0; size_t _implicitLen = 0; - uint8_t _chipType = 0; + const char* _chipType; // Allow subclasses to define different TX modes uint8_t _tx_mode = Module::MODE_TX; int16_t config(uint8_t modem); - bool findChip(uint8_t type); + bool findChip(const char* verStr); }; #endif