[SX126x] Fixes from cppcheck scan

This commit is contained in:
jgromes 2020-07-04 14:32:29 +02:00
parent 638bcfd32b
commit fed86b0742
4 changed files with 24 additions and 28 deletions

View file

@ -44,8 +44,6 @@ int16_t SX1262::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
int16_t SX1262::setFrequency(float freq, bool calibrate) { int16_t SX1262::setFrequency(float freq, bool calibrate) {
RADIOLIB_CHECK_RANGE(freq, 150.0, 960.0, ERR_INVALID_FREQUENCY); RADIOLIB_CHECK_RANGE(freq, 150.0, 960.0, ERR_INVALID_FREQUENCY);
int16_t state = ERR_NONE;
// calibrate image // calibrate image
if(calibrate) { if(calibrate) {
uint8_t data[2]; uint8_t data[2];
@ -65,7 +63,7 @@ int16_t SX1262::setFrequency(float freq, bool calibrate) {
data[0] = SX126X_CAL_IMG_430_MHZ_1; data[0] = SX126X_CAL_IMG_430_MHZ_1;
data[1] = SX126X_CAL_IMG_430_MHZ_2; data[1] = SX126X_CAL_IMG_430_MHZ_2;
} }
state = SX126x::calibrateImage(data); int16_t state = SX126x::calibrateImage(data);
RADIOLIB_ASSERT(state); RADIOLIB_ASSERT(state);
} }

View file

@ -44,8 +44,6 @@ int16_t SX1268::beginFSK(float freq, float br, float freqDev, float rxBw, int8_t
int16_t SX1268::setFrequency(float freq, bool calibrate) { int16_t SX1268::setFrequency(float freq, bool calibrate) {
RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, ERR_INVALID_FREQUENCY); RADIOLIB_CHECK_RANGE(freq, 410.0, 810.0, ERR_INVALID_FREQUENCY);
int16_t state = ERR_NONE;
// calibrate image // calibrate image
if(calibrate) { if(calibrate) {
uint8_t data[2]; uint8_t data[2];
@ -59,7 +57,7 @@ int16_t SX1268::setFrequency(float freq, bool calibrate) {
data[0] = SX126X_CAL_IMG_430_MHZ_1; data[0] = SX126X_CAL_IMG_430_MHZ_1;
data[1] = SX126X_CAL_IMG_430_MHZ_2; data[1] = SX126X_CAL_IMG_430_MHZ_2;
} }
state = SX126x::calibrateImage(data); int16_t state = SX126x::calibrateImage(data);
RADIOLIB_ASSERT(state); RADIOLIB_ASSERT(state);
} }

View file

@ -1042,7 +1042,7 @@ int16_t SX126x::setWhitening(bool enabled, uint16_t initial) {
return(state); return(state);
} }
float SX126x::getDataRate() { float SX126x::getDataRate() const {
return(_dataRate); return(_dataRate);
} }

View file

@ -421,7 +421,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0); int16_t transmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
/*! /*!
\brief Blocking binary receive method. \brief Blocking binary receive method.
@ -433,7 +433,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t receive(uint8_t* data, size_t len); int16_t receive(uint8_t* data, size_t len) override;
/*! /*!
\brief Starts direct mode transmission. \brief Starts direct mode transmission.
@ -450,7 +450,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t receiveDirect(); int16_t receiveDirect() override;
/*! /*!
\brief Performs scan for LoRa transmission in the current channel. Detects both preamble and payload. \brief Performs scan for LoRa transmission in the current channel. Detects both preamble and payload.
@ -473,7 +473,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t standby(); int16_t standby() override;
/*! /*!
\brief Sets the module to standby mode. \brief Sets the module to standby mode.
@ -510,7 +510,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0); int16_t startTransmit(uint8_t* data, size_t len, uint8_t addr = 0) override;
/*! /*!
\brief Interrupt-driven receive method. DIO1 will be activated when full packet is received. \brief Interrupt-driven receive method. DIO1 will be activated when full packet is received.
@ -555,7 +555,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t readData(uint8_t* data, size_t len); int16_t readData(uint8_t* data, size_t len) override;
// configuration methods // configuration methods
@ -629,7 +629,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t setFrequencyDeviation(float freqDev); int16_t setFrequencyDeviation(float freqDev) override;
/*! /*!
\brief Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps. \brief Sets FSK bit rate. Allowed values range from 0.6 to 300.0 kbps.
@ -656,7 +656,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t setDataShaping(float sh); int16_t setDataShaping(float sh) override;
/*! /*!
\brief Sets FSK sync word in the form of array of up to 8 bytes. \brief Sets FSK sync word in the form of array of up to 8 bytes.
@ -752,7 +752,7 @@ class SX126x: public PhysicalLayer {
\returns Effective data rate in bps. \returns Effective data rate in bps.
*/ */
float getDataRate(); float getDataRate() const;
/*! /*!
\brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet. \brief Gets RSSI (Recorded Signal Strength Indicator) of the last received packet.
@ -775,7 +775,7 @@ class SX126x: public PhysicalLayer {
\returns Length of last received packet in bytes. \returns Length of last received packet in bytes.
*/ */
size_t getPacketLength(bool update = true); size_t getPacketLength(bool update = true) override;
/*! /*!
\brief Set modem in fixed packet length mode. Available in FSK mode only. \brief Set modem in fixed packet length mode. Available in FSK mode only.
@ -841,7 +841,7 @@ class SX126x: public PhysicalLayer {
\returns \ref status_codes \returns \ref status_codes
*/ */
int16_t setEncoding(uint8_t encoding); int16_t setEncoding(uint8_t encoding) override;
/*! /*!
\brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state. \brief Some modules contain external RF switch controlled by two pins. This function gives RadioLib control over those two pins to automatically switch Rx and Tx state.
@ -899,20 +899,20 @@ class SX126x: public PhysicalLayer {
#endif #endif
Module* _mod; Module* _mod;
uint8_t _bw, _sf, _cr, _ldro, _crcType, _headerType; uint8_t _bw = 0, _sf = 0, _cr = 0, _ldro = 0, _crcType = 0, _headerType = 0;
uint16_t _preambleLength; uint16_t _preambleLength = 0;
float _bwKhz; float _bwKhz = 0;
uint32_t _br, _freqDev; uint32_t _br = 0, _freqDev = 0;
uint8_t _rxBw, _pulseShape, _crcTypeFSK, _syncWordLength, _addrComp, _whitening, _packetType; uint8_t _rxBw = 0, _pulseShape = 0, _crcTypeFSK = 0, _syncWordLength = 0, _addrComp = 0, _whitening = 0, _packetType = 0;
uint16_t _preambleLengthFSK; uint16_t _preambleLengthFSK = 0;
float _rxBwKhz; float _rxBwKhz = 0;
float _dataRate; float _dataRate = 0;
uint32_t _tcxoDelay; uint32_t _tcxoDelay = 0;
size_t _implicitLen; size_t _implicitLen = 0;
int16_t config(uint8_t modem); int16_t config(uint8_t modem);