[LR11x0] Fixed issues found by cppcheck
This commit is contained in:
parent
4d7c16bd44
commit
a643d0db7a
5 changed files with 32 additions and 29 deletions
|
@ -18,7 +18,7 @@ class LR1110: public LR11x0 {
|
|||
\brief Default constructor.
|
||||
\param mod Instance of Module that will be used to communicate with the radio.
|
||||
*/
|
||||
LR1110(Module* mod);
|
||||
LR1110(Module* mod); // cppcheck-suppress noExplicitConstructor
|
||||
|
||||
// basic methods
|
||||
|
||||
|
@ -74,7 +74,7 @@ class LR1110: public LR11x0 {
|
|||
\param freq Carrier frequency to be set in MHz.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequency(float freq);
|
||||
int16_t setFrequency(float freq) override;
|
||||
|
||||
/*!
|
||||
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz.
|
||||
|
|
|
@ -18,7 +18,7 @@ class LR1120: public LR11x0 {
|
|||
\brief Default constructor.
|
||||
\param mod Instance of Module that will be used to communicate with the radio.
|
||||
*/
|
||||
LR1120(Module* mod);
|
||||
LR1120(Module* mod); // cppcheck-suppress noExplicitConstructor
|
||||
|
||||
// basic methods
|
||||
|
||||
|
@ -74,7 +74,7 @@ class LR1120: public LR11x0 {
|
|||
\param freq Carrier frequency to be set in MHz.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequency(float freq);
|
||||
int16_t setFrequency(float freq) override;
|
||||
|
||||
/*!
|
||||
\brief Sets carrier frequency. Allowed values are in range from 150.0 to 960.0 MHz,
|
||||
|
|
|
@ -19,7 +19,7 @@ class LR1121: public LR1120 {
|
|||
\brief Default constructor.
|
||||
\param mod Instance of Module that will be used to communicate with the radio.
|
||||
*/
|
||||
LR1121(Module* mod);
|
||||
LR1121(Module* mod); // cppcheck-suppress noExplicitConstructor
|
||||
|
||||
// TODO this is where overrides to disable GNSS+WiFi scanning methods on LR1121
|
||||
// will be put once those are implemented
|
||||
|
|
|
@ -143,6 +143,7 @@ int16_t LR11x0::transmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// get currently active modem
|
||||
uint8_t modem = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
|
||||
state = getPacketType(&modem);
|
||||
RADIOLIB_ASSERT(state);
|
||||
RadioLibTime_t timeout = getTimeOnAir(len);
|
||||
if(modem == RADIOLIB_LR11X0_PACKET_TYPE_LORA) {
|
||||
// calculate timeout (150% of expected time-on-air)
|
||||
|
@ -189,6 +190,7 @@ int16_t LR11x0::receive(uint8_t* data, size_t len) {
|
|||
// get currently active modem
|
||||
uint8_t modem = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
|
||||
state = getPacketType(&modem);
|
||||
RADIOLIB_ASSERT(state);
|
||||
if(modem == RADIOLIB_LR11X0_PACKET_TYPE_LORA) {
|
||||
// calculate timeout (100 LoRa symbols, the default for SX127x series)
|
||||
float symbolLength = (float)(uint32_t(1) << this->spreadingFactor) / (float)this->bandwidthKhz;
|
||||
|
@ -396,6 +398,7 @@ int16_t LR11x0::startTransmit(uint8_t* data, size_t len, uint8_t addr) {
|
|||
// in LR-FHSS mode, the packet is built by the device
|
||||
// TODO add configurable grid step and device offset
|
||||
state = lrFhssBuildFrame(this->lrFhssHdrCount, this->lrFhssCr, RADIOLIB_LR11X0_LR_FHSS_GRID_STEP_FCC, true, this->lrFhssBw, this->lrFhssHopSeq, 0, data, len);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
} else {
|
||||
// write packet to buffer
|
||||
|
@ -1202,12 +1205,12 @@ float LR11x0::getRSSI() {
|
|||
|
||||
// check active modem
|
||||
uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
|
||||
getPacketType(&type);
|
||||
(void)getPacketType(&type);
|
||||
if(type == RADIOLIB_LR11X0_PACKET_TYPE_LORA) {
|
||||
getPacketStatusLoRa(&val, NULL, NULL);
|
||||
(void)getPacketStatusLoRa(&val, NULL, NULL);
|
||||
|
||||
} else if(type == RADIOLIB_LR11X0_PACKET_TYPE_GFSK) {
|
||||
getPacketStatusGFSK(NULL, &val, NULL, NULL);
|
||||
(void)getPacketStatusGFSK(NULL, &val, NULL, NULL);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1219,9 +1222,9 @@ float LR11x0::getSNR() {
|
|||
|
||||
// check active modem
|
||||
uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
|
||||
getPacketType(&type);
|
||||
(void)getPacketType(&type);
|
||||
if(type == RADIOLIB_LR11X0_PACKET_TYPE_LORA) {
|
||||
getPacketStatusLoRa(NULL, &val, NULL);
|
||||
(void)getPacketStatusLoRa(NULL, &val, NULL);
|
||||
}
|
||||
|
||||
return(val);
|
||||
|
@ -1254,7 +1257,7 @@ size_t LR11x0::getPacketLength(bool update, uint8_t* offset) {
|
|||
RadioLibTime_t LR11x0::getTimeOnAir(size_t len) {
|
||||
// check active modem
|
||||
uint8_t type = RADIOLIB_LR11X0_PACKET_TYPE_NONE;
|
||||
getPacketType(&type);
|
||||
(void)getPacketType(&type);
|
||||
if(type == RADIOLIB_LR11X0_PACKET_TYPE_LORA) {
|
||||
// calculate number of symbols
|
||||
float N_symbol = 0;
|
||||
|
@ -1468,7 +1471,7 @@ int16_t LR11x0::getWifiScanResult(LR11x0WifiResult_t* result, uint8_t index, boo
|
|||
|
||||
if(!brief) {
|
||||
if(this->wifiScanMode == RADIOLIB_LR11X0_WIFI_ACQ_MODE_FULL_BEACON) {
|
||||
LR11x0WifiResultExtended_t* resultExtended = (LR11x0WifiResultExtended_t*)result;
|
||||
LR11x0WifiResultExtended_t* resultExtended = reinterpret_cast<LR11x0WifiResultExtended_t*>(result);
|
||||
resultExtended->rate = raw[3];
|
||||
resultExtended->service = (((uint16_t)raw[4] << 8) | ((uint16_t)raw[5]));
|
||||
resultExtended->length = (((uint16_t)raw[6] << 8) | ((uint16_t)raw[7]));
|
||||
|
@ -1495,7 +1498,7 @@ int16_t LR11x0::getWifiScanResult(LR11x0WifiResult_t* result, uint8_t index, boo
|
|||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
|
||||
LR11x0WifiResultFull_t* resultFull = (LR11x0WifiResultFull_t*)result;
|
||||
LR11x0WifiResultFull_t* resultFull = reinterpret_cast<LR11x0WifiResultFull_t*>(result);
|
||||
resultFull->frameType = raw[3] & 0x03;
|
||||
resultFull->frameSubType = (raw[3] & 0x3C) >> 2;
|
||||
resultFull->toDistributionSystem = (raw[3] & 0x40) != 0;
|
||||
|
@ -1533,7 +1536,7 @@ int16_t LR11x0::wifiScan(uint8_t wifiType, uint8_t* count, uint8_t mode, uint16_
|
|||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||
}
|
||||
}
|
||||
RADIOLIB_DEBUG_BASIC_PRINTLN("WiFi scan done in %d ms", this->mod->hal->millis() - start);
|
||||
RADIOLIB_DEBUG_BASIC_PRINTLN("WiFi scan done in %lu ms", (long unsigned int)(this->mod->hal->millis() - start));
|
||||
|
||||
// read number of results
|
||||
return(getWifiScanResultsCount(count));
|
||||
|
@ -1658,7 +1661,7 @@ int16_t LR11x0::config(uint8_t modem) {
|
|||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// calibrate all blocks
|
||||
state = this->calibrate(RADIOLIB_LR11X0_CALIBRATE_ALL);
|
||||
(void)this->calibrate(RADIOLIB_LR11X0_CALIBRATE_ALL);
|
||||
|
||||
// wait for calibration completion
|
||||
this->mod->hal->delay(5);
|
||||
|
@ -1716,7 +1719,7 @@ int16_t LR11x0::startCad(uint8_t symbolNum, uint8_t detPeak, uint8_t detMin) {
|
|||
num = 2;
|
||||
}
|
||||
|
||||
uint8_t detPeakValues[8] = { 48, 48, 50, 55, 55, 59, 61, 65 };
|
||||
const uint8_t detPeakValues[8] = { 48, 48, 50, 55, 55, 59, 61, 65 };
|
||||
uint8_t peak = detPeak;
|
||||
if(peak == RADIOLIB_LR11X0_CAD_PARAM_DEFAULT) {
|
||||
peak = detPeakValues[this->spreadingFactor - 5];
|
||||
|
|
|
@ -656,7 +656,7 @@ class LR11x0: public PhysicalLayer {
|
|||
\brief Default constructor.
|
||||
\param mod Instance of Module that will be used to communicate with the radio.
|
||||
*/
|
||||
LR11x0(Module* mod);
|
||||
LR11x0(Module* mod); // cppcheck-suppress noExplicitConstructor
|
||||
|
||||
/*!
|
||||
\brief Whether the module has an XTAL (true) or TCXO (false). Defaults to false.
|
||||
|
@ -793,23 +793,23 @@ class LR11x0: public PhysicalLayer {
|
|||
\brief Sets interrupt service routine to call when a packet is received.
|
||||
\param func ISR to call.
|
||||
*/
|
||||
void setPacketReceivedAction(void (*func)(void));
|
||||
void setPacketReceivedAction(void (*func)(void)) override;
|
||||
|
||||
/*!
|
||||
\brief Clears interrupt service routine to call when a packet is received.
|
||||
*/
|
||||
void clearPacketReceivedAction();
|
||||
void clearPacketReceivedAction() override;
|
||||
|
||||
/*!
|
||||
\brief Sets interrupt service routine to call when a packet is sent.
|
||||
\param func ISR to call.
|
||||
*/
|
||||
void setPacketSentAction(void (*func)(void));
|
||||
void setPacketSentAction(void (*func)(void)) override;
|
||||
|
||||
/*!
|
||||
\brief Clears interrupt service routine to call when a packet is sent.
|
||||
*/
|
||||
void clearPacketSentAction();
|
||||
void clearPacketSentAction() override;
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven binary transmit method.
|
||||
|
@ -833,7 +833,7 @@ class LR11x0: public PhysicalLayer {
|
|||
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t startReceive();
|
||||
int16_t startReceive() override;
|
||||
|
||||
/*!
|
||||
\brief Interrupt-driven receive method. IRQ1 will be activated when full packet is received.
|
||||
|
@ -895,7 +895,7 @@ class LR11x0: public PhysicalLayer {
|
|||
\param power Output power to be set in dBm, output PA is determined automatically preferring the low-power PA.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setOutputPower(int8_t power);
|
||||
int16_t setOutputPower(int8_t power) override;
|
||||
|
||||
/*!
|
||||
\brief Sets output power. Allowed values are in range from -9 to 22 dBm (high-power PA) or -17 to 14 dBm (low-power PA).
|
||||
|
@ -961,7 +961,7 @@ class LR11x0: public PhysicalLayer {
|
|||
\param br FSK bit rate to be set in kbps.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setBitRate(float br);
|
||||
int16_t setBitRate(float br) override;
|
||||
|
||||
/*!
|
||||
\brief Sets GFSK frequency deviation. Allowed values range from 0.0 to 200.0 kHz.
|
||||
|
@ -1107,13 +1107,13 @@ class LR11x0: public PhysicalLayer {
|
|||
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. Only available for LoRa or GFSK modem.
|
||||
\returns RSSI of the last received packet in dBm.
|
||||
*/
|
||||
float getRSSI();
|
||||
float getRSSI() override;
|
||||
|
||||
/*!
|
||||
\brief Gets SNR (Signal to Noise Ratio) of the last received packet. Only available for LoRa modem.
|
||||
\returns SNR of the last received packet in dB.
|
||||
*/
|
||||
float getSNR();
|
||||
float getSNR() override;
|
||||
|
||||
/*!
|
||||
\brief Gets frequency error of the latest received packet.
|
||||
|
@ -1167,7 +1167,7 @@ class LR11x0: public PhysicalLayer {
|
|||
\brief Get one truly random byte from RSSI noise.
|
||||
\returns TRNG byte.
|
||||
*/
|
||||
uint8_t randomByte();
|
||||
uint8_t randomByte() override;
|
||||
|
||||
/*!
|
||||
\brief Set implicit header mode for future reception/transmission.
|
||||
|
@ -1264,7 +1264,7 @@ class LR11x0: public PhysicalLayer {
|
|||
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
||||
protected:
|
||||
#endif
|
||||
Module* getMod();
|
||||
Module* getMod() override;
|
||||
|
||||
// LR11x0 SPI command implementations
|
||||
int16_t writeRegMem32(uint32_t addr, uint32_t* data, size_t len);
|
||||
|
@ -1410,7 +1410,7 @@ class LR11x0: public PhysicalLayer {
|
|||
#if !RADIOLIB_GODMODE
|
||||
protected:
|
||||
#endif
|
||||
uint8_t chipType;
|
||||
uint8_t chipType = 0;
|
||||
|
||||
#if !RADIOLIB_GODMODE
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue