mirror of
https://github.com/esphome/esphome.git
synced 2025-07-30 07:06:38 +00:00
[api] Streamline some log strings (#8962)
This commit is contained in:
parent
8054c9b4f5
commit
4f87bea788
@ -118,7 +118,7 @@ void APIConnection::loop() {
|
|||||||
// when network is disconnected force disconnect immediately
|
// when network is disconnected force disconnect immediately
|
||||||
// don't wait for timeout
|
// don't wait for timeout
|
||||||
this->on_fatal_error();
|
this->on_fatal_error();
|
||||||
ESP_LOGW(TAG, "%s: Network unavailable, disconnecting", this->client_combined_info_.c_str());
|
ESP_LOGW(TAG, "%s: Network unavailable; disconnecting", this->client_combined_info_.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this->next_close_) {
|
if (this->next_close_) {
|
||||||
@ -182,24 +182,23 @@ void APIConnection::loop() {
|
|||||||
// Disconnect if not responded within 2.5*keepalive
|
// Disconnect if not responded within 2.5*keepalive
|
||||||
if (now - this->last_traffic_ > (KEEPALIVE_TIMEOUT_MS * 5) / 2) {
|
if (now - this->last_traffic_ > (KEEPALIVE_TIMEOUT_MS * 5) / 2) {
|
||||||
on_fatal_error();
|
on_fatal_error();
|
||||||
ESP_LOGW(TAG, "%s didn't respond to ping request in time. Disconnecting...", this->client_combined_info_.c_str());
|
ESP_LOGW(TAG, "%s is unresponsive; disconnecting", this->client_combined_info_.c_str());
|
||||||
}
|
}
|
||||||
} else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS && now > this->next_ping_retry_) {
|
} else if (now - this->last_traffic_ > KEEPALIVE_TIMEOUT_MS && now > this->next_ping_retry_) {
|
||||||
ESP_LOGVV(TAG, "Sending keepalive PING...");
|
ESP_LOGVV(TAG, "Sending keepalive PING");
|
||||||
this->sent_ping_ = this->send_ping_request(PingRequest());
|
this->sent_ping_ = this->send_ping_request(PingRequest());
|
||||||
if (!this->sent_ping_) {
|
if (!this->sent_ping_) {
|
||||||
|
char warn_str[38];
|
||||||
this->next_ping_retry_ = now + ping_retry_interval;
|
this->next_ping_retry_ = now + ping_retry_interval;
|
||||||
this->ping_retries_++;
|
this->ping_retries_++;
|
||||||
|
sprintf(warn_str, "Sending keepalive failed %u time(s); ", this->ping_retries_);
|
||||||
if (this->ping_retries_ >= max_ping_retries) {
|
if (this->ping_retries_ >= max_ping_retries) {
|
||||||
on_fatal_error();
|
on_fatal_error();
|
||||||
ESP_LOGE(TAG, "%s: Sending keepalive failed %d time(s). Disconnecting...", this->client_combined_info_.c_str(),
|
ESP_LOGE(TAG, "%s: %sdisconnecting", this->client_combined_info_.c_str(), warn_str);
|
||||||
this->ping_retries_);
|
|
||||||
} else if (this->ping_retries_ >= 10) {
|
} else if (this->ping_retries_ >= 10) {
|
||||||
ESP_LOGW(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
ESP_LOGW(TAG, "%s: %sretrying in %u ms", this->client_combined_info_.c_str(), warn_str, ping_retry_interval);
|
||||||
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
|
||||||
} else {
|
} else {
|
||||||
ESP_LOGD(TAG, "%s: Sending keepalive failed %d time(s), will retry in %d ms",
|
ESP_LOGD(TAG, "%s: %sretrying in %u ms", this->client_combined_info_.c_str(), warn_str, ping_retry_interval);
|
||||||
this->client_combined_info_.c_str(), this->ping_retries_, ping_retry_interval);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -270,7 +269,7 @@ DisconnectResponse APIConnection::disconnect(const DisconnectRequest &msg) {
|
|||||||
// remote initiated disconnect_client
|
// remote initiated disconnect_client
|
||||||
// don't close yet, we still need to send the disconnect response
|
// don't close yet, we still need to send the disconnect response
|
||||||
// close will happen on next loop
|
// close will happen on next loop
|
||||||
ESP_LOGD(TAG, "%s requested disconnected", this->client_combined_info_.c_str());
|
ESP_LOGD(TAG, "%s disconnected", this->client_combined_info_.c_str());
|
||||||
this->next_close_ = true;
|
this->next_close_ = true;
|
||||||
DisconnectResponse resp;
|
DisconnectResponse resp;
|
||||||
return resp;
|
return resp;
|
||||||
@ -1472,7 +1471,7 @@ void APIConnection::update_command(const UpdateCommandRequest &msg) {
|
|||||||
update->check();
|
update->check();
|
||||||
break;
|
break;
|
||||||
case enums::UPDATE_COMMAND_NONE:
|
case enums::UPDATE_COMMAND_NONE:
|
||||||
ESP_LOGE(TAG, "UPDATE_COMMAND_NONE not handled. Check client is sending the correct command");
|
ESP_LOGE(TAG, "UPDATE_COMMAND_NONE not handled; confirm command is correct");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ESP_LOGW(TAG, "Unknown update command: %" PRIu32, msg.command);
|
ESP_LOGW(TAG, "Unknown update command: %" PRIu32, msg.command);
|
||||||
@ -1534,7 +1533,7 @@ ConnectResponse APIConnection::connect(const ConnectRequest &msg) {
|
|||||||
// bool invalid_password = 1;
|
// bool invalid_password = 1;
|
||||||
resp.invalid_password = !correct;
|
resp.invalid_password = !correct;
|
||||||
if (correct) {
|
if (correct) {
|
||||||
ESP_LOGD(TAG, "%s: Connected successfully", this->client_combined_info_.c_str());
|
ESP_LOGD(TAG, "%s connected", this->client_combined_info_.c_str());
|
||||||
this->connection_state_ = ConnectionState::AUTHENTICATED;
|
this->connection_state_ = ConnectionState::AUTHENTICATED;
|
||||||
this->parent_->get_client_connected_trigger()->trigger(this->client_info_, this->client_peername_);
|
this->parent_->get_client_connected_trigger()->trigger(this->client_info_, this->client_peername_);
|
||||||
#ifdef USE_HOMEASSISTANT_TIME
|
#ifdef USE_HOMEASSISTANT_TIME
|
||||||
@ -1605,7 +1604,7 @@ void APIConnection::execute_service(const ExecuteServiceRequest &msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found) {
|
||||||
ESP_LOGV(TAG, "Could not find matching service!");
|
ESP_LOGV(TAG, "Could not find service");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef USE_API_NOISE
|
#ifdef USE_API_NOISE
|
||||||
@ -1674,11 +1673,11 @@ bool APIConnection::send_buffer(ProtoWriteBuffer buffer, uint32_t message_type)
|
|||||||
}
|
}
|
||||||
void APIConnection::on_unauthenticated_access() {
|
void APIConnection::on_unauthenticated_access() {
|
||||||
this->on_fatal_error();
|
this->on_fatal_error();
|
||||||
ESP_LOGD(TAG, "%s: tried to access without authentication.", this->client_combined_info_.c_str());
|
ESP_LOGD(TAG, "%s requested access without authentication", this->client_combined_info_.c_str());
|
||||||
}
|
}
|
||||||
void APIConnection::on_no_setup_connection() {
|
void APIConnection::on_no_setup_connection() {
|
||||||
this->on_fatal_error();
|
this->on_fatal_error();
|
||||||
ESP_LOGD(TAG, "%s: tried to access without full connection.", this->client_combined_info_.c_str());
|
ESP_LOGD(TAG, "%s requested access without full connection", this->client_combined_info_.c_str());
|
||||||
}
|
}
|
||||||
void APIConnection::on_fatal_error() {
|
void APIConnection::on_fatal_error() {
|
||||||
this->helper_->close();
|
this->helper_->close();
|
||||||
|
@ -780,7 +780,7 @@ extern "C" {
|
|||||||
// declare how noise generates random bytes (here with a good HWRNG based on the RF system)
|
// declare how noise generates random bytes (here with a good HWRNG based on the RF system)
|
||||||
void noise_rand_bytes(void *output, size_t len) {
|
void noise_rand_bytes(void *output, size_t len) {
|
||||||
if (!esphome::random_bytes(reinterpret_cast<uint8_t *>(output), len)) {
|
if (!esphome::random_bytes(reinterpret_cast<uint8_t *>(output), len)) {
|
||||||
ESP_LOGE(TAG, "Failed to acquire random bytes, rebooting!");
|
ESP_LOGE(TAG, "Acquiring random bytes failed; rebooting");
|
||||||
arch_restart();
|
arch_restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user