Added multiple attempts to read the sensor
This commit is contained in:
parent
554268488f
commit
44bc1d4977
@ -484,6 +484,8 @@ void zh_send_sensor_status_message_task(void *pvParameter)
|
||||
data.device_type = ZHDT_SENSOR;
|
||||
for (;;)
|
||||
{
|
||||
uint8_t attempts = 0;
|
||||
READ_SENSOR:
|
||||
esp_err_t err = ESP_OK;
|
||||
switch (switch_config->hardware_config.sensor_type)
|
||||
{
|
||||
@ -515,6 +517,11 @@ void zh_send_sensor_status_message_task(void *pvParameter)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++attempts < ZH_SENSOR_READ_MAXIMUM_RETRY)
|
||||
{
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
goto READ_SENSOR;
|
||||
}
|
||||
data.payload_type = ZHPT_ERROR;
|
||||
char *message = (char *)heap_caps_malloc(150, MALLOC_CAP_8BIT);
|
||||
memset(message, 0, 150);
|
||||
|
@ -49,6 +49,7 @@
|
||||
#define ZH_SWITCH_KEEP_ALIVE_MESSAGE_FREQUENCY 10 // Frequency of sending a switch keep alive message to the gateway (in seconds).
|
||||
#define ZH_SWITCH_ATTRIBUTES_MESSAGE_FREQUENCY 60 // Frequency of sending a switch attributes message to the gateway (in seconds).
|
||||
#define ZH_SENSOR_ATTRIBUTES_MESSAGE_FREQUENCY 60 // Frequency of sending a sensor attributes message to the gateway (in seconds).
|
||||
#define ZH_SENSOR_READ_MAXIMUM_RETRY 5 // Maximum number of read sensor attempts.
|
||||
|
||||
#define ZH_GPIO_TASK_PRIORITY 3 // Prioritize the task of GPIO processing.
|
||||
#define ZH_GPIO_STACK_SIZE 2048 // The stack size of the task of GPIO processing.
|
||||
|
Loading…
x
Reference in New Issue
Block a user