Added definition ZH_GATEWAY_KEEP_ALIVE_TIME

This commit is contained in:
Alexey Zholtikov 2024-07-17 07:59:08 +03:00
parent 61f253b473
commit c73ecd7ce6
3 changed files with 5 additions and 3 deletions

View File

@ -1298,7 +1298,7 @@ void zh_gateway_send_mqtt_json_config_message(const gateway_config_t *gateway_co
data.payload_data.config_message.binary_sensor_config_message.binary_sensor_device_class = HABSDC_CONNECTIVITY; data.payload_data.config_message.binary_sensor_config_message.binary_sensor_device_class = HABSDC_CONNECTIVITY;
data.payload_data.config_message.binary_sensor_config_message.payload_on = HAONOFT_CONNECT; data.payload_data.config_message.binary_sensor_config_message.payload_on = HAONOFT_CONNECT;
data.payload_data.config_message.binary_sensor_config_message.payload_off = HAONOFT_NONE; data.payload_data.config_message.binary_sensor_config_message.payload_off = HAONOFT_NONE;
data.payload_data.config_message.binary_sensor_config_message.expire_after = 30; data.payload_data.config_message.binary_sensor_config_message.expire_after = ZH_GATEWAY_KEEP_ALIVE_TIME * 1.25; // + 25% just in case.
data.payload_data.config_message.binary_sensor_config_message.enabled_by_default = true; data.payload_data.config_message.binary_sensor_config_message.enabled_by_default = true;
data.payload_data.config_message.binary_sensor_config_message.force_update = true; data.payload_data.config_message.binary_sensor_config_message.force_update = true;
data.payload_data.config_message.binary_sensor_config_message.qos = 2; data.payload_data.config_message.binary_sensor_config_message.qos = 2;
@ -1320,7 +1320,7 @@ void zh_gateway_send_mqtt_json_keep_alive_message_task(void *pvParameter)
zh_send_message(NULL, (uint8_t *)&data, sizeof(zh_espnow_data_t)); zh_send_message(NULL, (uint8_t *)&data, sizeof(zh_espnow_data_t));
data.payload_type = ZHPT_STATE; data.payload_type = ZHPT_STATE;
zh_espnow_binary_sensor_send_mqtt_json_status_message(&data, gateway_config->self_mac, gateway_config); zh_espnow_binary_sensor_send_mqtt_json_status_message(&data, gateway_config->self_mac, gateway_config);
vTaskDelay(10000 / portTICK_PERIOD_MS); vTaskDelay(ZH_GATEWAY_KEEP_ALIVE_TIME * 1000 / portTICK_PERIOD_MS);
} }
vTaskDelete(NULL); vTaskDelete(NULL);
} }

View File

@ -64,6 +64,8 @@
#define ZH_MAX_GPIO_NUMBERS 48 // Maximum number of GPIOs on ESP modules. #define ZH_MAX_GPIO_NUMBERS 48 // Maximum number of GPIOs on ESP modules.
#define ZH_GATEWAY_KEEP_ALIVE_TIME 10 // Frequency of sending a keep alive message.
typedef struct // Structure of data exchange between tasks, functions and event handlers. typedef struct // Structure of data exchange between tasks, functions and event handlers.
{ {
struct // Storage structure of gateway configuration data. struct // Storage structure of gateway configuration data.

View File

@ -1 +1 @@
1.0.8-1 1.0.8-2