add dead sensors' reinit, gathering all fresh data, fixed some little bugs

This commit is contained in:
2026-05-06 17:13:00 +03:00
parent c5b9d43797
commit 63f87d2283
17 changed files with 207 additions and 174 deletions

View File

@@ -97,10 +97,12 @@ typedef struct{
// all sensor's data
// all functions have `this` as first arg
typedef struct sensordata_t{
char name[NAME_LEN+1]; // max 31 symbol of sensor's name (e.g. "rain sensor")
char name[NAME_LEN+1]; // sensor's name (e.g. "rain sensor @ localhost")
char path[PATH_MAX]; // path to sensor's device or socket description in format D:/path, U:path, N:host:port
int Nvalues; // amount of values
int PluginNo; // plugin number in array (if several)
int IsMuted; // ==1 for "muted" station (don't refresh sensors' data)
int (*init)(struct sensordata_t*); // main init function
int (*onrefresh)(struct sensordata_t*, void (*handler)(struct sensordata_t*)); // handler of new data; return TRUE if OK
int (*get_value)(struct sensordata_t*, val_t*, int); // getter of Nth value
void (*kill)(struct sensordata_t*); // close everything and remove sensor
@@ -118,14 +120,14 @@ typedef struct sensordata_t{
} sensordata_t;
// type for function extraction
typedef sensordata_t* (*sensor_new_t)(int, time_t, const char*);
typedef int (*sensor_init_t)(sensordata_t *);
// init meteostation with given PluginNo, poll_interval and descriptor
sensordata_t *sensor_new(int PluginNo, time_t poll_interval, const char *descr); // external initial function for any plugin
//sensordata_t *sensor_init(int PluginNo, time_t poll_interval, const char *descr); // external initial function for any plugin
int sensor_alive(sensordata_t *s);
sensordata_t *sensor_new(int N, const char *descr);
// private function (for plugins usage only)
sensordata_t *common_new();
void common_kill(sensordata_t *s);
int common_onrefresh(sensordata_t *s, void (*handler)(sensordata_t *));
int common_getval(struct sensordata_t *s, val_t *o, int N);