AqualinkD/source/config.h

165 lines
5.0 KiB
C
Raw Permalink Normal View History

2017-12-30 20:12:01 +00:00
#ifndef CONFIG_H_
#define CONFIG_H_
#include "utils.h"
#include "aq_serial.h"
#include "aqualink.h"
2020-06-01 00:35:17 +00:00
//#define DEFAULT_LOG_LEVEL 10
#define DEFAULT_LOG_LEVEL LOG_NOTICE
2017-12-30 20:12:01 +00:00
#define DEFAULT_WEBPORT "6580"
#define DEFAULT_WEBROOT "./"
#define DEFAULT_SERIALPORT "/dev/ttyUSB0"
#define DEFAULT_DEVICE_ID "0x0a"
2018-03-05 23:52:42 +00:00
#define DEFAULT_MQTT_DZ_IN NULL
#define DEFAULT_MQTT_DZ_OUT NULL
2024-05-22 23:57:33 +00:00
#define DEFAULT_HASS_DISCOVER NULL
2018-03-05 23:52:42 +00:00
#define DEFAULT_MQTT_AQ_TP NULL
#define DEFAULT_MQTT_SERVER NULL
2017-12-30 20:12:01 +00:00
#define DEFAULT_MQTT_USER NULL
#define DEFAULT_MQTT_PASSWD NULL
2024-08-25 23:31:58 +00:00
//#define DEFAULT_SWG_ZERO_IGNORE_COUNT 0
2017-12-30 20:12:01 +00:00
2019-05-18 00:48:20 +00:00
#define MQTT_ID_LEN 18 // 20 seems to kill mosquitto 1.6
2017-12-30 20:12:01 +00:00
2020-08-28 19:12:38 +00:00
// For aqconfig.read_RS485_devmask
#define READ_RS485_SWG (1 << 0) // 1 SWG
#define READ_RS485_JAN_PUMP (1 << 1) // 2 Jandy Pump
#define READ_RS485_PEN_PUMP (1 << 2) // 4 Pentair Pump
2024-05-22 23:57:33 +00:00
#define READ_RS485_JAN_JXI (1 << 3) // Jandy JX & LXi heater
#define READ_RS485_JAN_LX (1 << 4) // Jandy LX heater
#define READ_RS485_JAN_CHEM (1 << 5) // Jandy Chemical Feeder
2024-09-30 00:47:04 +00:00
#define READ_RS485_IAQUALNK (1 << 6) // Read iAqualink messages
2020-08-28 19:12:38 +00:00
2024-09-17 22:48:06 +00:00
#define MAX_RSSD_LOG_FILTERS 4
2017-12-30 20:12:01 +00:00
struct aqconfig
{
2018-09-23 21:54:15 +00:00
char *config_file;
2017-12-30 20:12:01 +00:00
char *serial_port;
unsigned int log_level;
char *socket_port;
char *web_directory;
unsigned char device_id;
2020-08-28 19:12:38 +00:00
unsigned char rssa_device_id;
2020-07-18 16:37:19 +00:00
int16_t paneltype_mask;
#if defined AQ_ONETOUCH || defined AQ_IAQTOUCH
unsigned char extended_device_id;
2024-09-13 22:44:48 +00:00
unsigned char extended_device_id2;
2020-06-01 00:35:17 +00:00
bool extended_device_id_programming;
2024-09-13 22:44:48 +00:00
bool enable_iaqualink;
2024-09-17 22:48:06 +00:00
//bool enable_RS_device_value_print;
2020-07-18 16:37:19 +00:00
#endif
2017-12-30 20:12:01 +00:00
bool deamonize;
2023-07-08 16:14:44 +00:00
#ifndef AQ_MANAGER // Need to uncomment and clean up referances in future.
2017-12-30 20:12:01 +00:00
char *log_file;
2023-07-08 16:14:44 +00:00
#endif
2017-12-30 20:12:01 +00:00
char *mqtt_dz_sub_topic;
char *mqtt_dz_pub_topic;
char *mqtt_aq_topic;
2024-05-22 23:57:33 +00:00
char *mqtt_hass_discover_topic;
2017-12-30 20:12:01 +00:00
char *mqtt_server;
char *mqtt_user;
char *mqtt_passwd;
2024-11-17 17:35:58 +00:00
bool mqtt_hass_discover_use_mac;
2024-04-15 22:32:08 +00:00
char mqtt_ID[MQTT_ID_LEN+1];
2017-12-30 20:12:01 +00:00
int dzidx_air_temp;
int dzidx_pool_water_temp;
int dzidx_spa_water_temp;
int dzidx_swg_percent;
int dzidx_swg_ppm;
int dzidx_swg_status;
2017-12-30 20:12:01 +00:00
float light_programming_mode;
2018-07-15 19:36:19 +00:00
int light_programming_initial_on;
int light_programming_initial_off;
2018-03-13 14:14:21 +00:00
bool override_freeze_protect;
2020-06-20 16:09:54 +00:00
#ifdef AQ_PDA
2019-05-25 16:52:36 +00:00
bool pda_sleep_mode;
2020-06-20 16:09:54 +00:00
#endif
2018-07-15 19:36:19 +00:00
bool convert_mqtt_temp;
bool convert_dz_temp;
bool report_zero_spa_temp;
2019-01-24 14:56:58 +00:00
bool report_zero_pool_temp;
2020-08-28 19:12:38 +00:00
//bool read_all_devices;
//bool read_pentair_packets;
uint8_t read_RS485_devmask;
2019-05-25 16:52:36 +00:00
bool use_panel_aux_labels;
bool force_swg;
2023-06-04 21:17:48 +00:00
bool force_ps_setpoints;
2023-07-08 16:14:44 +00:00
bool force_frzprotect_setpoints;
2024-05-22 23:57:33 +00:00
bool force_chem_feeder;
2024-08-25 23:31:58 +00:00
//int swg_zero_ignore; // This can be removed since this was due to VSP that's been fixed.
2019-08-18 20:54:10 +00:00
bool display_warnings_web;
2023-05-14 21:35:13 +00:00
bool log_protocol_packets; // Read & Write as packets
bool log_raw_bytes; // Read as bytes
2024-09-17 22:48:06 +00:00
unsigned char RSSD_LOG_filter[MAX_RSSD_LOG_FILTERS];
2023-05-14 21:35:13 +00:00
//bool log_raw_RS_bytes;
2024-04-19 19:06:00 +00:00
/*
2024-03-30 16:51:31 +00:00
#ifdef AQ_RS_EXTRA_OPTS
2020-07-18 16:37:19 +00:00
bool readahead_b4_write;
2024-03-30 16:51:31 +00:00
bool prioritize_ack;
#endif
2024-04-19 19:06:00 +00:00
*/
2020-07-18 16:37:19 +00:00
bool mqtt_timed_update;
bool sync_panel_time;
2023-05-14 21:35:13 +00:00
bool enable_scheduler;
2024-12-06 15:53:44 +00:00
int16_t schedule_event_mask;
//bool sched_chk_poweron;
//bool sched_chk_freezeprotectoff;
//bool sched_chk_boostoff;
2024-12-03 23:53:23 +00:00
int sched_chk_pumpon_hour;
int sched_chk_pumpoff_hour;
2023-06-04 21:17:48 +00:00
bool ftdi_low_latency;
2024-03-30 16:51:31 +00:00
int frame_delay;
2024-06-14 22:11:57 +00:00
bool device_pre_state;
2023-06-04 21:17:48 +00:00
#ifdef AQ_NO_THREAD_NETSERVICE
int rs_poll_speed; // Need to remove
bool thread_netservices; // Need to remove
#endif
2017-12-30 20:12:01 +00:00
};
2020-06-01 00:35:17 +00:00
#ifndef CONFIG_C
extern struct aqconfig _aqconfig_;
#else
struct aqconfig _aqconfig_;
#endif
2020-07-18 16:37:19 +00:00
2020-08-28 19:12:38 +00:00
#define READ_RSDEV_SWG ((_aqconfig_.read_RS485_devmask & READ_RS485_SWG) == READ_RS485_SWG)
#define READ_RSDEV_ePUMP ((_aqconfig_.read_RS485_devmask & READ_RS485_JAN_PUMP) == READ_RS485_JAN_PUMP)
#define READ_RSDEV_vsfPUMP ((_aqconfig_.read_RS485_devmask & READ_RS485_PEN_PUMP) == READ_RS485_PEN_PUMP)
2024-05-22 23:57:33 +00:00
#define READ_RSDEV_JXI ((_aqconfig_.read_RS485_devmask & READ_RS485_JAN_JXI) == READ_RS485_JAN_JXI)
#define READ_RSDEV_LX ((_aqconfig_.read_RS485_devmask & READ_RS485_JAN_LX) == READ_RS485_JAN_LX)
#define READ_RSDEV_CHEM ((_aqconfig_.read_RS485_devmask & READ_RS485_JAN_CHEM) == READ_RS485_JAN_CHEM)
2024-09-30 00:47:04 +00:00
#define READ_RSDEV_iAQLNK ((_aqconfig_.read_RS485_devmask & READ_RS485_IAQUALNK) == READ_RS485_IAQUALNK)
2020-08-28 19:12:38 +00:00
2024-05-22 23:57:33 +00:00
#define isPDA_IAQT (_aqconfig_.device_id == 0x33)
2020-07-18 16:37:19 +00:00
//#define isPDA ((_aqconfig_.paneltype_mask & RSP_PDA) == RSP_PDA)
2020-06-01 00:35:17 +00:00
/*
#ifndef CONFIG_C
#ifdef AQUALINKD_C
extern struct aqconfig _aqconfig_;
#else
extern const struct aqconfig _aqconfig_;
#endif
#endif
*/
2017-12-30 20:12:01 +00:00
void init_parameters (struct aqconfig * parms);
//bool parse_config (struct aqconfig * parms, char *cfgfile);
//void readCfg (struct aqconfig *config_parameters, char *cfgFile);
2020-06-01 00:35:17 +00:00
//void readCfg (struct aqconfig *config_parameters, struct aqualinkdata *aqualink_data, char *cfgFile);
void read_config(struct aqualinkdata *aqdata, char *cfgFile);
void init_config();
bool writeCfg (struct aqualinkdata *aqdata);
bool setConfigValue(struct aqualinkdata *aqdata, char *param, char *value);
2024-11-17 17:35:58 +00:00
bool mac(char *buf, int len, bool useDelimiter);
2019-05-25 16:52:36 +00:00
char *cleanalloc(char*str);
2017-12-30 20:12:01 +00:00
2019-01-18 03:38:25 +00:00
#endif