From 045b356c2ce083642c065498179253ce1cdac984 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Sat, 8 Jun 2024 08:54:03 +0200 Subject: [PATCH] Modified implementation of maximum number of sensors (#175) --- library.properties | 2 +- package.json | 2 +- src/WeatherSensor.cpp | 4 +++- src/WeatherSensor.h | 4 +++- src/WeatherSensorConfig.cpp | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/library.properties b/library.properties index 0644897..1c64418 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=BresserWeatherSensorReceiver -version=0.28.5 +version=0.28.6 author=Matthias Prinke maintainer=Matthias Prinke sentence=Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on CC1101, SX1276/RFM95W or SX1262. diff --git a/package.json b/package.json index 6aefd5a..9040e85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "BresserWeatherSensorReceiver", - "version": "0.28.5", + "version": "0.28.6", "description": "Bresser 5-in-1/6-in-1/7-in-1 868 MHz Weather Sensor Radio Receiver for Arduino based on CC1101, SX1276/RFM95W or SX1262", "main": "WeatherSensor.cpp", "frameworks": "arduino", diff --git a/src/WeatherSensor.cpp b/src/WeatherSensor.cpp index b51d733..70e9949 100644 --- a/src/WeatherSensor.cpp +++ b/src/WeatherSensor.cpp @@ -99,6 +99,7 @@ // - Sensor data decoding functions (WeatherSensorDecoders.cpp) // - Run-time configuration functions (WeatherSensorConfig.cpp) // 20240528 Fixed channel comparison in findType() +// 20240608 Modified implementation of maximum number of sensors // // ToDo: // - @@ -133,8 +134,9 @@ void receivedFlag = true; } -int16_t WeatherSensor::begin(void) +int16_t WeatherSensor::begin(uint8_t max_sensors_default) { + uint8_t maxSensorsDefault = max_sensors_default; uint8_t maxSensors; getSensorsCfg(maxSensors, rxFlags, enDecoders); log_d("max_sensors: %u", maxSensors); diff --git a/src/WeatherSensor.h b/src/WeatherSensor.h index 0994cde..1e7ae82 100644 --- a/src/WeatherSensor.h +++ b/src/WeatherSensor.h @@ -79,6 +79,7 @@ // 20240417 Added sensor configuration at run time // 20240506 Changed sensor from array to std::vector, added getSensorCfg() / setSensorCfg() // 20240507 Added configuration of enabled decoders at run time +// 20240608 Modified implementation of maximum number of sensors // // ToDo: // - @@ -171,6 +172,7 @@ class WeatherSensor { Preferences cfgPrefs; //!< Preferences (stored in flash memory) std::vector sensor_ids_inc; std::vector sensor_ids_exc; + uint8_t maxSensorsDefault; public: /*! @@ -178,7 +180,7 @@ class WeatherSensor { \returns RADIOLIB_ERR_NONE on success (otherwise does never return). */ - int16_t begin(void); + int16_t begin(uint8_t max_sensors_default = MAX_SENSORS_DEFAULT); /*! \brief Reset radio transceiver diff --git a/src/WeatherSensorConfig.cpp b/src/WeatherSensorConfig.cpp index b289805..5c00d55 100644 --- a/src/WeatherSensorConfig.cpp +++ b/src/WeatherSensorConfig.cpp @@ -37,6 +37,7 @@ // History: // // 20240513 Created from WeatherSensor.cpp +// 20240608 Modified implementation of maximum number of sensors // // // ToDo: @@ -179,7 +180,7 @@ void WeatherSensor::setSensorsCfg(uint8_t max_sensors, uint8_t rx_flags, uint8_t void WeatherSensor::getSensorsCfg(uint8_t &max_sensors, uint8_t &rx_flags, uint8_t &en_decoders) { cfgPrefs.begin("BWS-CFG", false); - max_sensors = cfgPrefs.getUChar("maxsensors", MAX_SENSORS_DEFAULT); + max_sensors = cfgPrefs.getUChar("maxsensors", maxSensorsDefault); rx_flags = cfgPrefs.getUChar("rxflags", DATA_COMPLETE); en_decoders = cfgPrefs.getUChar("endec", 0xFF); cfgPrefs.end();