diff --git a/components/zh_espnow b/components/zh_espnow index f4ecd08..af7fa20 160000 --- a/components/zh_espnow +++ b/components/zh_espnow @@ -1 +1 @@ -Subproject commit f4ecd08e4521dd1f46df15325304cb596296d42b +Subproject commit af7fa204e1f2793f6902948e27d57334839b2058 diff --git a/main/zh_espnow_switch.c b/main/zh_espnow_switch.c index 6687b3c..f87ad8d 100644 --- a/main/zh_espnow_switch.c +++ b/main/zh_espnow_switch.c @@ -44,7 +44,6 @@ void zh_load_config(switch_config_t *switch_config) uint8_t config_is_present = 0; if (nvs_get_u8(nvs_handle, "present", &config_is_present) == ESP_ERR_NVS_NOT_FOUND) { - nvs_set_u8(nvs_handle, "present", 0xFE); nvs_close(nvs_handle); SETUP_INITIAL_SETTINGS: #ifdef CONFIG_RELAY_USING @@ -110,6 +109,7 @@ void zh_save_config(const switch_config_t *switch_config) { nvs_handle_t nvs_handle = 0; nvs_open("config", NVS_READWRITE, &nvs_handle); + nvs_set_u8(nvs_handle, "present", 0xFE); nvs_set_u8(nvs_handle, "relay_pin", switch_config->hardware_config.relay_pin); nvs_set_u8(nvs_handle, "relay_lvl", switch_config->hardware_config.relay_on_level); nvs_set_u8(nvs_handle, "led_pin", switch_config->hardware_config.led_pin); @@ -129,7 +129,6 @@ void zh_load_status(switch_config_t *switch_config) uint8_t status_is_present = 0; if (nvs_get_u8(nvs_handle, "present", &status_is_present) == ESP_ERR_NVS_NOT_FOUND) { - nvs_set_u8(nvs_handle, "present", 0xFE); nvs_close(nvs_handle); zh_save_status(switch_config); return; @@ -142,6 +141,7 @@ void zh_save_status(const switch_config_t *switch_config) { nvs_handle_t nvs_handle = 0; nvs_open("status", NVS_READWRITE, &nvs_handle); + nvs_set_u8(nvs_handle, "present", 0xFE); nvs_set_u8(nvs_handle, "relay_state", switch_config->status.status); nvs_close(nvs_handle); } @@ -479,7 +479,7 @@ void zh_espnow_event_handler(void *arg, esp_event_base_t event_base, int32_t eve break; case ZH_ESPNOW_ON_SEND_EVENT:; zh_espnow_event_on_send_t *send_data = event_data; - if (send_data->status == ZH_ESPNOW_SEND_FAIL && switch_config->gateway_is_available == true) + if (send_data->status == ZH_ESPNOW_SEND_FAIL) { switch_config->gateway_is_available = false; vTaskSuspend(switch_config->switch_attributes_message_task); diff --git a/version.txt b/version.txt index 359a5b9..10bf840 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -2.0.0 \ No newline at end of file +2.0.1 \ No newline at end of file