diff --git a/_weather_sensor_8h_source.html b/_weather_sensor_8h_source.html index 7ddea10..6a109c0 100644 --- a/_weather_sensor_8h_source.html +++ b/_weather_sensor_8h_source.html @@ -166,377 +166,379 @@
79 // 20240417 Added sensor configuration at run time
80 // 20240506 Changed sensor from array to std::vector, added getSensorCfg() / setSensorCfg()
81 // 20240507 Added configuration of enabled decoders at run time
-
82 //
-
83 // ToDo:
-
84 // -
-
85 //
-
87 
-
88 #ifndef WeatherSensor_h
-
89 #define WeatherSensor_h
-
90 
-
91 #include <Arduino.h>
-
92 #include <vector>
-
93 #include <string>
-
94 #include <Preferences.h>
-
95 #include <RadioLib.h>
-
96 
+
82 // 20240608 Modified implementation of maximum number of sensors
+
83 //
+
84 // ToDo:
+
85 // -
+
86 //
+
88 
+
89 #ifndef WeatherSensor_h
+
90 #define WeatherSensor_h
+
91 
+
92 #include <Arduino.h>
+
93 #include <vector>
+
94 #include <string>
+
95 #include <Preferences.h>
+
96 #include <RadioLib.h>
97 
-
98 // Sensor Types
-
99 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
-
100 // 1 - Weather Station 6-in-1; PN 7002585
-
101 // - Professional Wind Gauge 6-in-1; PN 7002531
-
102 // - Weather Station 7-in-1; PN 7003300
-
103 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
-
104 // 3 - Pool / Spa Thermometer 6-in-1; PN 7000073
-
105 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
-
106 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
-
107 // 8 - Air Quality Sensor PM2.5/PM10 7-in-1; P/N 7009970
-
108 // 9 - Professional Rain Gauge (5-in-1 decoder)
-
109 // 9 - Lightning Sensor PN 7009976
-
110 // 10 - CO2 Sensor 7-in-1; PN 7009977
-
111 // 11 - HCHO/VCO Sensor 7-in-1; PN 7009978
-
112 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
-
113 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
-
114 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-Sensor
-
115 #define SENSOR_TYPE_POOL_THERMO 3 // Pool / Spa Thermometer
-
116 #define SENSOR_TYPE_SOIL 4 // Soil Temperature and Moisture (from 6-in-1 decoder)
-
117 #define SENSOR_TYPE_LEAKAGE 5 // Water Leakage
-
118 #define SENSOR_TYPE_AIR_PM 8 // Air Quality Sensor (Particle Matter)
-
119 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
-
120 #define SENSOR_TYPE_LIGHTNING 9 // Lightning Sensor
-
121 #define SENSOR_TYPE_CO2 10 // CO2 Sensor
-
122 #define SENSOR_TYPE_HCHO_VOC 11 // Air Quality Sensor (HCHO and VOC)
-
123 
+
98 
+
99 // Sensor Types
+
100 // 0 - Weather Station 5-in-1; PN 7002510..12/7902510..12
+
101 // 1 - Weather Station 6-in-1; PN 7002585
+
102 // - Professional Wind Gauge 6-in-1; PN 7002531
+
103 // - Weather Station 7-in-1; PN 7003300
+
104 // 2 - Thermo-/Hygro-Sensor 6-in-1; PN 7009999
+
105 // 3 - Pool / Spa Thermometer 6-in-1; PN 7000073
+
106 // 4 - Soil Moisture Sensor 6-in-1; PN 7009972
+
107 // 5 - Water Leakage Sensor 6-in-1; PN 7009975
+
108 // 8 - Air Quality Sensor PM2.5/PM10 7-in-1; P/N 7009970
+
109 // 9 - Professional Rain Gauge (5-in-1 decoder)
+
110 // 9 - Lightning Sensor PN 7009976
+
111 // 10 - CO2 Sensor 7-in-1; PN 7009977
+
112 // 11 - HCHO/VCO Sensor 7-in-1; PN 7009978
+
113 #define SENSOR_TYPE_WEATHER0 0 // Weather Station
+
114 #define SENSOR_TYPE_WEATHER1 1 // Weather Station
+
115 #define SENSOR_TYPE_THERMO_HYGRO 2 // Thermo-/Hygro-Sensor
+
116 #define SENSOR_TYPE_POOL_THERMO 3 // Pool / Spa Thermometer
+
117 #define SENSOR_TYPE_SOIL 4 // Soil Temperature and Moisture (from 6-in-1 decoder)
+
118 #define SENSOR_TYPE_LEAKAGE 5 // Water Leakage
+
119 #define SENSOR_TYPE_AIR_PM 8 // Air Quality Sensor (Particle Matter)
+
120 #define SENSOR_TYPE_RAIN 9 // Professional Rain Gauge (from 5-in-1 decoder)
+
121 #define SENSOR_TYPE_LIGHTNING 9 // Lightning Sensor
+
122 #define SENSOR_TYPE_CO2 10 // CO2 Sensor
+
123 #define SENSOR_TYPE_HCHO_VOC 11 // Air Quality Sensor (HCHO and VOC)
124 
-
125 // Sensor specific rain gauge overflow threshold (mm)
-
126 #define WEATHER0_RAIN_OV 1000
-
127 #define WEATHER1_RAIN_OV 100000
-
128 
+
125 
+
126 // Sensor specific rain gauge overflow threshold (mm)
+
127 #define WEATHER0_RAIN_OV 1000
+
128 #define WEATHER1_RAIN_OV 100000
129 
-
130 // Flags for controlling completion of reception in getData()
-
131 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
-
132 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
-
133 #define DATA_ALL_SLOTS 0x8 // all slots completed
-
134 
-
135 // Flags for checking enabled decoders
-
136 #define DECODER_5IN1 0x01
-
137 #define DECODER_6IN1 0x02
-
138 #define DECODER_7IN1 0x04
-
139 #define DECODER_LIGHTNING 0x08
-
140 #define DECODER_LEAKAGE 0x10
-
141 
-
142 // Message buffer size
-
143 #define MSG_BUF_SIZE 27
-
144 
-
145 // Radio message decoding status
-
146 typedef enum DecodeStatus {
-
147  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
-
148 } DecodeStatus;
-
149 
+
130 
+
131 // Flags for controlling completion of reception in getData()
+
132 #define DATA_COMPLETE 0x1 // only completed slots (as opposed to partially filled)
+
133 #define DATA_TYPE 0x2 // at least one slot with specific sensor type
+
134 #define DATA_ALL_SLOTS 0x8 // all slots completed
+
135 
+
136 // Flags for checking enabled decoders
+
137 #define DECODER_5IN1 0x01
+
138 #define DECODER_6IN1 0x02
+
139 #define DECODER_7IN1 0x04
+
140 #define DECODER_LIGHTNING 0x08
+
141 #define DECODER_LEAKAGE 0x10
+
142 
+
143 // Message buffer size
+
144 #define MSG_BUF_SIZE 27
+
145 
+
146 // Radio message decoding status
+
147 typedef enum DecodeStatus {
+
148  DECODE_INVALID, DECODE_OK, DECODE_PAR_ERR, DECODE_CHK_ERR, DECODE_DIG_ERR, DECODE_SKIP, DECODE_FULL
+
149 } DecodeStatus;
150 
-
156 typedef struct SensorMap {
-
157  uint32_t id;
-
158  std::string name;
-
159 } SensorMap;
-
160 
+
151 
+
157 typedef struct SensorMap {
+
158  uint32_t id;
+
159  std::string name;
+
160 } SensorMap;
161 
162 
-
169 class WeatherSensor {
-
170  private:
-
171  Preferences cfgPrefs;
-
172  std::vector<uint32_t> sensor_ids_inc;
-
173  std::vector<uint32_t> sensor_ids_exc;
-
174 
-
175  public:
-
181  int16_t begin(void);
-
182 
-
186  void radioReset(void);
-
187 
-
191  void sleep(void);
-
192 
-
209  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
-
210 
-
211 
-
218  DecodeStatus getMessage(void);
-
219 
-
226  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
-
227 
-
228  struct Weather {
-
229  bool temp_ok = false;
-
230  bool humidity_ok = false;
-
231  bool light_ok = false;
-
232  bool uv_ok = false;
-
233  bool wind_ok = false;
-
234  bool rain_ok = false;
-
235  float temp_c = 0.0;
-
236  float light_klx = 0.0;
-
237  float light_lux = 0.0;
-
238  float uv = 0.0;
-
239  float rain_mm = 0.0;
-
240  #ifdef WIND_DATA_FLOATINGPOINT
-
241  float wind_direction_deg = 0.0;
-
242  float wind_gust_meter_sec = 0.0;
-
243  float wind_avg_meter_sec = 0.0;
-
244  #endif
-
245  #ifdef WIND_DATA_FIXEDPOINT
-
246  // For LoRa_Serialization:
-
247  // fixed point integer with 1 decimal -
-
248  // saves two bytes compared to "RawFloat"
-
249  uint16_t wind_direction_deg_fp1 = 0;
-
250  uint16_t wind_gust_meter_sec_fp1 = 0;
-
251  uint16_t wind_avg_meter_sec_fp1 = 0;
-
252  #endif
-
253  uint8_t humidity = 0;
-
254  };
-
255 
-
256  struct Soil {
-
257  float temp_c;
-
258  uint8_t moisture;
-
259  };
-
260 
-
261  struct Lightning {
-
262  uint8_t distance_km;
-
263  uint16_t strike_count;
-
264  uint16_t unknown1;
-
265  uint16_t unknown2;
-
266 
-
267  };
+
163 
+
170 class WeatherSensor {
+
171  private:
+
172  Preferences cfgPrefs;
+
173  std::vector<uint32_t> sensor_ids_inc;
+
174  std::vector<uint32_t> sensor_ids_exc;
+
175  uint8_t maxSensorsDefault;
+
176 
+
177  public:
+
183  int16_t begin(uint8_t max_sensors_default = MAX_SENSORS_DEFAULT);
+
184 
+
188  void radioReset(void);
+
189 
+
193  void sleep(void);
+
194 
+
211  bool getData(uint32_t timeout, uint8_t flags = 0, uint8_t type = 0, void (*func)() = NULL);
+
212 
+
213 
+
220  DecodeStatus getMessage(void);
+
221 
+
228  DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize);
+
229 
+
230  struct Weather {
+
231  bool temp_ok = false;
+
232  bool humidity_ok = false;
+
233  bool light_ok = false;
+
234  bool uv_ok = false;
+
235  bool wind_ok = false;
+
236  bool rain_ok = false;
+
237  float temp_c = 0.0;
+
238  float light_klx = 0.0;
+
239  float light_lux = 0.0;
+
240  float uv = 0.0;
+
241  float rain_mm = 0.0;
+
242  #ifdef WIND_DATA_FLOATINGPOINT
+
243  float wind_direction_deg = 0.0;
+
244  float wind_gust_meter_sec = 0.0;
+
245  float wind_avg_meter_sec = 0.0;
+
246  #endif
+
247  #ifdef WIND_DATA_FIXEDPOINT
+
248  // For LoRa_Serialization:
+
249  // fixed point integer with 1 decimal -
+
250  // saves two bytes compared to "RawFloat"
+
251  uint16_t wind_direction_deg_fp1 = 0;
+
252  uint16_t wind_gust_meter_sec_fp1 = 0;
+
253  uint16_t wind_avg_meter_sec_fp1 = 0;
+
254  #endif
+
255  uint8_t humidity = 0;
+
256  };
+
257 
+
258  struct Soil {
+
259  float temp_c;
+
260  uint8_t moisture;
+
261  };
+
262 
+
263  struct Lightning {
+
264  uint8_t distance_km;
+
265  uint16_t strike_count;
+
266  uint16_t unknown1;
+
267  uint16_t unknown2;
268 
-
269  struct Leakage {
-
270  bool alarm;
-
271  };
-
272 
-
273  struct AirPM {
-
274  uint16_t pm_1_0;
-
275  uint16_t pm_2_5;
-
276  uint16_t pm_10;
-
277  bool pm_1_0_init;
-
278  bool pm_2_5_init;
-
279  bool pm_10_init;
-
280  };
-
281 
-
282  struct AirCO2 {
-
283  uint16_t co2_ppm;
-
284  bool co2_init;
-
285  };
-
286 
-
287  struct AirVOC {
-
288  uint16_t hcho_ppb;
-
289  uint8_t voc_level;
-
290  bool hcho_init;
-
291  bool voc_init;
-
292  };
-
293 
-
299  struct Sensor {
-
300  uint32_t sensor_id;
-
301  float rssi;
-
302  uint8_t s_type;
-
303  uint8_t chan;
-
304  bool startup = false;
-
305  bool battery_ok;
-
306  bool valid;
-
307  bool complete;
-
308  union {
-
309  struct Weather w;
-
310  struct Soil soil;
-
311  struct Lightning lgt;
-
312  struct Leakage leak;
-
313  struct AirPM pm;
-
314  struct AirCO2 co2;
-
315  struct AirVOC voc;
-
316  };
-
317 
-
318  Sensor ()
-
319  {
-
320  #pragma GCC diagnostic push
-
321  #pragma GCC diagnostic ignored "-Wclass-memaccess"
-
322  memset(this, 0, sizeof(*this));
-
323  #pragma GCC diagnostic pop
-
324  };
-
325  };
-
326 
-
327  typedef struct Sensor sensor_t;
-
328  std::vector<sensor_t> sensor;
-
329  float rssi = 0.0;
-
330  uint8_t rxFlags;
-
331  uint8_t enDecoders = 0xFF;
-
332 
-
338  bool genMessage(int i, uint32_t id = 0xff, uint8_t s_type = 1, uint8_t channel = 0, uint8_t startup = 0);
-
339 
-
340 
-
349  void clearSlots(uint8_t type = 0xFF)
-
350  {
-
351  for (size_t i=0; i<sensor.size(); i++) {
-
352  if ((type == 0xFF) || (sensor[i].s_type == type)) {
-
353  sensor[i].valid = false;
-
354  sensor[i].complete = false;
-
355  }
-
356  if (sensor[i].s_type == SENSOR_TYPE_WEATHER1) {
-
357  sensor[i].w.temp_ok = false;
-
358  sensor[i].w.humidity_ok = false;
-
359  sensor[i].w.light_ok = false;
-
360  sensor[i].w.uv_ok = false;
-
361  sensor[i].w.wind_ok = false;
-
362  sensor[i].w.rain_ok = false;
-
363  }
-
364  }
-
365  };
-
366 
-
374  int findId(uint32_t id);
-
375 
-
376 
-
385  int findType(uint8_t type, uint8_t channel = 0xFF);
-
386 
-
393  void setSensorsInc(uint8_t *bytes, uint8_t size);
-
394 
-
401  void setSensorsExc(uint8_t *bytes, uint8_t size);
-
402 
-
410  void setSensorsCfg(uint8_t max_sensors, uint8_t rx_flags, uint8_t en_decoders = 0xFF);
-
411 
-
419  uint8_t getSensorsInc(uint8_t *payload);
-
420 
-
428  uint8_t getSensorsExc(uint8_t *payload);
-
429 
-
437  void getSensorsCfg(uint8_t &max_sensors, uint8_t &rx_flags, uint8_t &en_decoders);
-
438 
-
439  private:
-
440  struct Sensor *pData;
-
441 
-
451  void initList(std::vector<uint32_t> &list, const std::vector<uint32_t> list_def, const char *key);
-
452 
-
470  int findSlot(uint32_t id, DecodeStatus * status);
-
471 
-
472 
-
473  #ifdef BRESSER_5_IN_1
-
483  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
-
484  #endif
-
485  #ifdef BRESSER_6_IN_1
-
497  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
-
498  #endif
-
499  #ifdef BRESSER_7_IN_1
-
509  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
-
510  #endif
-
511  #ifdef BRESSER_LIGHTNING
-
521  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
-
522  #endif
-
523  #ifdef BRESSER_LEAKAGE
-
533  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
-
534  #endif
-
535 
-
536  protected:
-
540  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
-
541 
-
550  int add_bytes(uint8_t const message[], unsigned num_bytes);
-
551 
-
562  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
-
563 
-
564  #if CORE_DEBUG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
-
576  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
-
577  char buf[128];
-
578  const char txt[] = "Byte #: ";
-
579  int offs;
-
580  int len1 = strlen(txt);
-
581  int len2 = strlen(descr) + 2; // add colon and space
-
582  int prefix_len = max(len1, len2);
-
583 
-
584  memset(buf, ' ', prefix_len);
-
585  buf[prefix_len] = '\0';
-
586  offs = (len1 < len2) ? (len2 - len1) : 0;
-
587  strcpy(&buf[offs], txt);
-
588 
-
589  // Print byte index
-
590  for (size_t i = 0 ; i < msgSize; i++) {
-
591  sprintf(&buf[strlen(buf)], "%02d ", i);
-
592  }
-
593  log_d("%s", buf);
-
594 
-
595  memset(buf, ' ', prefix_len);
-
596  buf[prefix_len] ='\0';
-
597  offs = (len1 > len2) ? (len1 - len2) : 0;
-
598  sprintf(&buf[offs], "%s: ", descr);
-
599 
-
600  for (size_t i = 0 ; i < msgSize; i++) {
-
601  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
-
602  }
-
603  log_d("%s", buf);
-
604  }
-
605  #endif
-
606 
-
607 };
+
269  };
+
270 
+
271  struct Leakage {
+
272  bool alarm;
+
273  };
+
274 
+
275  struct AirPM {
+
276  uint16_t pm_1_0;
+
277  uint16_t pm_2_5;
+
278  uint16_t pm_10;
+
279  bool pm_1_0_init;
+
280  bool pm_2_5_init;
+
281  bool pm_10_init;
+
282  };
+
283 
+
284  struct AirCO2 {
+
285  uint16_t co2_ppm;
+
286  bool co2_init;
+
287  };
+
288 
+
289  struct AirVOC {
+
290  uint16_t hcho_ppb;
+
291  uint8_t voc_level;
+
292  bool hcho_init;
+
293  bool voc_init;
+
294  };
+
295 
+
301  struct Sensor {
+
302  uint32_t sensor_id;
+
303  float rssi;
+
304  uint8_t s_type;
+
305  uint8_t chan;
+
306  bool startup = false;
+
307  bool battery_ok;
+
308  bool valid;
+
309  bool complete;
+
310  union {
+
311  struct Weather w;
+
312  struct Soil soil;
+
313  struct Lightning lgt;
+
314  struct Leakage leak;
+
315  struct AirPM pm;
+
316  struct AirCO2 co2;
+
317  struct AirVOC voc;
+
318  };
+
319 
+
320  Sensor ()
+
321  {
+
322  #pragma GCC diagnostic push
+
323  #pragma GCC diagnostic ignored "-Wclass-memaccess"
+
324  memset(this, 0, sizeof(*this));
+
325  #pragma GCC diagnostic pop
+
326  };
+
327  };
+
328 
+
329  typedef struct Sensor sensor_t;
+
330  std::vector<sensor_t> sensor;
+
331  float rssi = 0.0;
+
332  uint8_t rxFlags;
+
333  uint8_t enDecoders = 0xFF;
+
334 
+
340  bool genMessage(int i, uint32_t id = 0xff, uint8_t s_type = 1, uint8_t channel = 0, uint8_t startup = 0);
+
341 
+
342 
+
351  void clearSlots(uint8_t type = 0xFF)
+
352  {
+
353  for (size_t i=0; i<sensor.size(); i++) {
+
354  if ((type == 0xFF) || (sensor[i].s_type == type)) {
+
355  sensor[i].valid = false;
+
356  sensor[i].complete = false;
+
357  }
+
358  if (sensor[i].s_type == SENSOR_TYPE_WEATHER1) {
+
359  sensor[i].w.temp_ok = false;
+
360  sensor[i].w.humidity_ok = false;
+
361  sensor[i].w.light_ok = false;
+
362  sensor[i].w.uv_ok = false;
+
363  sensor[i].w.wind_ok = false;
+
364  sensor[i].w.rain_ok = false;
+
365  }
+
366  }
+
367  };
+
368 
+
376  int findId(uint32_t id);
+
377 
+
378 
+
387  int findType(uint8_t type, uint8_t channel = 0xFF);
+
388 
+
395  void setSensorsInc(uint8_t *bytes, uint8_t size);
+
396 
+
403  void setSensorsExc(uint8_t *bytes, uint8_t size);
+
404 
+
412  void setSensorsCfg(uint8_t max_sensors, uint8_t rx_flags, uint8_t en_decoders = 0xFF);
+
413 
+
421  uint8_t getSensorsInc(uint8_t *payload);
+
422 
+
430  uint8_t getSensorsExc(uint8_t *payload);
+
431 
+
439  void getSensorsCfg(uint8_t &max_sensors, uint8_t &rx_flags, uint8_t &en_decoders);
+
440 
+
441  private:
+
442  struct Sensor *pData;
+
443 
+
453  void initList(std::vector<uint32_t> &list, const std::vector<uint32_t> list_def, const char *key);
+
454 
+
472  int findSlot(uint32_t id, DecodeStatus * status);
+
473 
+
474 
+
475  #ifdef BRESSER_5_IN_1
+
485  DecodeStatus decodeBresser5In1Payload(const uint8_t *msg, uint8_t msgSize);
+
486  #endif
+
487  #ifdef BRESSER_6_IN_1
+
499  DecodeStatus decodeBresser6In1Payload(const uint8_t *msg, uint8_t msgSize);
+
500  #endif
+
501  #ifdef BRESSER_7_IN_1
+
511  DecodeStatus decodeBresser7In1Payload(const uint8_t *msg, uint8_t msgSize);
+
512  #endif
+
513  #ifdef BRESSER_LIGHTNING
+
523  DecodeStatus decodeBresserLightningPayload(const uint8_t *msg, uint8_t msgSize);
+
524  #endif
+
525  #ifdef BRESSER_LEAKAGE
+
535  DecodeStatus decodeBresserLeakagePayload(const uint8_t *msg, uint8_t msgSize);
+
536  #endif
+
537 
+
538  protected:
+
542  uint16_t lfsr_digest16(uint8_t const message[], unsigned bytes, uint16_t gen, uint16_t key);
+
543 
+
552  int add_bytes(uint8_t const message[], unsigned num_bytes);
+
553 
+
564  uint16_t crc16(uint8_t const message[], unsigned nBytes, uint16_t polynomial, uint16_t init);
+
565 
+
566  #if CORE_DEBUG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
+
578  void log_message(const char *descr, const uint8_t *msg, uint8_t msgSize) {
+
579  char buf[128];
+
580  const char txt[] = "Byte #: ";
+
581  int offs;
+
582  int len1 = strlen(txt);
+
583  int len2 = strlen(descr) + 2; // add colon and space
+
584  int prefix_len = max(len1, len2);
+
585 
+
586  memset(buf, ' ', prefix_len);
+
587  buf[prefix_len] = '\0';
+
588  offs = (len1 < len2) ? (len2 - len1) : 0;
+
589  strcpy(&buf[offs], txt);
+
590 
+
591  // Print byte index
+
592  for (size_t i = 0 ; i < msgSize; i++) {
+
593  sprintf(&buf[strlen(buf)], "%02d ", i);
+
594  }
+
595  log_d("%s", buf);
+
596 
+
597  memset(buf, ' ', prefix_len);
+
598  buf[prefix_len] ='\0';
+
599  offs = (len1 > len2) ? (len1 - len2) : 0;
+
600  sprintf(&buf[offs], "%s: ", descr);
+
601 
+
602  for (size_t i = 0 ; i < msgSize; i++) {
+
603  sprintf(&buf[strlen(buf)], "%02X ", msg[i]);
+
604  }
+
605  log_d("%s", buf);
+
606  }
+
607  #endif
608 
-
609 #endif
-
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:169
-
WeatherSensor::getMessage
DecodeStatus getMessage(void)
Tries to receive radio message (non-blocking) and to decode it. Timeout occurs after a multitude of e...
Definition: WeatherSensor.cpp:317
-
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:427
-
WeatherSensor::radioReset
void radioReset(void)
Reset radio transceiver.
Definition: WeatherSensor.cpp:233
-
WeatherSensor::rxFlags
uint8_t rxFlags
receive flags (see getData())
Definition: WeatherSensor.h:330
-
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:329
-
WeatherSensor::getSensorsCfg
void getSensorsCfg(uint8_t &max_sensors, uint8_t &rx_flags, uint8_t &en_decoders)
Definition: WeatherSensorConfig.cpp:179
-
WeatherSensor::getData
bool getData(uint32_t timeout, uint8_t flags=0, uint8_t type=0, void(*func)()=NULL)
Wait for reception of data or occurrance of timeout. With BRESSER_6_IN_1, data is distributed across ...
Definition: WeatherSensor.cpp:243
-
WeatherSensor::setSensorsCfg
void setSensorsCfg(uint8_t max_sensors, uint8_t rx_flags, uint8_t en_decoders=0xFF)
Definition: WeatherSensorConfig.cpp:163
-
WeatherSensor::enDecoders
uint8_t enDecoders
enabled Decoders
Definition: WeatherSensor.h:331
-
WeatherSensor::sleep
void sleep(void)
Set transceiver into sleep mode.
Definition: WeatherSensor.cpp:238
-
WeatherSensor::begin
int16_t begin(void)
Presence check and initialization of radio module.
Definition: WeatherSensor.cpp:136
-
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:440
-
WeatherSensor::getSensorsInc
uint8_t getSensorsInc(uint8_t *payload)
Definition: WeatherSensorConfig.cpp:116
-
WeatherSensor::genMessage
bool genMessage(int i, uint32_t id=0xff, uint8_t s_type=1, uint8_t channel=0, uint8_t startup=0)
Generates data otherwise received and decoded from a radio message.
Definition: WeatherSensor.cpp:369
-
WeatherSensor::sensor_t
struct Sensor sensor_t
Shortcut for struct Sensor.
Definition: WeatherSensor.h:327
-
WeatherSensor::sensor
std::vector< sensor_t > sensor
sensor data array
Definition: WeatherSensor.h:328
-
WeatherSensor::setSensorsInc
void setSensorsInc(uint8_t *bytes, uint8_t size)
Definition: WeatherSensorConfig.cpp:93
-
WeatherSensor::getSensorsExc
uint8_t getSensorsExc(uint8_t *payload)
Definition: WeatherSensorConfig.cpp:151
-
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:349
+
609 };
+
610 
+
611 #endif
+
WeatherSensor
Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receivin...
Definition: WeatherSensor.h:170
+
WeatherSensor::getMessage
DecodeStatus getMessage(void)
Tries to receive radio message (non-blocking) and to decode it. Timeout occurs after a multitude of e...
Definition: WeatherSensor.cpp:319
+
WeatherSensor::findId
int findId(uint32_t id)
Definition: WeatherSensor.cpp:429
+
WeatherSensor::radioReset
void radioReset(void)
Reset radio transceiver.
Definition: WeatherSensor.cpp:235
+
WeatherSensor::rxFlags
uint8_t rxFlags
receive flags (see getData())
Definition: WeatherSensor.h:332
+
WeatherSensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:331
+
WeatherSensor::getSensorsCfg
void getSensorsCfg(uint8_t &max_sensors, uint8_t &rx_flags, uint8_t &en_decoders)
Definition: WeatherSensorConfig.cpp:180
+
WeatherSensor::getData
bool getData(uint32_t timeout, uint8_t flags=0, uint8_t type=0, void(*func)()=NULL)
Wait for reception of data or occurrance of timeout. With BRESSER_6_IN_1, data is distributed across ...
Definition: WeatherSensor.cpp:245
+
WeatherSensor::setSensorsCfg
void setSensorsCfg(uint8_t max_sensors, uint8_t rx_flags, uint8_t en_decoders=0xFF)
Definition: WeatherSensorConfig.cpp:164
+
WeatherSensor::enDecoders
uint8_t enDecoders
enabled Decoders
Definition: WeatherSensor.h:333
+
WeatherSensor::begin
int16_t begin(uint8_t max_sensors_default=MAX_SENSORS_DEFAULT)
Presence check and initialization of radio module.
Definition: WeatherSensor.cpp:137
+
WeatherSensor::sleep
void sleep(void)
Set transceiver into sleep mode.
Definition: WeatherSensor.cpp:240
+
WeatherSensor::findType
int findType(uint8_t type, uint8_t channel=0xFF)
Definition: WeatherSensor.cpp:442
+
WeatherSensor::getSensorsInc
uint8_t getSensorsInc(uint8_t *payload)
Definition: WeatherSensorConfig.cpp:117
+
WeatherSensor::genMessage
bool genMessage(int i, uint32_t id=0xff, uint8_t s_type=1, uint8_t channel=0, uint8_t startup=0)
Generates data otherwise received and decoded from a radio message.
Definition: WeatherSensor.cpp:371
+
WeatherSensor::sensor_t
struct Sensor sensor_t
Shortcut for struct Sensor.
Definition: WeatherSensor.h:329
+
WeatherSensor::sensor
std::vector< sensor_t > sensor
sensor data array
Definition: WeatherSensor.h:330
+
WeatherSensor::setSensorsInc
void setSensorsInc(uint8_t *bytes, uint8_t size)
Definition: WeatherSensorConfig.cpp:94
+
WeatherSensor::getSensorsExc
uint8_t getSensorsExc(uint8_t *payload)
Definition: WeatherSensorConfig.cpp:152
+
WeatherSensor::clearSlots
void clearSlots(uint8_t type=0xFF)
Clear sensor data.
Definition: WeatherSensor.h:351
WeatherSensor::decodeMessage
DecodeStatus decodeMessage(const uint8_t *msg, uint8_t msgSize)
Decode message Tries the available decoders until a decoding was successful.
Definition: WeatherSensorDecoders.cpp:143
-
WeatherSensor::setSensorsExc
void setSensorsExc(uint8_t *bytes, uint8_t size)
Definition: WeatherSensorConfig.cpp:128
-
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:156
-
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:158
-
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:157
-
WeatherSensor::AirCO2
Definition: WeatherSensor.h:282
-
WeatherSensor::AirCO2::co2_init
bool co2_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:284
-
WeatherSensor::AirCO2::co2_ppm
uint16_t co2_ppm
CO2 concentration in ppm.
Definition: WeatherSensor.h:283
-
WeatherSensor::AirPM
Definition: WeatherSensor.h:273
-
WeatherSensor::AirPM::pm_1_0
uint16_t pm_1_0
air quality PM1.0 in µg/m³
Definition: WeatherSensor.h:274
-
WeatherSensor::AirPM::pm_10_init
bool pm_10_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:279
-
WeatherSensor::AirPM::pm_2_5_init
bool pm_2_5_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:278
-
WeatherSensor::AirPM::pm_2_5
uint16_t pm_2_5
air quality PM2.5 in µg/m³
Definition: WeatherSensor.h:275
-
WeatherSensor::AirPM::pm_1_0_init
bool pm_1_0_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:277
-
WeatherSensor::AirPM::pm_10
uint16_t pm_10
air quality PM10 in µg/m³
Definition: WeatherSensor.h:276
-
WeatherSensor::AirVOC
Definition: WeatherSensor.h:287
-
WeatherSensor::AirVOC::hcho_init
bool hcho_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:290
-
WeatherSensor::AirVOC::voc_level
uint8_t voc_level
volatile organic oompounds; 1 - bad air quality .. 5 - very good air quality
Definition: WeatherSensor.h:289
-
WeatherSensor::AirVOC::voc_init
bool voc_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:291
-
WeatherSensor::AirVOC::hcho_ppb
uint16_t hcho_ppb
formaldehyde concentration in ppb
Definition: WeatherSensor.h:288
-
WeatherSensor::Leakage
Definition: WeatherSensor.h:269
-
WeatherSensor::Leakage::alarm
bool alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:270
-
WeatherSensor::Lightning
Definition: WeatherSensor.h:261
-
WeatherSensor::Lightning::unknown1
uint16_t unknown1
unknown part 1
Definition: WeatherSensor.h:264
-
WeatherSensor::Lightning::distance_km
uint8_t distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:262
-
WeatherSensor::Lightning::unknown2
uint16_t unknown2
unknown part 2
Definition: WeatherSensor.h:265
-
WeatherSensor::Lightning::strike_count
uint16_t strike_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:263
-
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:299
-
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:305
-
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:301
-
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:307
-
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type
Definition: WeatherSensor.h:302
-
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:304
-
WeatherSensor::Sensor::sensor_id
uint32_t sensor_id
sensor ID (5-in-1: 1 byte / 6-in-1: 4 bytes / 7-in-1: 2 bytes)
Definition: WeatherSensor.h:300
-
WeatherSensor::Sensor::chan
uint8_t chan
channel
Definition: WeatherSensor.h:303
-
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:306
-
WeatherSensor::Soil
Definition: WeatherSensor.h:256
-
WeatherSensor::Soil::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:257
-
WeatherSensor::Soil::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:258
-
WeatherSensor::Weather
Definition: WeatherSensor.h:228
-
WeatherSensor::Weather::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:236
-
WeatherSensor::Weather::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:231
-
WeatherSensor::Weather::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:237
-
WeatherSensor::Weather::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:229
-
WeatherSensor::Weather::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:235
-
WeatherSensor::Weather::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:253
-
WeatherSensor::Weather::uv
float uv
uv radiation (only 6-in-1 & 7-in-1)
Definition: WeatherSensor.h:238
-
WeatherSensor::Weather::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:230
-
WeatherSensor::Weather::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:233
-
WeatherSensor::Weather::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:232
-
WeatherSensor::Weather::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:239
-
WeatherSensor::Weather::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:234
+
WeatherSensor::setSensorsExc
void setSensorsExc(uint8_t *bytes, uint8_t size)
Definition: WeatherSensorConfig.cpp:129
+
SensorMap
Mapping of sensor IDs to names.
Definition: WeatherSensor.h:157
+
SensorMap::name
std::string name
Name of sensor (e.g. for MQTT topic)
Definition: WeatherSensor.h:159
+
SensorMap::id
uint32_t id
ID if sensor (as transmitted in radio message)
Definition: WeatherSensor.h:158
+
WeatherSensor::AirCO2
Definition: WeatherSensor.h:284
+
WeatherSensor::AirCO2::co2_init
bool co2_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:286
+
WeatherSensor::AirCO2::co2_ppm
uint16_t co2_ppm
CO2 concentration in ppm.
Definition: WeatherSensor.h:285
+
WeatherSensor::AirPM
Definition: WeatherSensor.h:275
+
WeatherSensor::AirPM::pm_1_0
uint16_t pm_1_0
air quality PM1.0 in µg/m³
Definition: WeatherSensor.h:276
+
WeatherSensor::AirPM::pm_10_init
bool pm_10_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:281
+
WeatherSensor::AirPM::pm_2_5_init
bool pm_2_5_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:280
+
WeatherSensor::AirPM::pm_2_5
uint16_t pm_2_5
air quality PM2.5 in µg/m³
Definition: WeatherSensor.h:277
+
WeatherSensor::AirPM::pm_1_0_init
bool pm_1_0_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:279
+
WeatherSensor::AirPM::pm_10
uint16_t pm_10
air quality PM10 in µg/m³
Definition: WeatherSensor.h:278
+
WeatherSensor::AirVOC
Definition: WeatherSensor.h:289
+
WeatherSensor::AirVOC::hcho_init
bool hcho_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:292
+
WeatherSensor::AirVOC::voc_level
uint8_t voc_level
volatile organic oompounds; 1 - bad air quality .. 5 - very good air quality
Definition: WeatherSensor.h:291
+
WeatherSensor::AirVOC::voc_init
bool voc_init
measurement value invalid due to initialization
Definition: WeatherSensor.h:293
+
WeatherSensor::AirVOC::hcho_ppb
uint16_t hcho_ppb
formaldehyde concentration in ppb
Definition: WeatherSensor.h:290
+
WeatherSensor::Leakage
Definition: WeatherSensor.h:271
+
WeatherSensor::Leakage::alarm
bool alarm
water leakage alarm (only water leakage)
Definition: WeatherSensor.h:272
+
WeatherSensor::Lightning
Definition: WeatherSensor.h:263
+
WeatherSensor::Lightning::unknown1
uint16_t unknown1
unknown part 1
Definition: WeatherSensor.h:266
+
WeatherSensor::Lightning::distance_km
uint8_t distance_km
lightning distance in km (only lightning)
Definition: WeatherSensor.h:264
+
WeatherSensor::Lightning::unknown2
uint16_t unknown2
unknown part 2
Definition: WeatherSensor.h:267
+
WeatherSensor::Lightning::strike_count
uint16_t strike_count
lightning strike counter (only lightning)
Definition: WeatherSensor.h:265
+
WeatherSensor::Sensor
sensor data and status flags
Definition: WeatherSensor.h:301
+
WeatherSensor::Sensor::battery_ok
bool battery_ok
battery o.k.
Definition: WeatherSensor.h:307
+
WeatherSensor::Sensor::rssi
float rssi
received signal strength indicator in dBm
Definition: WeatherSensor.h:303
+
WeatherSensor::Sensor::complete
bool complete
data is split into two separate messages is complete (only 6-in-1 WS)
Definition: WeatherSensor.h:309
+
WeatherSensor::Sensor::s_type
uint8_t s_type
sensor type
Definition: WeatherSensor.h:304
+
WeatherSensor::Sensor::startup
bool startup
startup after reset / battery change
Definition: WeatherSensor.h:306
+
WeatherSensor::Sensor::sensor_id
uint32_t sensor_id
sensor ID (5-in-1: 1 byte / 6-in-1: 4 bytes / 7-in-1: 2 bytes)
Definition: WeatherSensor.h:302
+
WeatherSensor::Sensor::chan
uint8_t chan
channel
Definition: WeatherSensor.h:305
+
WeatherSensor::Sensor::valid
bool valid
data valid (but not necessarily complete)
Definition: WeatherSensor.h:308
+
WeatherSensor::Soil
Definition: WeatherSensor.h:258
+
WeatherSensor::Soil::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:259
+
WeatherSensor::Soil::moisture
uint8_t moisture
moisture in % (only 6-in-1)
Definition: WeatherSensor.h:260
+
WeatherSensor::Weather
Definition: WeatherSensor.h:230
+
WeatherSensor::Weather::light_klx
float light_klx
Light KLux (only 7-in-1)
Definition: WeatherSensor.h:238
+
WeatherSensor::Weather::light_ok
bool light_ok
light o.k. (only 7-in-1)
Definition: WeatherSensor.h:233
+
WeatherSensor::Weather::light_lux
float light_lux
Light lux (only 7-in-1)
Definition: WeatherSensor.h:239
+
WeatherSensor::Weather::temp_ok
bool temp_ok
temperature o.k. (only 6-in-1)
Definition: WeatherSensor.h:231
+
WeatherSensor::Weather::temp_c
float temp_c
temperature in degC
Definition: WeatherSensor.h:237
+
WeatherSensor::Weather::humidity
uint8_t humidity
humidity in %
Definition: WeatherSensor.h:255
+
WeatherSensor::Weather::uv
float uv
uv radiation (only 6-in-1 & 7-in-1)
Definition: WeatherSensor.h:240
+
WeatherSensor::Weather::humidity_ok
bool humidity_ok
humidity o.k.
Definition: WeatherSensor.h:232
+
WeatherSensor::Weather::wind_ok
bool wind_ok
wind speed/direction o.k. (only 6-in-1)
Definition: WeatherSensor.h:235
+
WeatherSensor::Weather::uv_ok
bool uv_ok
uv radiation o.k. (only 6-in-1)
Definition: WeatherSensor.h:234
+
WeatherSensor::Weather::rain_mm
float rain_mm
rain gauge level in mm
Definition: WeatherSensor.h:241
+
WeatherSensor::Weather::rain_ok
bool rain_ok
rain gauge level o.k.
Definition: WeatherSensor.h:236
diff --git a/class_weather_sensor-members.html b/class_weather_sensor-members.html index cf8f7d5..c2d2b0c 100644 --- a/class_weather_sensor-members.html +++ b/class_weather_sensor-members.html @@ -89,7 +89,7 @@

