[sps30] Shorten log messages (#8971)

This commit is contained in:
Keith Burzinski 2025-06-03 15:50:22 -05:00 committed by GitHub
parent b39a9924d8
commit 935e0a365f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -113,18 +113,18 @@ void SPS30Component::dump_config() {
void SPS30Component::update() { void SPS30Component::update() {
/// Check if warning flag active (sensor reconnected?) /// Check if warning flag active (sensor reconnected?)
if (this->status_has_warning()) { if (this->status_has_warning()) {
ESP_LOGD(TAG, "Trying to reconnect the sensor..."); ESP_LOGD(TAG, "Trying to reconnect");
if (this->write_command(SPS30_CMD_SOFT_RESET)) { if (this->write_command(SPS30_CMD_SOFT_RESET)) {
ESP_LOGD(TAG, "Sensor has soft-reset successfully. Waiting for reconnection in 500ms..."); ESP_LOGD(TAG, "Soft-reset successful. Waiting for reconnection in 500 ms");
this->set_timeout(500, [this]() { this->set_timeout(500, [this]() {
this->start_continuous_measurement_(); this->start_continuous_measurement_();
/// Sensor restarted and reading attempt made next cycle /// Sensor restarted and reading attempt made next cycle
this->status_clear_warning(); this->status_clear_warning();
this->skipped_data_read_cycles_ = 0; this->skipped_data_read_cycles_ = 0;
ESP_LOGD(TAG, "Sensor reconnected successfully. Resuming continuous measurement!"); ESP_LOGD(TAG, "Reconnect successful. Resuming continuous measurement");
}); });
} else { } else {
ESP_LOGD(TAG, "Sensor soft-reset failed. Is the sensor offline?"); ESP_LOGD(TAG, "Soft-reset failed");
} }
return; return;
} }
@ -136,19 +136,19 @@ void SPS30Component::update() {
uint16_t raw_read_status; uint16_t raw_read_status;
if (!this->read_data(&raw_read_status, 1) || raw_read_status == 0x00) { if (!this->read_data(&raw_read_status, 1) || raw_read_status == 0x00) {
ESP_LOGD(TAG, "Sensor measurement not ready yet."); ESP_LOGD(TAG, "Not ready yet");
this->skipped_data_read_cycles_++; this->skipped_data_read_cycles_++;
/// The following logic is required to address the cases when a sensor is quickly replaced before it's marked /// The following logic is required to address the cases when a sensor is quickly replaced before it's marked
/// as failed so that new sensor is eventually forced to be reinitialized for continuous measurement. /// as failed so that new sensor is eventually forced to be reinitialized for continuous measurement.
if (this->skipped_data_read_cycles_ > MAX_SKIPPED_DATA_CYCLES_BEFORE_ERROR) { if (this->skipped_data_read_cycles_ > MAX_SKIPPED_DATA_CYCLES_BEFORE_ERROR) {
ESP_LOGD(TAG, "Sensor exceeded max allowed attempts. Sensor communication will be reinitialized."); ESP_LOGD(TAG, "Exceeded max allowed attempts; communication will be reinitialized");
this->status_set_warning(); this->status_set_warning();
} }
return; return;
} }
if (!this->write_command(SPS30_CMD_READ_MEASUREMENT)) { if (!this->write_command(SPS30_CMD_READ_MEASUREMENT)) {
ESP_LOGW(TAG, "Error reading measurement status!"); ESP_LOGW(TAG, "Error reading status");
this->status_set_warning(); this->status_set_warning();
return; return;
} }
@ -156,7 +156,7 @@ void SPS30Component::update() {
this->set_timeout(50, [this]() { this->set_timeout(50, [this]() {
uint16_t raw_data[20]; uint16_t raw_data[20];
if (!this->read_data(raw_data, 20)) { if (!this->read_data(raw_data, 20)) {
ESP_LOGW(TAG, "Error reading measurement data!"); ESP_LOGW(TAG, "Error reading data");
this->status_set_warning(); this->status_set_warning();
return; return;
} }