Added processing of node messages about offline mode
This commit is contained in:
parent
c73ecd7ce6
commit
458a4695bd
@ -380,20 +380,30 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
is_found = true;
|
||||
}
|
||||
}
|
||||
if (gateway_config->syslog_is_enable == true && is_found == false)
|
||||
char *mac = (char *)heap_caps_malloc(18, MALLOC_CAP_8BIT);
|
||||
memset(mac, 0, 18);
|
||||
sprintf(mac, "" MAC_STR "", MAC2STR(recv_data->mac_addr));
|
||||
if (data->payload_data.keep_alive_message.online_status == ZH_ONLINE)
|
||||
{
|
||||
char *mac = (char *)heap_caps_malloc(18, MALLOC_CAP_8BIT);
|
||||
memset(mac, 0, 18);
|
||||
sprintf(mac, "" MAC_STR "", MAC2STR(recv_data->mac_addr));
|
||||
zh_syslog_send(ZH_USER, ZH_INFO, mac, zh_get_device_type_value_name(data->device_type), "Connected to gateway.");
|
||||
heap_caps_free(mac);
|
||||
available_device_t available_device = {0};
|
||||
available_device.device_type = data->device_type;
|
||||
memcpy(available_device.mac_addr, recv_data->mac_addr, 6);
|
||||
available_device.frequency = data->payload_data.keep_alive_message.message_frequency;
|
||||
available_device.time = esp_timer_get_time() / 1000000;
|
||||
zh_vector_push_back(&gateway_config->available_device_vector, &available_device);
|
||||
if (gateway_config->syslog_is_enable == true && is_found == false)
|
||||
{
|
||||
zh_syslog_send(ZH_USER, ZH_INFO, mac, zh_get_device_type_value_name(data->device_type), "Connected to gateway.");
|
||||
}
|
||||
}
|
||||
available_device_t available_device = {0};
|
||||
available_device.device_type = data->device_type;
|
||||
memcpy(available_device.mac_addr, recv_data->mac_addr, 6);
|
||||
available_device.frequency = data->payload_data.keep_alive_message.message_frequency;
|
||||
available_device.time = esp_timer_get_time() / 1000000;
|
||||
zh_vector_push_back(&gateway_config->available_device_vector, &available_device);
|
||||
else
|
||||
{
|
||||
if (gateway_config->syslog_is_enable == true)
|
||||
{
|
||||
zh_syslog_send(ZH_USER, ZH_WARNING, mac, zh_get_device_type_value_name(data->device_type), "Disconnected from gateway.");
|
||||
}
|
||||
}
|
||||
heap_caps_free(mac);
|
||||
xSemaphoreGive(gateway_config->device_check_in_progress_mutex);
|
||||
}
|
||||
zh_espnow_send_mqtt_json_keep_alive_message(data, recv_data->mac_addr, gateway_config);
|
||||
@ -645,8 +655,6 @@ void zh_mqtt_event_handler(void *arg, esp_event_base_t event_base, int32_t event
|
||||
}
|
||||
else if (strncmp(incoming_payload, "restart", strlen(incoming_payload) + 1) == 0)
|
||||
{
|
||||
zh_espnow_data_t data = {0};
|
||||
data.device_type = ZHDT_GATEWAY;
|
||||
data.payload_type = ZHPT_KEEP_ALIVE;
|
||||
data.payload_data.keep_alive_message.online_status = ZH_OFFLINE;
|
||||
zh_send_message(NULL, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
@ -1064,7 +1072,6 @@ void zh_espnow_ota_update_task(void *pvParameter)
|
||||
char *mac = (char *)heap_caps_malloc(18, MALLOC_CAP_8BIT);
|
||||
memset(mac, 0, 18);
|
||||
sprintf(mac, "" MAC_STR "", MAC2STR(gateway_config->espnow_ota_data.mac_addr));
|
||||
// heap_caps_free(mac);
|
||||
xSemaphoreTake(gateway_config->espnow_ota_in_progress_mutex, portMAX_DELAY);
|
||||
zh_espnow_data_t data = {0};
|
||||
data.device_type = ZHDT_GATEWAY;
|
||||
|
@ -1 +1 @@
|
||||
1.0.8-2
|
||||
1.0.8-4
|
Loading…
x
Reference in New Issue
Block a user