Skip to content

Commit

Permalink
Modified implementation of maximum number of sensors (#175)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthias-bs committed Jun 8, 2024
1 parent 3201073 commit 045b356
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=BresserWeatherSensorReceiver
version=0.28.5
version=0.28.6
author=Matthias Prinke <matthias-bs@web.de>
maintainer=Matthias Prinke <matthias-bs@web.de>
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.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/WeatherSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// -
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/WeatherSensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
// -
Expand Down Expand Up @@ -171,14 +172,15 @@ class WeatherSensor {
Preferences cfgPrefs; //!< Preferences (stored in flash memory)
std::vector<uint32_t> sensor_ids_inc;
std::vector<uint32_t> sensor_ids_exc;
uint8_t maxSensorsDefault;

public:
/*!
\brief Presence check and initialization of radio module.
\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
Expand Down
3 changes: 2 additions & 1 deletion src/WeatherSensorConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
// History:
//
// 20240513 Created from WeatherSensor.cpp
// 20240608 Modified implementation of maximum number of sensors
//
//
// ToDo:
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 045b356

Please sign in to comment.