mirror of
https://github.com/esphome/esphome.git
synced 2025-03-13 22:28:14 +00:00
ESP8266 Connection Fixes
This commit is contained in:
parent
2642750466
commit
f05449f544
@ -712,12 +712,12 @@ bool APIConnection::send_buffer(APIMessageType type) {
|
||||
size_t needed_space = this->send_buffer_.size() + header_len;
|
||||
|
||||
if (needed_space > this->client_->space()) {
|
||||
delay(5);
|
||||
delay(0);
|
||||
if (needed_space > this->client_->space()) {
|
||||
if (type != APIMessageType::SUBSCRIBE_LOGS_RESPONSE) {
|
||||
ESP_LOGV(TAG, "Cannot send message because of TCP buffer space");
|
||||
}
|
||||
delay(5);
|
||||
delay(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -360,11 +360,11 @@ bool MQTTClientComponent::publish(const std::string &topic, const char *payload,
|
||||
}
|
||||
bool logging_topic = topic == this->log_message_.topic;
|
||||
uint16_t ret = this->mqtt_client_.publish(topic.c_str(), qos, retain, payload, payload_length);
|
||||
yield();
|
||||
delay(0);
|
||||
if (ret == 0 && !logging_topic && this->is_connected()) {
|
||||
delay(5);
|
||||
delay(0);
|
||||
ret = this->mqtt_client_.publish(topic.c_str(), qos, retain, payload, payload_length);
|
||||
yield();
|
||||
delay(0);
|
||||
}
|
||||
|
||||
if (!logging_topic) {
|
||||
|
@ -421,6 +421,7 @@ void WiFiComponent::check_connecting_finished() {
|
||||
}
|
||||
|
||||
void WiFiComponent::retry_connect() {
|
||||
delay(10);
|
||||
if (this->num_retried_ > 5 || this->error_from_callback_) {
|
||||
// If retry failed for more than 5 times, let's restart STA
|
||||
ESP_LOGW(TAG, "Restarting WiFi adapter...");
|
||||
|
@ -330,7 +330,6 @@ const char *get_disconnect_reason_str(uint8_t reason) {
|
||||
}
|
||||
|
||||
void WiFiComponent::wifi_event_callback(System_Event_t *event) {
|
||||
#ifdef ESPHOME_LOG_HAS_VERBOSE
|
||||
// TODO: this callback is called while in cont context, so delay will fail
|
||||
// We need to defer the log messages until we're out of this context
|
||||
// only affects verbose log level
|
||||
@ -351,7 +350,7 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) {
|
||||
char buf[33];
|
||||
memcpy(buf, it.ssid, it.ssid_len);
|
||||
buf[it.ssid_len] = '\0';
|
||||
ESP_LOGV(TAG, "Event: Disconnected ssid='%s' bssid=%s reason='%s'", buf, format_mac_addr(it.bssid).c_str(),
|
||||
ESP_LOGW(TAG, "Event: Disconnected ssid='%s' bssid=%s reason='%s'", buf, format_mac_addr(it.bssid).c_str(),
|
||||
get_disconnect_reason_str(it.reason));
|
||||
break;
|
||||
}
|
||||
@ -403,7 +402,6 @@ void WiFiComponent::wifi_event_callback(System_Event_t *event) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (event->event == EVENT_STAMODE_DISCONNECTED) {
|
||||
global_wifi_component->error_from_callback_ = true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user