1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-08 21:03:49 +01:00

[esp32_ble_server] Use early returns in is_created() and is_failed() methods (#11072)

This commit is contained in:
J. Nick Koston
2025-10-06 12:16:25 -05:00
committed by GitHub
parent f4df17673b
commit 42d1269aaf

View File

@@ -125,26 +125,26 @@ bool BLECharacteristic::is_created() {
if (this->state_ != CREATING_DEPENDENTS)
return false;
bool created = true;
for (auto *descriptor : this->descriptors_) {
created &= descriptor->is_created();
if (!descriptor->is_created())
return false;
}
if (created)
this->state_ = CREATED;
return this->state_ == CREATED;
// All descriptors are created if we reach here
this->state_ = CREATED;
return true;
}
bool BLECharacteristic::is_failed() {
if (this->state_ == FAILED)
return true;
bool failed = false;
for (auto *descriptor : this->descriptors_) {
failed |= descriptor->is_failed();
if (descriptor->is_failed()) {
this->state_ = FAILED;
return true;
}
}
if (failed)
this->state_ = FAILED;
return this->state_ == FAILED;
return false;
}
void BLECharacteristic::set_property_bit_(esp_gatt_char_prop_t bit, bool value) {