This is the complete list of members for WeatherSensor, including all inherited members.

- + diff --git a/class_weather_sensor.html b/class_weather_sensor.html index 5cf6040..0e07752 100644 --- a/class_weather_sensor.html +++ b/class_weather_sensor.html @@ -127,9 +127,9 @@
begin(void)WeatherSensor
begin(uint8_t max_sensors_default=MAX_SENSORS_DEFAULT)WeatherSensor
clearSlots(uint8_t type=0xFF)WeatherSensorinline
decodeMessage(const uint8_t *msg, uint8_t msgSize)WeatherSensor
enDecodersWeatherSensor
- - - + + + @@ -193,8 +193,8 @@

Detailed Description

Receive, decode and store Bresser Weather Sensor Data Uses CC1101 or SX1276 radio module for receiving FSK modulated signal at 868 MHz.

Member Function Documentation

- -

◆ begin()

+ +

◆ begin()

@@ -202,8 +202,8 @@

int16_t WeatherSensor::begin

- - + +

Public Member Functions

int16_t begin (void)
 Presence check and initialization of radio module. More...
 
int16_t begin (uint8_t max_sensors_default=MAX_SENSORS_DEFAULT)
 Presence check and initialization of radio module. More...
 
void radioReset (void)
 Reset radio transceiver.
