1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-02 19:32:19 +01:00
This commit is contained in:
J. Nick Koston
2025-08-20 11:38:07 -05:00
parent 998a9264a1
commit c88f2eb4d1

View File

@@ -47,14 +47,11 @@ void PVVXDisplay::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t
this->connection_established_ = true;
this->char_handle_ = chr->handle;
// Check if already paired - if not, writes will be deferred to next update cycle
if (this->parent_->is_paired()) {
ESP_LOGD(TAG, "[%s] Device is paired, writing immediately.", this->parent_->address_str().c_str());
this->sync_time_and_display_();
} else {
ESP_LOGD(TAG, "[%s] Device not paired yet, deferring writes until authentication completes.",
this->parent_->address_str().c_str());
}
// Attempt to write immediately
// For devices without security, this will work
// For devices with security that are already paired, this will work
// For devices that need pairing, the write will be retried after auth completes
this->sync_time_and_display_();
break;
}
default:
@@ -106,11 +103,6 @@ void PVVXDisplay::display() {
this->parent_->address_str().c_str());
return;
}
// Check if authentication is required and not complete
if (!this->parent_->is_paired()) {
ESP_LOGD(TAG, "[%s] Waiting for pairing to complete before writing.", this->parent_->address_str().c_str());
return;
}
ESP_LOGD(TAG, "[%s] Send to display: bignum %d, smallnum: %d, cfg: 0x%02x, validity period: %u.",
this->parent_->address_str().c_str(), this->bignum_, this->smallnum_, this->cfg_, this->validity_period_);
uint8_t blk[8] = {};
@@ -139,10 +131,6 @@ void PVVXDisplay::send_to_setup_char_(uint8_t *blk, size_t size) {
ESP_LOGW(TAG, "[%s] Not connected to BLE client.", this->parent_->address_str().c_str());
return;
}
if (!this->parent_->is_paired()) {
ESP_LOGW(TAG, "[%s] Cannot write - authentication not complete.", this->parent_->address_str().c_str());
return;
}
auto status =
esp_ble_gattc_write_char(this->parent_->get_gattc_if(), this->parent_->get_conn_id(), this->char_handle_, size,
blk, ESP_GATT_WRITE_TYPE_NO_RSP, ESP_GATT_AUTH_REQ_NONE);