Skip to content

Commit 78f50ce

Browse files
committed
Fix switch logic errors and snake case
1 parent e97eb76 commit 78f50ce

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

components/sen5x/sen5x.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,11 @@ void SEN5XComponent::internal_setup_(uint8_t state) {
135135
return;
136136
} else {
137137
// update blank product name from model parameter
138-
this->product_name_ = model_to_str(this->model_.value());
138+
this->product_name_ = model_to_str_(this->model_.value());
139139
}
140140
} else if (!this->model_.has_value()) {
141141
// model is not defined, get it from product name
142-
this->model_.value() = str_to_model(this->product_name_.c_str());
142+
this->model_.value() = str_to_model_(this->product_name_.c_str());
143143
if (this->model_.value() == UNKNOWN_MODEL) {
144144
ESP_LOGE(TAG, "Product Name from sensor is not a known sensor");
145145
this->error_code_ = PRODUCT_NAME_FAILED;
@@ -148,7 +148,7 @@ void SEN5XComponent::internal_setup_(uint8_t state) {
148148
}
149149
} else {
150150
// product name and model specified in config, they must match
151-
if (this->product_name_ != model_to_str(this->model_.value())) {
151+
if (this->product_name_ != model_to_str_(this->model_.value())) {
152152
ESP_LOGE(TAG, "Sensor Product Name does not match 'model' in configuration");
153153
this->error_code_ = PRODUCT_NAME_FAILED;
154154
this->mark_failed();
@@ -441,7 +441,7 @@ void SEN5XComponent::dump_config() {
441441
}
442442
LOG_I2C_DEVICE(this);
443443
if (this->model_.has_value()) {
444-
ESP_LOGCONFIG(TAG, " Model: %s", model_to_str(this->model_.value()));
444+
ESP_LOGCONFIG(TAG, " Model: %s", model_to_str_(this->model_.value()));
445445
}
446446
ESP_LOGCONFIG(TAG, " Product Name: %s", this->product_name_.c_str());
447447
ESP_LOGCONFIG(TAG, " Serial number: %s", this->serial_number_.c_str());
@@ -546,6 +546,7 @@ void SEN5XComponent::update() {
546546
case SEN68:
547547
cmd = SEN68_CMD_READ_MEASUREMENT;
548548
length = 9;
549+
break;
549550
default:
550551
cmd = SEN5X_CMD_READ_MEASUREMENT;
551552
length = 9;
@@ -682,6 +683,7 @@ bool SEN5XComponent::start_measurements_() {
682683
case SEN66:
683684
case SEN68:
684685
cmd = CMD_START_MEASUREMENTS;
686+
break;
685687
default:
686688
cmd = SEN60_CMD_START_MEASUREMENTS;
687689
break;
@@ -802,7 +804,7 @@ bool SEN5XComponent::is_sen6x_() {
802804
return false;
803805
}
804806
}
805-
const char *SEN5XComponent::model_to_str(Sen5xType model) {
807+
const char *SEN5XComponent::model_to_str_(Sen5xType model) {
806808
switch (model) {
807809
case SEN50:
808810
return "SEN50";
@@ -825,7 +827,7 @@ const char *SEN5XComponent::model_to_str(Sen5xType model) {
825827
}
826828
}
827829

828-
Sen5xType SEN5XComponent::str_to_model(const char *product_name) {
830+
Sen5xType SEN5XComponent::str_to_model_(const char *product_name) {
829831
if (strcmp(product_name, "SEN50") == 0) {
830832
return SEN50;
831833
} else if (strcmp(product_name, "SEN54") == 0) {

components/sen5x/sen5x.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ enum Sen5xType { SEN50, SEN54, SEN55, SEN60, SEN63C, SEN65, SEN66, SEN68, UNKNOW
3434
enum RhtAccelerationMode : uint16_t {
3535
LOW_ACCELERATION = 0,
3636
MEDIUM_ACCELERATION = 1,
37-
HIGH_ACCELERATION = 2,
38-
UNKNOWN_ACCELERATION = 100
37+
HIGH_ACCELERATION = 2
3938
};
4039

4140
struct GasTuning {
@@ -123,8 +122,8 @@ class SEN5XComponent : public PollingComponent, public sensirion_common::Sensiri
123122
bool write_tuning_parameters_(uint16_t i2c_command, const GasTuning &tuning);
124123
bool write_temperature_compensation_(const TemperatureCompensation &compensation);
125124
bool update_co2_ambient_pressure_compensation_(uint16_t pressure_in_hpa);
126-
const char *model_to_str(Sen5xType model);
127-
Sen5xType str_to_model(const char *product_name);
125+
const char *model_to_str_(Sen5xType model);
126+
Sen5xType str_to_model_(const char *product_name);
128127
ERRORCODE error_code_;
129128
bool initialized_{false};
130129
bool running_{false};

0 commit comments

Comments
 (0)