Version 2.2.0
Changed the frequency of sending messages. Changed the event for the first start of tasks.
This commit is contained in:
parent
3ffdfae7b3
commit
56c6a76309
@ -18,11 +18,6 @@ void app_main(void)
|
|||||||
esp_wifi_start();
|
esp_wifi_start();
|
||||||
zh_espnow_init_config_t espnow_init_config = ZH_ESPNOW_INIT_CONFIG_DEFAULT();
|
zh_espnow_init_config_t espnow_init_config = ZH_ESPNOW_INIT_CONFIG_DEFAULT();
|
||||||
zh_espnow_init(&espnow_init_config);
|
zh_espnow_init(&espnow_init_config);
|
||||||
xTaskCreatePinnedToCore(&zh_send_switch_attributes_message_task, "switch_attributes_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
|
||||||
xTaskCreatePinnedToCore(&zh_send_switch_keep_alive_message_task, "switch_keep_alive_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
|
||||||
xTaskCreatePinnedToCore(&zh_send_switch_config_message_task, "switch_config_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
|
||||||
xTaskCreatePinnedToCore(&zh_send_switch_hardware_config_message_task, "switch_hardware_config_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
|
||||||
xTaskCreatePinnedToCore(&zh_send_switch_status_message_task, "switch_status_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||||
esp_event_handler_register(ZH_ESPNOW, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, switch_config);
|
esp_event_handler_register(ZH_ESPNOW, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, switch_config);
|
||||||
#else
|
#else
|
||||||
@ -397,6 +392,15 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
|||||||
{
|
{
|
||||||
case ZHPT_KEEP_ALIVE:
|
case ZHPT_KEEP_ALIVE:
|
||||||
memcpy(switch_config->gateway_mac, recv_data->mac_addr, 6);
|
memcpy(switch_config->gateway_mac, recv_data->mac_addr, 6);
|
||||||
|
if (is_first_boot == false)
|
||||||
|
{
|
||||||
|
is_first_boot = true;
|
||||||
|
xTaskCreatePinnedToCore(&zh_send_switch_attributes_message_task, "switch_attributes_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||||
|
xTaskCreatePinnedToCore(&zh_send_switch_keep_alive_message_task, "switch_keep_alive_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||||
|
xTaskCreatePinnedToCore(&zh_send_switch_config_message_task, "switch_config_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||||
|
xTaskCreatePinnedToCore(&zh_send_switch_hardware_config_message_task, "switch_hardware_config_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||||
|
xTaskCreatePinnedToCore(&zh_send_switch_status_message_task, "switch_status_message_task", ZH_MESSAGE_STACK_SIZE, switch_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ZHPT_SET:
|
case ZHPT_SET:
|
||||||
switch_config->status.status = data->payload_data.status_message.switch_status_message.status;
|
switch_config->status.status = data->payload_data.status_message.switch_status_message.status;
|
||||||
|
@ -37,15 +37,17 @@
|
|||||||
|
|
||||||
#define ZH_SWITCH_KEEP_ALIVE_MESSAGE_FREQUENCY 10 // Frequency of sending a switch keep alive message to the gateway (in seconds).
|
#define ZH_SWITCH_KEEP_ALIVE_MESSAGE_FREQUENCY 10 // Frequency of sending a switch keep alive message to the gateway (in seconds).
|
||||||
#define ZH_SWITCH_ATTRIBUTES_MESSAGE_FREQUENCY 60 // Frequency of sending a switch attributes message to the gateway (in seconds).
|
#define ZH_SWITCH_ATTRIBUTES_MESSAGE_FREQUENCY 60 // Frequency of sending a switch attributes message to the gateway (in seconds).
|
||||||
#define ZH_SWITCH_HARDWARE_CONFIG_MESSAGE_FREQUENCY 300 // Frequency of sending a switch hardware config message to the gateway (in seconds).
|
#define ZH_SWITCH_HARDWARE_CONFIG_MESSAGE_FREQUENCY 60 // Frequency of sending a switch hardware config message to the gateway (in seconds).
|
||||||
#define ZH_SWITCH_CONFIG_MESSAGE_FREQUENCY 300 // Frequency of sending a switch config message to the gateway (in seconds).
|
#define ZH_SWITCH_CONFIG_MESSAGE_FREQUENCY 60 // Frequency of sending a switch config message to the gateway (in seconds).
|
||||||
#define ZH_SWITCH_STATUS_MESSAGE_FREQUENCY 300 // Frequency of sending a switch status message to the gateway (in seconds).
|
#define ZH_SWITCH_STATUS_MESSAGE_FREQUENCY 60 // Frequency of sending a switch status message to the gateway (in seconds).
|
||||||
|
|
||||||
#define ZH_GPIO_TASK_PRIORITY 10 // Prioritize the task of GPIO processing.
|
#define ZH_GPIO_TASK_PRIORITY 10 // Prioritize the task of GPIO processing.
|
||||||
#define ZH_GPIO_STACK_SIZE 2048 // The stack size of the task of GPIO processing.
|
#define ZH_GPIO_STACK_SIZE 2048 // The stack size of the task of GPIO processing.
|
||||||
#define ZH_MESSAGE_TASK_PRIORITY 5 // Prioritize the task of sending messages to the gateway.
|
#define ZH_MESSAGE_TASK_PRIORITY 5 // Prioritize the task of sending messages to the gateway.
|
||||||
#define ZH_MESSAGE_STACK_SIZE 2048 // The stack size of the task of sending messages to the gateway.
|
#define ZH_MESSAGE_STACK_SIZE 2048 // The stack size of the task of sending messages to the gateway.
|
||||||
|
|
||||||
|
static bool is_first_boot = false;
|
||||||
|
|
||||||
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 switch hardware configuration data.
|
struct // Storage structure of switch hardware configuration data.
|
||||||
@ -130,7 +132,7 @@ void zh_gpio_processing_task(void *pvParameter);
|
|||||||
/**
|
/**
|
||||||
* @brief Task for prepare the switch attributes message and sending it to the gateway.
|
* @brief Task for prepare the switch attributes message and sending it to the gateway.
|
||||||
*
|
*
|
||||||
* @param[in,out] pvParameter Pointer to structure of data exchange between tasks, functions and event handlers.
|
* @param[in] pvParameter Pointer to structure of data exchange between tasks, functions and event handlers.
|
||||||
*/
|
*/
|
||||||
void zh_send_switch_attributes_message_task(void *pvParameter);
|
void zh_send_switch_attributes_message_task(void *pvParameter);
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
2.1.0
|
2.2.0
|
Loading…
x
Reference in New Issue
Block a user