mirror of
https://github.com/esphome/esphome.git
synced 2024-11-27 09:18:00 +01:00
fix(mr60fda2): jump bypasses variable initialization
This commit is contained in:
parent
0b1bcfe826
commit
fb4f9c7b6d
1 changed files with 11 additions and 3 deletions
|
@ -214,6 +214,10 @@ void MR60FDA2Component::split_frame_(uint8_t buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MR60FDA2Component::process_frame_() {
|
void MR60FDA2Component::process_frame_() {
|
||||||
|
// Declare variables outside of the switch statement
|
||||||
|
float install_height_float = 0;
|
||||||
|
float height_threshold_float = 0;
|
||||||
|
|
||||||
switch (this->current_frame_type_) {
|
switch (this->current_frame_type_) {
|
||||||
case IS_FALL_TYPE_BUFFER:
|
case IS_FALL_TYPE_BUFFER:
|
||||||
if (this->fall_detected_binary_sensor_ != nullptr) {
|
if (this->fall_detected_binary_sensor_ != nullptr) {
|
||||||
|
@ -221,11 +225,13 @@ void MR60FDA2Component::process_frame_() {
|
||||||
}
|
}
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PEOPLE_EXIST_TYPE_BUFFER:
|
case PEOPLE_EXIST_TYPE_BUFFER:
|
||||||
if (this->people_exist_binary_sensor_ != nullptr)
|
if (this->people_exist_binary_sensor_ != nullptr)
|
||||||
this->people_exist_binary_sensor_->publish_state(this->current_frame_buf_[LEN_TO_HEAD_CKSUM]);
|
this->people_exist_binary_sensor_->publish_state(this->current_frame_buf_[LEN_TO_HEAD_CKSUM]);
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESULT_INSTALL_HEIGHT:
|
case RESULT_INSTALL_HEIGHT:
|
||||||
if (this->current_data_buf_[0]) {
|
if (this->current_data_buf_[0]) {
|
||||||
ESP_LOGD(TAG, "Successfully set the mounting height");
|
ESP_LOGD(TAG, "Successfully set the mounting height");
|
||||||
|
@ -234,6 +240,7 @@ void MR60FDA2Component::process_frame_() {
|
||||||
}
|
}
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESULT_HEIGHT_THRESHOLD:
|
case RESULT_HEIGHT_THRESHOLD:
|
||||||
if (this->current_data_buf_[0]) {
|
if (this->current_data_buf_[0]) {
|
||||||
ESP_LOGD(TAG, "Successfully set the height threshold");
|
ESP_LOGD(TAG, "Successfully set the height threshold");
|
||||||
|
@ -242,6 +249,7 @@ void MR60FDA2Component::process_frame_() {
|
||||||
}
|
}
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RESULT_SENSITIVITY:
|
case RESULT_SENSITIVITY:
|
||||||
if (this->current_data_buf_[0]) {
|
if (this->current_data_buf_[0]) {
|
||||||
ESP_LOGD(TAG, "Successfully set the sensitivity");
|
ESP_LOGD(TAG, "Successfully set the sensitivity");
|
||||||
|
@ -250,10 +258,9 @@ void MR60FDA2Component::process_frame_() {
|
||||||
}
|
}
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
case RESULT_PARAMETERS:
|
|
||||||
float install_height_float = 0;
|
|
||||||
float height_threshold_float = 0;
|
|
||||||
|
|
||||||
|
case RESULT_PARAMETERS:
|
||||||
|
// Variables declared outside the switch statement will be initialized here
|
||||||
if (this->install_height_select_ != nullptr) {
|
if (this->install_height_select_ != nullptr) {
|
||||||
this->current_install_height_int_ =
|
this->current_install_height_int_ =
|
||||||
encode_uint32(current_data_buf_[3], current_data_buf_[2], current_data_buf_[1], current_data_buf_[0]);
|
encode_uint32(current_data_buf_[3], current_data_buf_[2], current_data_buf_[1], current_data_buf_[0]);
|
||||||
|
@ -284,6 +291,7 @@ void MR60FDA2Component::process_frame_() {
|
||||||
height_threshold_float, this->current_sensitivity_);
|
height_threshold_float, this->current_sensitivity_);
|
||||||
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
this->current_frame_locate_ = LOCATE_FRAME_HEADER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue