[core] Add no-arg status_set_warning() overload, use LOG_STR for static strings

Add a separate no-argument status_set_warning() that delegates to the
LogString* overload, matching the existing status_set_error() pattern.
This allows the linker to garbage-collect the const char* overload in
firmware that only uses no-arg or LOG_STR() calls.

Migrate static string literal callers to LOG_STR() so the const char*
overload can be eliminated in most builds.
This commit is contained in:
J. Nick Koston
2026-03-14 16:42:54 -10:00
parent f12531e7e0
commit 159485f8a9
5 changed files with 8 additions and 6 deletions
+3 -3
View File
@@ -68,7 +68,7 @@ void RX8130Component::dump_config() {
void RX8130Component::read_time() {
uint8_t date[7];
if (this->read_register(RX8130_REG_SEC, date, 7) != i2c::ERROR_OK) {
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
return;
}
ESPTime rtc_time{
@@ -109,7 +109,7 @@ void RX8130Component::write_time() {
buff[6] = dec2bcd(now.year % 100);
this->stop_(true);
if (this->write_register(RX8130_REG_SEC, buff, 7) != i2c::ERROR_OK) {
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
} else {
ESP_LOGD(TAG, "Wrote UTC time: %04d-%02d-%02d %02d:%02d:%02d", now.year, now.month, now.day_of_month, now.hour,
now.minute, now.second);
@@ -120,7 +120,7 @@ void RX8130Component::write_time() {
void RX8130Component::stop_(bool stop) {
const uint8_t data = stop ? RX8130_BIT_CTRL_STOP : RX8130_CLEAR_FLAGS;
if (this->write_register(RX8130_REG_CTRL0, &data, 1) != i2c::ERROR_OK) {
this->status_set_warning(ESP_LOG_MSG_COMM_FAIL);
this->status_set_warning(LOG_STR(ESP_LOG_MSG_COMM_FAIL));
}
}
+1 -1
View File
@@ -416,7 +416,7 @@ void USBUartTypeCdcAcm::on_connected() {
for (auto *channel : this->channels_) {
if (i == cdc_devs.size()) {
ESP_LOGE(TAG, "No configuration found for channel %d", channel->index_);
this->status_set_warning("No configuration found for channel");
this->status_set_warning(LOG_STR("No configuration found for channel"));
break;
}
channel->cdc_dev_ = cdc_devs[i++];
@@ -90,7 +90,7 @@ void ZWaveProxy::process_uart_() {
while (this->available()) {
uint8_t byte;
if (!this->read_byte(&byte)) {
this->status_set_warning("UART read failed");
this->status_set_warning(LOG_STR("UART read failed"));
return;
}
if (this->parse_byte_(byte)) {
+1
View File
@@ -392,6 +392,7 @@ bool Component::set_status_flag_(uint8_t flag) {
return true;
}
void Component::status_set_warning() { this->status_set_warning((const LogString *) nullptr); }
void Component::status_set_warning(const char *message) {
if (!this->set_status_flag_(STATUS_LED_WARNING))
return;
+2 -1
View File
@@ -240,7 +240,8 @@ class Component {
bool status_has_error() const { return this->component_state_ & STATUS_LED_ERROR; }
void status_set_warning(const char *message = nullptr);
void status_set_warning(); // Set warning flag without message
void status_set_warning(const char *message);
void status_set_warning(const LogString *message);
void status_set_error(); // Set error flag without message