diff --git a/components/zh_config b/components/zh_config index ec60c4d..bc12b2c 160000 --- a/components/zh_config +++ b/components/zh_config @@ -1 +1 @@ -Subproject commit ec60c4d5596150a139e7237c7a685e5b2d2df8fb +Subproject commit bc12b2ca4b59ef178624d968188e7cad0dcfa7fd diff --git a/components/zh_dht b/components/zh_dht index 7339f15..7662593 160000 --- a/components/zh_dht +++ b/components/zh_dht @@ -1 +1 @@ -Subproject commit 7339f1544b59184ee3e77e1266ce08910b392768 +Subproject commit 7662593a30319809aa5160fa382689b675615f15 diff --git a/components/zh_espnow b/components/zh_espnow index 10a5837..742c807 160000 --- a/components/zh_espnow +++ b/components/zh_espnow @@ -1 +1 @@ -Subproject commit 10a5837c8fffd027d2d6a0709644f69a0bc85be1 +Subproject commit 742c807c416d9f80c0571f8daea85d275e8d4c93 diff --git a/components/zh_network b/components/zh_network index 76281e8..783b44f 160000 --- a/components/zh_network +++ b/components/zh_network @@ -1 +1 @@ -Subproject commit 76281e85be8bd7570c5a0d5d49626242c0c798c3 +Subproject commit 783b44fbca0ed467a868b4420f191c6d9f6caea5 diff --git a/components/zh_vector b/components/zh_vector index 899c3fe..53cdc76 160000 --- a/components/zh_vector +++ b/components/zh_vector @@ -1 +1 @@ -Subproject commit 899c3feed8df95f937c4f802ba880adf5e6140da +Subproject commit 53cdc7687388840c04470fb35e84e83b27175ae5 diff --git a/main/Kconfig.projbuild b/main/Kconfig.projbuild index 1681e97..4499703 100644 --- a/main/Kconfig.projbuild +++ b/main/Kconfig.projbuild @@ -151,10 +151,8 @@ menu "ZH ESP-NOW Switch Configuration" default SENSOR_TYPE_DS18B20 config SENSOR_TYPE_DS18B20 bool "DS18B20" - config SENSOR_TYPE_DHT11 - bool "DHT11" - config SENSOR_TYPE_DHT22 - bool "DHT22" + config SENSOR_TYPE_DHT + bool "DHT" endchoice endmenu \ No newline at end of file diff --git a/main/zh_espnow_switch.c b/main/zh_espnow_switch.c index d4381f9..756558f 100644 --- a/main/zh_espnow_switch.c +++ b/main/zh_espnow_switch.c @@ -91,12 +91,9 @@ void zh_load_config(switch_config_t *switch_config) #ifdef CONFIG_SENSOR_TYPE_DS18B20 switch_config->hardware_config.sensor_pin = CONFIG_SENSOR_PIN; switch_config->hardware_config.sensor_type = HAST_DS18B20; -#elif CONFIG_SENSOR_TYPE_DHT11 +#elif CONFIG_SENSOR_TYPE_DHT switch_config->hardware_config.sensor_pin = CONFIG_SENSOR_PIN; - switch_config->hardware_config.sensor_type = HAST_DHT11; -#elif CONFIG_SENSOR_TYPE_DHT22 - switch_config->hardware_config.sensor_pin = CONFIG_SENSOR_PIN; - switch_config->hardware_config.sensor_type = HAST_DHT22; + switch_config->hardware_config.sensor_type = HAST_DHT; #else switch_config->hardware_config.sensor_pin = ZH_NOT_USED; switch_config->hardware_config.sensor_type = HAST_NONE; @@ -238,11 +235,13 @@ void zh_gpio_init(switch_config_t *switch_config) switch_config->hardware_config.sensor_pin = ZH_NOT_USED; } break; - case HAST_DHT11:; - case HAST_DHT22:; - zh_dht_sensor_type_t sensor_type = (switch_config->hardware_config.sensor_type == HAST_DHT11) ? ZH_DHT11 : ZH_DHT22; - switch_config->dht_handle = zh_dht_init(sensor_type, switch_config->hardware_config.sensor_pin); - switch_config->hardware_config.sensor_pin = switch_config->dht_handle.sensor_pin; + case HAST_DHT:; + zh_dht_init_config_t dht_init_config = ZH_DHT_INIT_CONFIG_DEFAULT(); + dht_init_config.sensor_pin = switch_config->hardware_config.sensor_pin; + if (zh_dht_init(&dht_init_config) != ESP_OK) + { + switch_config->hardware_config.sensor_pin = ZH_NOT_USED; + } break; default: switch_config->hardware_config.sensor_type = HAST_NONE; @@ -405,15 +404,14 @@ void zh_send_sensor_config_message(const switch_config_t *switch_config) char *unit_of_measurement = NULL; switch (switch_config->hardware_config.sensor_type) { - case HAST_DS18B20:; + case HAST_DS18B20: data.payload_data.config_message.sensor_config_message.unique_id = 2; data.payload_data.config_message.sensor_config_message.sensor_device_class = HASDC_TEMPERATURE; unit_of_measurement = "°C"; strcpy(data.payload_data.config_message.sensor_config_message.unit_of_measurement, unit_of_measurement); zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t)); break; - case HAST_DHT11:; - case HAST_DHT22:; + case HAST_DHT: data.payload_data.config_message.sensor_config_message.unique_id = 2; data.payload_data.config_message.sensor_config_message.sensor_device_class = HASDC_TEMPERATURE; unit_of_measurement = "°C"; @@ -487,10 +485,9 @@ void zh_send_sensor_status_message_task(void *pvParameter) break; } break; - case HAST_DHT11: - case HAST_DHT22: + case HAST_DHT: ZH_DHT_READ: - switch (zh_dht_read(&switch_config->dht_handle, &humidity, &temperature)) + switch (zh_dht_read(&humidity, &temperature)) { case ESP_OK: data.payload_data.status_message.sensor_status_message.humidity = humidity; diff --git a/main/zh_espnow_switch.h b/main/zh_espnow_switch.h index cc01ddb..e8d03b0 100644 --- a/main/zh_espnow_switch.h +++ b/main/zh_espnow_switch.h @@ -78,7 +78,6 @@ typedef struct // Structure of data exchange between tasks, functions and event volatile bool gpio_processing; // GPIO processing flag. @note Used to prevent a repeated interrupt from triggering during GPIO processing. volatile bool gateway_is_available; // Gateway availability status flag. @note Used to control the tasks when the gateway connection is established / lost. uint8_t gateway_mac[6]; // Gateway MAC address. - zh_dht_handle_t dht_handle; // Unique DTH11/22 sensor handle. TaskHandle_t switch_attributes_message_task; // Unique task handle for zh_send_switsh_attributes_message_task(). TaskHandle_t switch_keep_alive_message_task; // Unique task handle for zh_send_switch_keep_alive_message_task(). TaskHandle_t sensor_attributes_message_task; // Unique task handle for zh_send_sensor_attributes_message_task(). diff --git a/version.txt b/version.txt index 7f20734..e6d5cb8 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.1 \ No newline at end of file +1.0.2 \ No newline at end of file