From b77cc0b529d6ea0a9e9b1f11abb6a90d369b8097 Mon Sep 17 00:00:00 2001 From: Matthias Prinke <83612361+matthias-bs@users.noreply.github.com> Date: Sun, 9 Jun 2024 10:32:09 +0200 Subject: [PATCH] Fixed exception caused by max_num_sensors = 0 (#62) --- src/PayloadBresser.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/PayloadBresser.cpp b/src/PayloadBresser.cpp index 8a0fec7..bb61571 100644 --- a/src/PayloadBresser.cpp +++ b/src/PayloadBresser.cpp @@ -43,6 +43,7 @@ // 20240601 Added mapping of invalid RainGauge values to INV_FLOAT // 20240603 Added encoding of sensor battery status // 20240608 Modified default number of sensors +// 20240609 Fixed exception caused by max_num_sensors = 0 // // ToDo: // - Add handling of Professional Rain Gauge @@ -54,6 +55,9 @@ void PayloadBresser::begin(void) { weatherSensor.begin(MAX_NUM_868MHZ_SENSORS); + if (weatherSensor.sensor.size() == 0) + return; + weatherSensor.clearSlots(); appPrefs.begin("BWS-LW-APP", false); uint8_t ws_timeout = appPrefs.getUChar("ws_timeout", WEATHERSENSOR_TIMEOUT); @@ -68,6 +72,9 @@ void PayloadBresser::begin(void) void PayloadBresser::encodeBresser(uint8_t *appPayloadCfg, uint8_t *appStatus, LoraEncoder &encoder) { + if (weatherSensor.sensor.size() == 0) + return; + // Handle weather sensors - which only have one channel (0) - first. // Configuration for SENSOR_TYPE_WEATHER0 is integrated into SENSOR_TYPE_WEATHER1. uint8_t flags = appPayloadCfg[1];