1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-26 14:58:16 +00:00

Merge pull request #8326 from esphome/bump-2025.2.1

2025.2.1
This commit is contained in:
Jesse Hills 2025-02-26 11:01:14 +13:00 committed by GitHub
commit c13174c318
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 4784 additions and 4638 deletions

View File

@ -123,12 +123,49 @@ void BLEClientBase::connect() {
esp_err_t BLEClientBase::pair() { return esp_ble_set_encryption(this->remote_bda_, ESP_BLE_SEC_ENCRYPT); } esp_err_t BLEClientBase::pair() { return esp_ble_set_encryption(this->remote_bda_, ESP_BLE_SEC_ENCRYPT); }
void BLEClientBase::disconnect() { void BLEClientBase::disconnect() {
if (this->state_ == espbt::ClientState::IDLE || this->state_ == espbt::ClientState::DISCONNECTING) if (this->state_ == espbt::ClientState::IDLE) {
ESP_LOGI(TAG, "[%d] [%s] Disconnect requested, but already idle.", this->connection_index_,
this->address_str_.c_str());
return; return;
ESP_LOGI(TAG, "[%d] [%s] Disconnecting.", this->connection_index_, this->address_str_.c_str()); }
if (this->state_ == espbt::ClientState::DISCONNECTING) {
ESP_LOGI(TAG, "[%d] [%s] Disconnect requested, but already disconnecting.", this->connection_index_,
this->address_str_.c_str());
return;
}
if (this->state_ == espbt::ClientState::CONNECTING || this->conn_id_ == UNSET_CONN_ID) {
ESP_LOGW(TAG, "[%d] [%s] Disconnecting before connected, disconnect scheduled.", this->connection_index_,
this->address_str_.c_str());
this->want_disconnect_ = true;
return;
}
this->unconditional_disconnect();
}
void BLEClientBase::unconditional_disconnect() {
// Disconnect without checking the state.
ESP_LOGI(TAG, "[%d] [%s] Disconnecting (conn_id: %d).", this->connection_index_, this->address_str_.c_str(),
this->conn_id_);
if (this->state_ == espbt::ClientState::DISCONNECTING) {
ESP_LOGE(TAG, "[%d] [%s] Tried to disconnect while already disconnecting.", this->connection_index_,
this->address_str_.c_str());
return;
}
if (this->conn_id_ == UNSET_CONN_ID) {
ESP_LOGE(TAG, "[%d] [%s] No connection ID set, cannot disconnect.", this->connection_index_,
this->address_str_.c_str());
return;
}
auto err = esp_ble_gattc_close(this->gattc_if_, this->conn_id_); auto err = esp_ble_gattc_close(this->gattc_if_, this->conn_id_);
if (err != ESP_OK) { if (err != ESP_OK) {
ESP_LOGW(TAG, "[%d] [%s] esp_ble_gattc_close error, err=%d", this->connection_index_, this->address_str_.c_str(), //
// This is a fatal error, but we can't do anything about it
// and it likely means the BLE stack is in a bad state.
//
// In the future we might consider App.reboot() here since
// the BLE stack is in an indeterminate state.
//
ESP_LOGE(TAG, "[%d] [%s] esp_ble_gattc_close error, err=%d", this->connection_index_, this->address_str_.c_str(),
err); err);
} }
@ -184,12 +221,38 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
this->log_event_("ESP_GATTC_OPEN_EVT"); this->log_event_("ESP_GATTC_OPEN_EVT");
this->conn_id_ = param->open.conn_id; this->conn_id_ = param->open.conn_id;
this->service_count_ = 0; this->service_count_ = 0;
if (this->state_ != espbt::ClientState::CONNECTING) {
// This should not happen but lets log it in case it does
// because it means we have a bad assumption about how the
// ESP BT stack works.
if (this->state_ == espbt::ClientState::CONNECTED) {
ESP_LOGE(TAG, "[%d] [%s] Got ESP_GATTC_OPEN_EVT while already connected, status=%d", this->connection_index_,
this->address_str_.c_str(), param->open.status);
} else if (this->state_ == espbt::ClientState::ESTABLISHED) {
ESP_LOGE(TAG, "[%d] [%s] Got ESP_GATTC_OPEN_EVT while already established, status=%d",
this->connection_index_, this->address_str_.c_str(), param->open.status);
} else if (this->state_ == espbt::ClientState::DISCONNECTING) {
ESP_LOGE(TAG, "[%d] [%s] Got ESP_GATTC_OPEN_EVT while disconnecting, status=%d", this->connection_index_,
this->address_str_.c_str(), param->open.status);
} else {
ESP_LOGE(TAG, "[%d] [%s] Got ESP_GATTC_OPEN_EVT while not in connecting state, status=%d",
this->connection_index_, this->address_str_.c_str(), param->open.status);
}
}
if (param->open.status != ESP_GATT_OK && param->open.status != ESP_GATT_ALREADY_OPEN) { if (param->open.status != ESP_GATT_OK && param->open.status != ESP_GATT_ALREADY_OPEN) {
ESP_LOGW(TAG, "[%d] [%s] Connection failed, status=%d", this->connection_index_, this->address_str_.c_str(), ESP_LOGW(TAG, "[%d] [%s] Connection failed, status=%d", this->connection_index_, this->address_str_.c_str(),
param->open.status); param->open.status);
this->set_state(espbt::ClientState::IDLE); this->set_state(espbt::ClientState::IDLE);
break; break;
} }
if (this->want_disconnect_) {
// Disconnect was requested after connecting started,
// but before the connection was established. Now that we have
// this->conn_id_ set, we can disconnect it.
this->unconditional_disconnect();
this->conn_id_ = UNSET_CONN_ID;
break;
}
auto ret = esp_ble_gattc_send_mtu_req(this->gattc_if_, param->open.conn_id); auto ret = esp_ble_gattc_send_mtu_req(this->gattc_if_, param->open.conn_id);
if (ret) { if (ret) {
ESP_LOGW(TAG, "[%d] [%s] esp_ble_gattc_send_mtu_req failed, status=%x", this->connection_index_, ESP_LOGW(TAG, "[%d] [%s] esp_ble_gattc_send_mtu_req failed, status=%x", this->connection_index_,
@ -241,6 +304,7 @@ bool BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_
this->log_event_("ESP_GATTC_CLOSE_EVT"); this->log_event_("ESP_GATTC_CLOSE_EVT");
this->release_services(); this->release_services();
this->set_state(espbt::ClientState::IDLE); this->set_state(espbt::ClientState::IDLE);
this->conn_id_ = UNSET_CONN_ID;
break; break;
} }
case ESP_GATTC_SEARCH_RES_EVT: { case ESP_GATTC_SEARCH_RES_EVT: {

View File

@ -21,6 +21,8 @@ namespace esp32_ble_client {
namespace espbt = esphome::esp32_ble_tracker; namespace espbt = esphome::esp32_ble_tracker;
static const int UNSET_CONN_ID = 0xFFFF;
class BLEClientBase : public espbt::ESPBTClient, public Component { class BLEClientBase : public espbt::ESPBTClient, public Component {
public: public:
void setup() override; void setup() override;
@ -37,6 +39,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component {
void connect() override; void connect() override;
esp_err_t pair(); esp_err_t pair();
void disconnect() override; void disconnect() override;
void unconditional_disconnect();
void release_services(); void release_services();
bool connected() { return this->state_ == espbt::ClientState::ESTABLISHED; } bool connected() { return this->state_ == espbt::ClientState::ESTABLISHED; }
@ -94,7 +97,7 @@ class BLEClientBase : public espbt::ESPBTClient, public Component {
int gattc_if_; int gattc_if_;
esp_bd_addr_t remote_bda_; esp_bd_addr_t remote_bda_;
esp_ble_addr_type_t remote_addr_type_{BLE_ADDR_TYPE_PUBLIC}; esp_ble_addr_type_t remote_addr_type_{BLE_ADDR_TYPE_PUBLIC};
uint16_t conn_id_{0xFFFF}; uint16_t conn_id_{UNSET_CONN_ID};
uint64_t address_{0}; uint64_t address_{0};
bool auto_connect_{false}; bool auto_connect_{false};
std::string address_str_{}; std::string address_str_{};

View File

@ -238,6 +238,12 @@ async def to_code(config):
else: else:
add_idf_sdkconfig_option("CONFIG_BTU_TASK_STACK_SIZE", 8192) add_idf_sdkconfig_option("CONFIG_BTU_TASK_STACK_SIZE", 8192)
add_idf_sdkconfig_option("CONFIG_BT_ACL_CONNECTIONS", 9) add_idf_sdkconfig_option("CONFIG_BT_ACL_CONNECTIONS", 9)
# CONFIG_BT_GATTC_NOTIF_REG_MAX controls the number of
# max notifications in 5.x, setting CONFIG_BT_ACL_CONNECTIONS
# is enough in 4.x
# https://github.com/esphome/issues/issues/6808
if CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION] >= cv.Version(5, 0, 0):
add_idf_sdkconfig_option("CONFIG_BT_GATTC_NOTIF_REG_MAX", 9)
cg.add_define("USE_OTA_STATE_CALLBACK") # To be notified when an OTA update starts cg.add_define("USE_OTA_STATE_CALLBACK") # To be notified when an OTA update starts
cg.add_define("USE_ESP32_BLE_CLIENT") cg.add_define("USE_ESP32_BLE_CLIENT")

View File

@ -173,12 +173,22 @@ class ESPBTClient : public ESPBTDeviceListener {
virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0; virtual void gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) = 0;
virtual void connect() = 0; virtual void connect() = 0;
virtual void disconnect() = 0; virtual void disconnect() = 0;
virtual void set_state(ClientState st) { this->state_ = st; } virtual void set_state(ClientState st) {
this->state_ = st;
if (st == ClientState::IDLE) {
this->want_disconnect_ = false;
}
}
ClientState state() const { return state_; } ClientState state() const { return state_; }
int app_id; int app_id;
protected: protected:
ClientState state_{ClientState::INIT}; ClientState state_{ClientState::INIT};
// want_disconnect_ is set to true when a disconnect is requested
// while the client is connecting. This is used to disconnect the
// client as soon as we get the connection id (conn_id_) from the
// ESP_GATTC_OPEN_EVT event.
bool want_disconnect_{false};
}; };
class ESP32BLETracker : public Component, class ESP32BLETracker : public Component,

View File

@ -52,7 +52,7 @@ void ESP32TouchComponent::setup() {
} }
#endif #endif
#if ESP_IDF_VERSION_MAJOR >= 5 #if ESP_IDF_VERSION_MAJOR >= 5 && defined(USE_ESP32_VARIANT_ESP32)
touch_pad_set_measurement_clock_cycles(this->meas_cycle_); touch_pad_set_measurement_clock_cycles(this->meas_cycle_);
touch_pad_set_measurement_interval(this->sleep_cycle_); touch_pad_set_measurement_interval(this->sleep_cycle_);
#else #else

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
"""Constants used by esphome.""" """Constants used by esphome."""
__version__ = "2025.2.0" __version__ = "2025.2.1"
ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_" ALLOWED_NAME_CHARS = "abcdefghijklmnopqrstuvwxyz0123456789-_"
VALID_SUBSTITUTIONS_CHARACTERS = ( VALID_SUBSTITUTIONS_CHARACTERS = (

View File

@ -13,7 +13,7 @@ platformio==6.1.16 # When updating platformio, also update Dockerfile
esptool==4.7.0 esptool==4.7.0
click==8.1.7 click==8.1.7
esphome-dashboard==20250212.0 esphome-dashboard==20250212.0
aioesphomeapi==29.1.0 aioesphomeapi==29.1.1
zeroconf==0.145.1 zeroconf==0.145.1
puremagic==1.27 puremagic==1.27
ruamel.yaml==0.18.6 # dashboard_import ruamel.yaml==0.18.6 # dashboard_import

View File

@ -0,0 +1,15 @@
esp32_touch:
setup_mode: false
sleep_duration: 27ms
measurement_duration: 8ms
low_voltage_reference: 0.5V
high_voltage_reference: 2.7V
voltage_attenuation: 1.5V
binary_sensor:
- platform: esp32_touch
name: ESP32 Touch Pad
pin: ${pin}
threshold: 1000
on_press:
- logger.log: "I'm touched!"

View File

@ -10,7 +10,7 @@ esp32_touch:
binary_sensor: binary_sensor:
- platform: esp32_touch - platform: esp32_touch
name: ESP32 Touch Pad name: ESP32 Touch Pad
pin: 27 pin: ${pin}
threshold: 1000 threshold: 1000
on_press: on_press:
- logger.log: "I'm touched!" - logger.log: "I'm touched!"

View File

@ -1 +1,4 @@
substitutions:
pin: GPIO27
<<: !include common.yaml <<: !include common.yaml

View File

@ -1 +1,4 @@
substitutions:
pin: GPIO27
<<: !include common.yaml <<: !include common.yaml

View File

@ -0,0 +1,4 @@
substitutions:
pin: GPIO12
<<: !include common-variants.yaml

View File

@ -0,0 +1,4 @@
substitutions:
pin: GPIO12
<<: !include common-variants.yaml

View File

@ -0,0 +1,4 @@
substitutions:
pin: GPIO12
<<: !include common-variants.yaml

View File

@ -0,0 +1,4 @@
substitutions:
pin: GPIO12
<<: !include common-variants.yaml