Version 2.0.0
Added ESP32 - C2/C3/C6/S2/S3 support. Added ESP-NOW v2.0 support. Removed zh_network support. Improved stability of work
This commit is contained in:
parent
7a34b9c25a
commit
d40bb7d52e
6
.gitmodules
vendored
6
.gitmodules
vendored
@ -1,9 +1,3 @@
|
||||
[submodule "components/zh_network"]
|
||||
path = components/zh_network
|
||||
url = https://github.com/aZholtikov/zh_network
|
||||
[submodule "components/zh_vector"]
|
||||
path = components/zh_vector
|
||||
url = https://github.com/aZholtikov/zh_vector
|
||||
[submodule "components/zh_espnow"]
|
||||
path = components/zh_espnow
|
||||
url = https://github.com/aZholtikov/zh_espnow
|
||||
|
15
README.md
15
README.md
@ -1,27 +1,24 @@
|
||||
# ESP-NOW led
|
||||
|
||||
ESP-NOW based led controller/light for ESP32 ESP-IDF and ESP8266 RTOS SDK. Alternate firmware for Tuya/SmartLife/eWeLink WiFi led controllers/lights.
|
||||
ESP-NOW based led controller/light for ESP32 ESP-IDF and ESP8266 RTOS_SDK. Alternate firmware for Tuya/SmartLife/eWeLink WiFi led controllers/lights.
|
||||
|
||||
## Tested on
|
||||
|
||||
1. ESP8266 RTOS_SDK v3.4
|
||||
2. ESP32 ESP-IDF v5.2
|
||||
2. ESP32 ESP-IDF v5.4
|
||||
|
||||
## Features
|
||||
|
||||
1. Saves the last state when the power is turned off.
|
||||
2. Automatically adds led configuration to Home Assistan via MQTT discovery as a light.
|
||||
3. Update firmware from HTTPS server via ESP-NOW.
|
||||
4. Direct or mesh work mode.
|
||||
|
||||
## Notes
|
||||
|
||||
1. Work mode must be same with [gateway](https://github.com/aZholtikov/zh_gateway) work mode.
|
||||
2. ESP-NOW mesh network based on the [zh_network](https://github.com/aZholtikov/zh_network).
|
||||
3. For initial settings use "menuconfig -> ZH ESP-NOW Led Configuration". After first boot all settings will be stored in NVS memory for prevente change during OTA firmware update.
|
||||
4. To restart the led, send the "restart" command to the root topic of the led (example - "homeassistant/espnow_led/24-62-AB-F9-1F-A8").
|
||||
5. To update the led firmware, send the "update" command to the root topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7"). The update path should be like as "https://your_server/zh_espnow_led_esp32.bin" (for ESP32) or "https://your_server/zh_espnow_led_esp8266.app1.bin + https://your_server/zh_espnow_led_esp8266.app2.bin" (for ESP8266). Average update time is up to some minutes. The online status of the update will be displayed in the root led topic.
|
||||
6. To change initial settings of the led (except work mode), send the X1,X2,X3,X4,X5,X6 command to the hardware topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7/hardware"). The configuration will only be accepted if it does not cause errors. The current configuration status is displayed in the configuration topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7/config").
|
||||
1. For initial settings use "menuconfig -> ZH ESP-NOW Led Configuration". After first boot all settings will be stored in NVS memory for prevente change during OTA firmware update.
|
||||
2. To restart the led, send the "restart" command to the root topic of the led (example - "homeassistant/espnow_led/24-62-AB-F9-1F-A8").
|
||||
3. To update the led firmware, send the "update" command to the root topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7"). The update path should be like as "https://your_server/zh_espnow_led_esp32.bin" (for ESP32) or "https://your_server/zh_espnow_led_esp8266.app1.bin + https://your_server/zh_espnow_led_esp8266.app2.bin" (for ESP8266). Average update time is up to one minute. The status of the update will be displayed in the root led topic.
|
||||
4. To change initial settings of the led (except work mode), send the X1,X2,X3,X4,X5,X6 command to the hardware topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7/hardware"). The configuration will only be accepted if it does not cause errors. The current configuration status is displayed in the configuration topic of the led (example - "homeassistant/espnow_led/70-03-9F-44-BE-F7/config").
|
||||
|
||||
MQTT configuration message should filled according to the template "X1,X2,X3,X4,X5,X6". Where:
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit d066c326e3accf6de824c20479b31282f599a4ce
|
||||
Subproject commit f4ecd08e4521dd1f46df15325304cb596296d42b
|
@ -1 +0,0 @@
|
||||
Subproject commit ebe0b8cbf52c97b532c620b57ef0a3da7869228a
|
@ -1 +0,0 @@
|
||||
Subproject commit 4e0c0a6623afc0eb0816b0447d8567bf6867247c
|
@ -10,17 +10,6 @@ menu "ZH ESP-NOW Led Configuration"
|
||||
default 19 if IDF_TARGET_ESP32C3
|
||||
default 30 if IDF_TARGET_ESP32C6
|
||||
|
||||
choice NETWORK_TYPE
|
||||
prompt "Network type"
|
||||
help
|
||||
Network type.
|
||||
default NETWORK_TYPE_DIRECT
|
||||
config NETWORK_TYPE_DIRECT
|
||||
bool "DIRECT"
|
||||
config NETWORK_TYPE_MESH
|
||||
bool "MESH"
|
||||
endchoice
|
||||
|
||||
choice LED_TYPE
|
||||
prompt "Led type"
|
||||
help
|
||||
|
@ -15,23 +15,17 @@ void app_main(void)
|
||||
wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
|
||||
esp_wifi_init(&wifi_init_config);
|
||||
esp_wifi_set_mode(WIFI_MODE_STA);
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N);
|
||||
#else
|
||||
esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_11B | WIFI_PROTOCOL_11G | WIFI_PROTOCOL_11N | WIFI_PROTOCOL_LR);
|
||||
#endif
|
||||
esp_wifi_start();
|
||||
#ifdef CONFIG_NETWORK_TYPE_DIRECT
|
||||
zh_espnow_init_config_t espnow_init_config = ZH_ESPNOW_INIT_CONFIG_DEFAULT();
|
||||
zh_espnow_init(&espnow_init_config);
|
||||
#else
|
||||
zh_network_init_config_t network_init_config = ZH_NETWORK_INIT_CONFIG_DEFAULT();
|
||||
zh_network_init(&network_init_config);
|
||||
#endif
|
||||
xTaskCreatePinnedToCore(&zh_send_led_attributes_message_task, "led_attributes_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, (TaskHandle_t *)&led_config->attributes_message_task, tskNO_AFFINITY);
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_keep_alive_message_task, "led_keep_alive_message_task", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, (TaskHandle_t *)&led_config->keep_alive_message_task, tskNO_AFFINITY);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
esp_event_handler_register(ZH_EVENT, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, led_config);
|
||||
esp_event_handler_register(ZH_ESPNOW, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, led_config);
|
||||
#else
|
||||
esp_event_handler_instance_register(ZH_EVENT, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, led_config, NULL);
|
||||
esp_event_handler_instance_register(ZH_ESPNOW, ESP_EVENT_ANY_ID, &zh_espnow_event_handler, led_config, NULL);
|
||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||
esp_ota_img_states_t ota_state = {0};
|
||||
esp_ota_get_state_partition(running, &ota_state);
|
||||
@ -429,7 +423,7 @@ void zh_send_led_attributes_message_task(void *pvParameter)
|
||||
data.payload_data.attributes_message.heap_size = esp_get_free_heap_size();
|
||||
data.payload_data.attributes_message.min_heap_size = esp_get_minimum_free_heap_size();
|
||||
data.payload_data.attributes_message.uptime = esp_timer_get_time() / 1000000;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
vTaskDelay(ZH_LED_ATTRIBUTES_MESSAGE_FREQUENCY * 1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
@ -448,7 +442,7 @@ void zh_send_led_config_message(const led_config_t *led_config)
|
||||
data.payload_data.config_message.led_config_message.optimistic = false;
|
||||
data.payload_data.config_message.led_config_message.qos = 2;
|
||||
data.payload_data.config_message.led_config_message.retain = true;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
}
|
||||
|
||||
void zh_send_led_hardware_config_message(const led_config_t *led_config)
|
||||
@ -462,7 +456,7 @@ void zh_send_led_hardware_config_message(const led_config_t *led_config)
|
||||
data.payload_data.config_message.led_hardware_config_message.red_pin = led_config->hardware_config.red_pin;
|
||||
data.payload_data.config_message.led_hardware_config_message.green_pin = led_config->hardware_config.green_pin;
|
||||
data.payload_data.config_message.led_hardware_config_message.blue_pin = led_config->hardware_config.blue_pin;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
}
|
||||
|
||||
void zh_send_led_keep_alive_message_task(void *pvParameter)
|
||||
@ -475,7 +469,7 @@ void zh_send_led_keep_alive_message_task(void *pvParameter)
|
||||
data.payload_data.keep_alive_message.message_frequency = ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY;
|
||||
for (;;)
|
||||
{
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
vTaskDelay(ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY * 1000 / portTICK_PERIOD_MS);
|
||||
}
|
||||
vTaskDelete(NULL);
|
||||
@ -493,7 +487,7 @@ void zh_send_led_status_message(const led_config_t *led_config)
|
||||
data.payload_data.status_message.led_status_message.green = led_config->status.green;
|
||||
data.payload_data.status_message.led_status_message.blue = led_config->status.blue;
|
||||
data.payload_data.status_message.led_status_message.effect = led_config->status.effect;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
|
||||
}
|
||||
|
||||
void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
@ -501,21 +495,12 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
led_config_t *led_config = arg;
|
||||
switch (event_id)
|
||||
{
|
||||
#ifdef CONFIG_NETWORK_TYPE_DIRECT
|
||||
case ZH_ESPNOW_ON_RECV_EVENT:;
|
||||
zh_espnow_event_on_recv_t *recv_data = event_data;
|
||||
if (recv_data->data_len != sizeof(zh_espnow_data_t))
|
||||
{
|
||||
goto ZH_ESPNOW_EVENT_HANDLER_EXIT;
|
||||
}
|
||||
#else
|
||||
case ZH_NETWORK_ON_RECV_EVENT:;
|
||||
zh_network_event_on_recv_t *recv_data = event_data;
|
||||
if (recv_data->data_len != sizeof(zh_espnow_data_t))
|
||||
{
|
||||
goto ZH_NETWORK_EVENT_HANDLER_EXIT;
|
||||
}
|
||||
#endif
|
||||
zh_espnow_data_t *data = (zh_espnow_data_t *)recv_data->data;
|
||||
switch (data->device_type)
|
||||
{
|
||||
@ -525,40 +510,22 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
case ZHPT_KEEP_ALIVE:
|
||||
if (data->payload_data.keep_alive_message.online_status == ZH_ONLINE)
|
||||
{
|
||||
memcpy(led_config->gateway_mac, recv_data->mac_addr, 6);
|
||||
if (led_config->gateway_is_available == false)
|
||||
{
|
||||
led_config->gateway_is_available = true;
|
||||
memcpy(led_config->gateway_mac, recv_data->mac_addr, 6);
|
||||
zh_send_led_hardware_config_message(led_config);
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
zh_send_led_config_message(led_config);
|
||||
zh_send_led_status_message(led_config);
|
||||
if (led_config->is_first_connection == false)
|
||||
{
|
||||
xTaskCreatePinnedToCore(&zh_send_led_attributes_message_task, "NULL", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, (TaskHandle_t *)&led_config->attributes_message_task, tskNO_AFFINITY);
|
||||
xTaskCreatePinnedToCore(&zh_send_led_keep_alive_message_task, "NULL", ZH_MESSAGE_STACK_SIZE, led_config, ZH_MESSAGE_TASK_PRIORITY, (TaskHandle_t *)&led_config->keep_alive_message_task, tskNO_AFFINITY);
|
||||
led_config->is_first_connection = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
vTaskResume(led_config->attributes_message_task);
|
||||
vTaskResume(led_config->keep_alive_message_task);
|
||||
}
|
||||
}
|
||||
zh_send_led_config_message(led_config);
|
||||
zh_send_led_status_message(led_config);
|
||||
vTaskResume(led_config->attributes_message_task);
|
||||
vTaskResume(led_config->keep_alive_message_task);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (led_config->gateway_is_available == true)
|
||||
{
|
||||
led_config->gateway_is_available = false;
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
}
|
||||
led_config->gateway_is_available = false;
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
break;
|
||||
case ZHPT_SET:
|
||||
@ -595,30 +562,9 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
led_config->hardware_config.green_pin = data->payload_data.config_message.led_hardware_config_message.green_pin;
|
||||
led_config->hardware_config.blue_pin = data->payload_data.config_message.led_hardware_config_message.blue_pin;
|
||||
zh_save_config(led_config);
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskDelete(led_config->attributes_message_task);
|
||||
vTaskDelete(led_config->keep_alive_message_task);
|
||||
}
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_KEEP_ALIVE;
|
||||
data->payload_data.keep_alive_message.online_status = ZH_OFFLINE;
|
||||
data->payload_data.keep_alive_message.message_frequency = ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
esp_restart();
|
||||
break;
|
||||
case ZHPT_UPDATE:;
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_KEEP_ALIVE;
|
||||
data->payload_data.keep_alive_message.online_status = ZH_OFFLINE;
|
||||
data->payload_data.keep_alive_message.message_frequency = ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
const esp_app_desc_t *app_info = get_app_description();
|
||||
led_config->update_partition = esp_ota_get_next_update_partition(NULL);
|
||||
strcpy(data->payload_data.ota_message.espnow_ota_data.app_version, app_info->version);
|
||||
@ -632,7 +578,7 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
strcpy(data->payload_data.ota_message.espnow_ota_data.app_name, app_info->project_name);
|
||||
#endif
|
||||
data->payload_type = ZHPT_UPDATE;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
break;
|
||||
case ZHPT_UPDATE_BEGIN:
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
@ -643,7 +589,7 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
led_config->ota_message_part_number = 1;
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_UPDATE_PROGRESS;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
break;
|
||||
case ZHPT_UPDATE_PROGRESS:
|
||||
if (led_config->ota_message_part_number == data->payload_data.ota_message.espnow_ota_message.part)
|
||||
@ -653,48 +599,27 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
}
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_UPDATE_PROGRESS;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
break;
|
||||
case ZHPT_UPDATE_ERROR:
|
||||
esp_ota_end(led_config->update_handle);
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskResume(led_config->attributes_message_task);
|
||||
vTaskResume(led_config->keep_alive_message_task);
|
||||
}
|
||||
break;
|
||||
case ZHPT_UPDATE_END:
|
||||
if (esp_ota_end(led_config->update_handle) != ESP_OK)
|
||||
{
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_UPDATE_FAIL;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskResume(led_config->attributes_message_task);
|
||||
vTaskResume(led_config->keep_alive_message_task);
|
||||
}
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
break;
|
||||
}
|
||||
esp_ota_set_boot_partition(led_config->update_partition);
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_UPDATE_SUCCESS;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
zh_espnow_send(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
esp_restart();
|
||||
break;
|
||||
case ZHPT_RESTART:
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskDelete(led_config->attributes_message_task);
|
||||
vTaskDelete(led_config->keep_alive_message_task);
|
||||
}
|
||||
data->device_type = ZHDT_LED;
|
||||
data->payload_type = ZHPT_KEEP_ALIVE;
|
||||
data->payload_data.keep_alive_message.online_status = ZH_OFFLINE;
|
||||
data->payload_data.keep_alive_message.message_frequency = ZH_LED_KEEP_ALIVE_MESSAGE_FREQUENCY;
|
||||
zh_send_message(led_config->gateway_mac, (uint8_t *)data, sizeof(zh_espnow_data_t));
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
esp_restart();
|
||||
break;
|
||||
default:
|
||||
@ -704,7 +629,6 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#ifdef CONFIG_NETWORK_TYPE_DIRECT
|
||||
ZH_ESPNOW_EVENT_HANDLER_EXIT:
|
||||
heap_caps_free(recv_data->data);
|
||||
break;
|
||||
@ -713,30 +637,10 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve
|
||||
if (send_data->status == ZH_ESPNOW_SEND_FAIL && led_config->gateway_is_available == true)
|
||||
{
|
||||
led_config->gateway_is_available = false;
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
break;
|
||||
#else
|
||||
ZH_NETWORK_EVENT_HANDLER_EXIT:
|
||||
heap_caps_free(recv_data->data);
|
||||
break;
|
||||
case ZH_NETWORK_ON_SEND_EVENT:;
|
||||
zh_network_event_on_send_t *send_data = event_data;
|
||||
if (send_data->status == ZH_NETWORK_SEND_FAIL && led_config->gateway_is_available == true)
|
||||
{
|
||||
led_config->gateway_is_available = false;
|
||||
if (led_config->hardware_config.led_type != HALT_NONE)
|
||||
{
|
||||
vTaskSuspend(led_config->attributes_message_task);
|
||||
vTaskSuspend(led_config->keep_alive_message_task);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -9,17 +9,8 @@
|
||||
#include "driver/ledc.h"
|
||||
#include "esp_timer.h"
|
||||
#include "esp_ota_ops.h"
|
||||
#include "zh_config.h"
|
||||
|
||||
#ifdef CONFIG_NETWORK_TYPE_DIRECT
|
||||
#include "zh_espnow.h"
|
||||
#define zh_send_message(a, b, c) zh_espnow_send(a, b, c)
|
||||
#define ZH_EVENT ZH_ESPNOW
|
||||
#else
|
||||
#include "zh_network.h"
|
||||
#define zh_send_message(a, b, c) zh_network_send(a, b, c)
|
||||
#define ZH_EVENT ZH_NETWORK
|
||||
#endif
|
||||
#include "zh_config.h"
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP8266
|
||||
#define ZH_CHIP_TYPE HACHT_ESP8266
|
||||
@ -48,7 +39,7 @@
|
||||
#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_MESSAGE_TASK_PRIORITY 2 // 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.
|
||||
|
||||
typedef struct // Structure of data exchange between tasks, functions and event handlers.
|
||||
@ -81,7 +72,6 @@ typedef struct // Structure of data exchange between tasks, functions and event
|
||||
uint8_t blue; // Blue color channel.
|
||||
} channel;
|
||||
volatile bool gateway_is_available; // Gateway availability status flag. @note Used to control the tasks when the gateway connection is established / lost.
|
||||
volatile bool is_first_connection; // First connection status flag. @note Used to control the tasks when the gateway connection is established / lost.
|
||||
uint8_t gateway_mac[6]; // Gateway MAC address.
|
||||
TaskHandle_t attributes_message_task; // Unique task handle for zh_send_led_attributes_message_task().
|
||||
TaskHandle_t keep_alive_message_task; // Unique task handle for zh_send_led_keep_alive_message_task().
|
||||
|
7
partitions_esp32c2.csv
Normal file
7
partitions_esp32c2.csv
Normal file
@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 900K,
|
||||
ota_1, app, ota_1, , 900K,
|
|
7
partitions_esp32c3.csv
Normal file
7
partitions_esp32c3.csv
Normal file
@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 1500K,
|
||||
ota_1, app, ota_1, , 1500K,
|
|
7
partitions_esp32c6.csv
Normal file
7
partitions_esp32c6.csv
Normal file
@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 1500K,
|
||||
ota_1, app, ota_1, , 1500K,
|
|
7
partitions_esp32s2.csv
Normal file
7
partitions_esp32s2.csv
Normal file
@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 1500K,
|
||||
ota_1, app, ota_1, , 1500K,
|
|
7
partitions_esp32s3.csv
Normal file
7
partitions_esp32s3.csv
Normal file
@ -0,0 +1,7 @@
|
||||
# Name, Type, SubType, Offset, Size, Flags
|
||||
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
|
||||
nvs, data, nvs, , 0x4000,
|
||||
otadata, data, ota, , 0x2000,
|
||||
phy_init, data, phy, , 0x1000,
|
||||
ota_0, app, ota_0, , 1500K,
|
||||
ota_1, app, ota_1, , 1500K,
|
|
18
sdkconfig.defaults.esp32c2
Normal file
18
sdkconfig.defaults.esp32c2
Normal file
@ -0,0 +1,18 @@
|
||||
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=0
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="2MB"
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32c2.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32c2.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
18
sdkconfig.defaults.esp32c3
Normal file
18
sdkconfig.defaults.esp32c3
Normal file
@ -0,0 +1,18 @@
|
||||
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=0
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32c3.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32c3.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
18
sdkconfig.defaults.esp32c6
Normal file
18
sdkconfig.defaults.esp32c6
Normal file
@ -0,0 +1,18 @@
|
||||
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=0
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32c6.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32c6.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
18
sdkconfig.defaults.esp32s2
Normal file
18
sdkconfig.defaults.esp32s2
Normal file
@ -0,0 +1,18 @@
|
||||
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=0
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32s2.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32s2.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
18
sdkconfig.defaults.esp32s3
Normal file
18
sdkconfig.defaults.esp32s3
Normal file
@ -0,0 +1,18 @@
|
||||
CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000
|
||||
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL_NONE=y
|
||||
CONFIG_BOOTLOADER_LOG_LEVEL=0
|
||||
CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE=y
|
||||
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
|
||||
CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
|
||||
|
||||
CONFIG_PARTITION_TABLE_CUSTOM=y
|
||||
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions_esp32s3.csv"
|
||||
CONFIG_PARTITION_TABLE_FILENAME="partitions_esp32s3.csv"
|
||||
CONFIG_PARTITION_TABLE_OFFSET=0x8000
|
||||
|
||||
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
|
||||
|
||||
CONFIG_LOG_DEFAULT_LEVEL_NONE=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL=0
|
@ -1 +1 @@
|
||||
1.0.3
|
||||
2.0.0
|
Loading…
x
Reference in New Issue
Block a user