Changed the frequency of sending messages.
Changed the event for the first start of tasks.
This commit is contained in:
parent
3a1b10bdc7
commit
09a2b1cdcc
@ -18,11 +18,6 @@ void app_main(void)
|
||||
esp_wifi_start();
|
||||
zh_espnow_init_config_t espnow_init_config = ZH_ESPNOW_INIT_CONFIG_DEFAULT();
|
||||
zh_espnow_init(&espnow_init_config);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_attributes_message_task, "led_attributes_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_keep_alive_message_task, "led_keep_alive_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_config_message_task, "led_config_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_hardware_config_message_task, "led_hardware_config_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_status_message_task, "led_status_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
esp_event_handler_register(ZH_ESPNOW, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, led_config);
|
||||
#else
|
||||
@ -543,6 +538,15 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
{
|
||||
case ZHPT_KEEP_ALIVE:
|
||||
memcpy(led_config->gateway_mac, recv_data->mac_addr, 6);
|
||||
if (is_first_boot == false)
|
||||
{
|
||||
is_first_boot = true;
|
||||
xTaskCreatePinnedToCore(&zh_send_led_attributes_message_task, "led_attributes_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_keep_alive_message_task, "led_keep_alive_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_config_message_task, "led_config_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_hardware_config_message_task, "led_hardware_config_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_status_message_task, "led_status_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, NULL, tskNO_AFFINITY);
|
||||
}
|
||||
break;
|
||||
case ZHPT_SET:
|
||||
led_config->status.status = data->payload_data.status_message.led_status_message.status;
|
||||
|
@ -38,13 +38,15 @@
|
||||
|
||||
#define ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY 10 // Frequency of sending a led keep alive message to the gateway (in seconds).
|
||||
#define ZH_LED_ATTRIBUTES_MESSAGE_FREQUENCY 60 // Frequency of sending a led attributes message to the gateway (in seconds).
|
||||
#define ZH_LED_HARDWARE_CONFIG_MESSAGE_FREQUENCY 300 // Frequency of sending a led hardware config message to the gateway (in seconds).
|
||||
#define ZH_LED_CONFIG_MESSAGE_FREQUENCY 300 // Frequency of sending a led config message to the gateway (in seconds).
|
||||
#define ZH_LED_STATUS_MESSAGE_FREQUENCY 300 // Frequency of sending a led status message to the gateway (in seconds).
|
||||
#define ZH_LED_HARDWARE_CONFIG_MESSAGE_FREQUENCY 60 // Frequency of sending a led hardware config message to the gateway (in seconds).
|
||||
#define ZH_LED_CONFIG_MESSAGE_FREQUENCY 60 // Frequency of sending a led config message to the gateway (in seconds).
|
||||
#define ZH_LED_STATUS_MESSAGE_FREQUENCY 60 // Frequency of sending a led status message to the gateway (in seconds).
|
||||
|
||||
#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.
|
||||
|
||||
static bool is_first_boot = false;
|
||||
|
||||
typedef struct // Structure of data exchange between tasks, functions and event handlers.
|
||||
{
|
||||
struct // Storage structure of led hardware configuration data.
|
||||
@ -138,7 +140,7 @@ int32_t zh_map(int32_t value, int32_t in_min, int32_t in_max, int32_t out_min, i
|
||||
/**
|
||||
* @brief Task for prepare the led 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_led_attributes_message_task(void *pvParameter);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user