Changed sensor reading error message
This commit is contained in:
		@@ -471,8 +471,6 @@ void zh_send_sensor_status_message_task(void *pvParameter)
 | 
				
			|||||||
    float temperature = 0.0;
 | 
					    float temperature = 0.0;
 | 
				
			||||||
    zh_espnow_data_t data = {0};
 | 
					    zh_espnow_data_t data = {0};
 | 
				
			||||||
    data.device_type = ZHDT_SENSOR;
 | 
					    data.device_type = ZHDT_SENSOR;
 | 
				
			||||||
    data.payload_type = ZHPT_STATE;
 | 
					 | 
				
			||||||
    data.payload_data.status_message.sensor_status_message.sensor_type = switch_config->hardware_config.sensor_type;
 | 
					 | 
				
			||||||
    for (;;)
 | 
					    for (;;)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        esp_err_t err = ESP_OK;
 | 
					        esp_err_t err = ESP_OK;
 | 
				
			||||||
@@ -500,13 +498,19 @@ void zh_send_sensor_status_message_task(void *pvParameter)
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        if (err == ESP_OK)
 | 
					        if (err == ESP_OK)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
 | 
					            data.payload_type = ZHPT_STATE;
 | 
				
			||||||
 | 
					            data.payload_data.status_message.sensor_status_message.sensor_type = switch_config->hardware_config.sensor_type;
 | 
				
			||||||
            zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
 | 
					            zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        else
 | 
					        else
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            data.payload_type = ZHPT_ERROR;
 | 
					            data.payload_type = ZHPT_ERROR;
 | 
				
			||||||
            strcpy(data.payload_data.status_message.error_message.message, "Sensor reading error.");
 | 
					            char *message = (char *)heap_caps_malloc(151, MALLOC_CAP_8BIT);
 | 
				
			||||||
 | 
					            memset(message, 0, 151);
 | 
				
			||||||
 | 
					            sprintf(message, "Sensor %s reading error. Error - %s.", zh_get_sensor_type_value_name(switch_config->hardware_config.sensor_type), esp_err_to_name(err));
 | 
				
			||||||
 | 
					            strcpy(data.payload_data.status_message.error_message.message, message);
 | 
				
			||||||
            zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
 | 
					            zh_send_message(switch_config->gateway_mac, (uint8_t *)&data, sizeof(zh_espnow_data_t));
 | 
				
			||||||
 | 
					            heap_caps_free(message);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        vTaskDelay(ZH_SENSOR_STATUS_MESSAGE_FREQUENCY * 1000 / portTICK_PERIOD_MS);
 | 
					        vTaskDelay(ZH_SENSOR_STATUS_MESSAGE_FREQUENCY * 1000 / portTICK_PERIOD_MS);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user