(void )uint8_t max_sensors_default = MAX_SENSORS_DEFAULT)
diff --git a/class_weather_sensor.js b/class_weather_sensor.js index 433afbb..083c9cd 100644 --- a/class_weather_sensor.js +++ b/class_weather_sensor.js @@ -9,7 +9,7 @@ var class_weather_sensor = [ "Soil", "struct_weather_sensor_1_1_soil.html", "struct_weather_sensor_1_1_soil" ], [ "Weather", "struct_weather_sensor_1_1_weather.html", "struct_weather_sensor_1_1_weather" ], [ "sensor_t", "class_weather_sensor.html#ae38bcb7791c9c49d5f23c150d4517dc4", null ], - [ "begin", "class_weather_sensor.html#a9b84d8518edf33a2f796288bb482eb8b", null ], + [ "begin", "class_weather_sensor.html#a69fb340800d9fef5cb81921760a15a45", null ], [ "clearSlots", "class_weather_sensor.html#af7d1085b72f2f41e8b349e63d2628b0c", null ], [ "decodeMessage", "class_weather_sensor.html#af964b214e398132f25d4e783dffe708a", null ], [ "findId", "class_weather_sensor.html#a0adf85658be20d05e43e34c6b728b989", null ], diff --git a/functions.html b/functions.html index 26e2b69..fc9583c 100644 --- a/functions.html +++ b/functions.html @@ -99,7 +99,7 @@

- b -

diff --git a/functions_func.html b/functions_func.html index d39cdbe..ef5b9ec 100644 --- a/functions_func.html +++ b/functions_func.html @@ -84,7 +84,7 @@