order matters

This commit is contained in:
J. Nick Koston
2025-09-27 13:39:03 -05:00
parent a9a5cef281
commit c17e38e58f
+11 -2
View File
@@ -81,8 +81,17 @@ void ESP32BLE::advertising_set_service_data_and_name(std::span<const uint8_t> da
// when changing both properties, avoiding the brief gap that would occur with separate calls.
this->advertising_init_();
this->advertising_->set_service_data(data);
this->advertising_->set_include_name(include_name);
if (include_name) {
// When including name, clear service data first to avoid packet overflow
this->advertising_->set_service_data(std::span<const uint8_t>{});
this->advertising_->set_include_name(true);
} else {
// When including service data, clear name first to avoid packet overflow
this->advertising_->set_include_name(false);
this->advertising_->set_service_data(data);
}
this->advertising_start();
}