Skip to content

Commit 39dad19

Browse files
authored
Merge pull request #59 from gurrier/codex/fix-compilation-errors-for-esphome-2025.12
Fix Powerpal BLE logs for ESPHome 2025.12 address change
2 parents 6e38f69 + 4b4b2cd commit 39dad19

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

components/powerpal_ble/powerpal_ble.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void Powerpal::reset_connection_state_() {
4343
}
4444

4545
void Powerpal::on_connect() {
46-
ESP_LOGI(TAG, "[%s] Connected to Powerpal GATT server", this->parent_->address_str().c_str());
46+
ESP_LOGI(TAG, "[%s] Connected to Powerpal GATT server", this->parent_->address_str());
4747
this->client_connected_ = true;
4848
this->pending_subscription_ = true;
4949
this->subscription_in_progress_ = false;
@@ -58,7 +58,7 @@ void Powerpal::on_connect() {
5858
}
5959

6060
void Powerpal::on_disconnect() {
61-
ESP_LOGW(TAG, "[%s] Disconnected from Powerpal GATT server", this->parent_->address_str().c_str());
61+
ESP_LOGW(TAG, "[%s] Disconnected from Powerpal GATT server", this->parent_->address_str());
6262
this->reset_connection_state_();
6363

6464
if (!this->reconnect_pending_) {
@@ -68,10 +68,10 @@ void Powerpal::on_disconnect() {
6868
if (this->parent_ == nullptr)
6969
return;
7070
if (this->client_connected_) {
71-
ESP_LOGD(TAG, "[%s] Reconnect timer fired but client already connected", this->parent_->address_str().c_str());
71+
ESP_LOGD(TAG, "[%s] Reconnect timer fired but client already connected", this->parent_->address_str());
7272
return;
7373
}
74-
ESP_LOGI(TAG, "[%s] Attempting BLE reconnect", this->parent_->address_str().c_str());
74+
ESP_LOGI(TAG, "[%s] Attempting BLE reconnect", this->parent_->address_str());
7575
this->pending_subscription_ = true;
7676
this->parent_->connect();
7777
});
@@ -349,12 +349,12 @@ void Powerpal::request_subscription_(const char *trigger_reason) {
349349
return;
350350

351351
if (this->subscription_in_progress_) {
352-
ESP_LOGV(TAG, "[%s] Subscription already in progress, ignoring trigger '%s'", this->parent_->address_str().c_str(), trigger_reason);
352+
ESP_LOGV(TAG, "[%s] Subscription already in progress, ignoring trigger '%s'", this->parent_->address_str(), trigger_reason);
353353
return;
354354
}
355355

356356
if (this->pairing_code_char_handle_ == 0 || this->reading_batch_size_char_handle_ == 0 || this->measurement_char_handle_ == 0) {
357-
ESP_LOGD(TAG, "[%s] GATT handles not ready, waiting to subscribe (%s)", this->parent_->address_str().c_str(), trigger_reason);
357+
ESP_LOGD(TAG, "[%s] GATT handles not ready, waiting to subscribe (%s)", this->parent_->address_str(), trigger_reason);
358358
if (!this->subscription_retry_scheduled_) {
359359
this->subscription_retry_scheduled_ = true;
360360
this->set_timeout(500, [this]() {
@@ -365,12 +365,12 @@ void Powerpal::request_subscription_(const char *trigger_reason) {
365365
return;
366366
}
367367

368-
ESP_LOGI(TAG, "[%s] Writing pairing code to resume notifications (%s)", this->parent_->address_str().c_str(), trigger_reason);
368+
ESP_LOGI(TAG, "[%s] Writing pairing code to resume notifications (%s)", this->parent_->address_str(), trigger_reason);
369369
auto status = esp_ble_gattc_write_char(this->parent()->get_gattc_if(), this->parent()->get_conn_id(),
370370
this->pairing_code_char_handle_, sizeof(this->pairing_code_),
371371
this->pairing_code_, ESP_GATT_WRITE_TYPE_RSP, ESP_GATT_AUTH_REQ_NONE);
372372
if (status != ESP_OK) {
373-
ESP_LOGW(TAG, "[%s] Failed to submit pairing write (%s), status=%d", this->parent_->address_str().c_str(), trigger_reason, status);
373+
ESP_LOGW(TAG, "[%s] Failed to submit pairing write (%s), status=%d", this->parent_->address_str(), trigger_reason, status);
374374
if (!this->subscription_retry_scheduled_) {
375375
this->subscription_retry_scheduled_ = true;
376376
this->set_timeout(2000, [this]() {
@@ -390,17 +390,17 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
390390
switch (event) {
391391
case ESP_GATTC_OPEN_EVT: {
392392
if (param->open.status == ESP_GATT_OK) {
393-
ESP_LOGD(TAG, "[%s] ESP_GATTC_OPEN_EVT", this->parent_->address_str().c_str());
393+
ESP_LOGD(TAG, "[%s] ESP_GATTC_OPEN_EVT", this->parent_->address_str());
394394
this->on_connect();
395395
} else {
396-
ESP_LOGW(TAG, "[%s] ESP_GATTC_OPEN_EVT failed, status=%d", this->parent_->address_str().c_str(),
396+
ESP_LOGW(TAG, "[%s] ESP_GATTC_OPEN_EVT failed, status=%d", this->parent_->address_str(),
397397
param->open.status);
398398
this->reset_connection_state_();
399399
}
400400
break;
401401
}
402402
case ESP_GATTC_DISCONNECT_EVT: {
403-
ESP_LOGW(TAG, "[%s] ESP_GATTC_DISCONNECT_EVT", this->parent_->address_str().c_str());
403+
ESP_LOGW(TAG, "[%s] ESP_GATTC_DISCONNECT_EVT", this->parent_->address_str());
404404
this->on_disconnect();
405405
break;
406406
}
@@ -446,7 +446,7 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
446446
break;
447447
}
448448
case ESP_GATTC_READ_CHAR_EVT: {
449-
ESP_LOGD(TAG, "[%s] ESP_GATTC_READ_CHAR_EVT (Received READ)", this->parent_->address_str().c_str());
449+
ESP_LOGD(TAG, "[%s] ESP_GATTC_READ_CHAR_EVT (Received READ)", this->parent_->address_str());
450450
if (param->read.status != ESP_GATT_OK) {
451451
ESP_LOGW(TAG, "Error reading char at handle %d, status=%d", param->read.handle, param->read.status);
452452
break;
@@ -471,7 +471,7 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
471471
this->measurement_char_handle_);
472472
if (status) {
473473
ESP_LOGW(TAG, "[%s] esp_ble_gattc_register_for_notify failed, status=%d",
474-
this->parent_->address_str().c_str(), status);
474+
this->parent_->address_str(), status);
475475
}
476476
}
477477
} else {
@@ -523,7 +523,7 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
523523
}
524524

525525
case ESP_GATTC_WRITE_CHAR_EVT: {
526-
ESP_LOGD(TAG, "[%s] ESP_GATTC_WRITE_CHAR_EVT (Write confirmed)", this->parent_->address_str().c_str());
526+
ESP_LOGD(TAG, "[%s] ESP_GATTC_WRITE_CHAR_EVT (Write confirmed)", this->parent_->address_str());
527527

528528
if (param->write.handle == this->pairing_code_char_handle_) {
529529
this->subscription_in_progress_ = false;
@@ -580,7 +580,7 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
580580
this->parent_->get_gattc_if(), this->parent_->get_remote_bda(), this->battery_char_handle_);
581581
if (notify_battery_status) {
582582
ESP_LOGW(TAG, "[%s] esp_ble_gattc_register_for_notify failed, status=%d",
583-
this->parent_->address_str().c_str(), notify_battery_status);
583+
this->parent_->address_str(), notify_battery_status);
584584
}
585585
}
586586

@@ -614,17 +614,17 @@ void Powerpal::gattc_event_handler(esp_gattc_cb_event_t event, esp_gatt_if_t gat
614614
this->measurement_char_handle_);
615615
if (status) {
616616
ESP_LOGW(TAG, "[%s] esp_ble_gattc_register_for_notify failed, status=%d",
617-
this->parent_->address_str().c_str(), status);
617+
this->parent_->address_str(), status);
618618
}
619619
break;
620620
}
621621

622622
ESP_LOGW(TAG, "[%s] Missed all handle matches: %d",
623-
this->parent_->address_str().c_str(), param->write.handle);
623+
this->parent_->address_str(), param->write.handle);
624624
break;
625625
} // ESP_GATTC_WRITE_CHAR_EVT
626626
case ESP_GATTC_NOTIFY_EVT: {
627-
ESP_LOGD(TAG, "[%s] Received Notification", this->parent_->address_str().c_str());
627+
ESP_LOGD(TAG, "[%s] Received Notification", this->parent_->address_str());
628628

629629
// battery
630630
if (param->notify.handle == this->battery_char_handle_) {
@@ -651,13 +651,13 @@ void Powerpal::gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_pa
651651
// This event is sent once authentication has completed
652652
case ESP_GAP_BLE_AUTH_CMPL_EVT: {
653653
if (param->ble_security.auth_cmpl.success) {
654-
ESP_LOGI(TAG, "[%s] Authentication completed", this->parent_->address_str().c_str());
654+
ESP_LOGI(TAG, "[%s] Authentication completed", this->parent_->address_str());
655655
this->pending_subscription_ = true;
656656
this->subscription_in_progress_ = false;
657657
this->subscription_retry_scheduled_ = false;
658658
this->request_subscription_("auth-complete");
659659
} else {
660-
ESP_LOGW(TAG, "[%s] Authentication failed, reason=0x%02x", this->parent_->address_str().c_str(),
660+
ESP_LOGW(TAG, "[%s] Authentication failed, reason=0x%02x", this->parent_->address_str(),
661661
param->ble_security.auth_cmpl.fail_reason);
662662
this->pending_subscription_ = false;
663663
this->subscription_in_progress_ = false;

0 commit comments

Comments
 (0)