1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-14 15:53:48 +01:00

[esp32_improv] Make device name visible to passive BLE scanners (#10918)

This commit is contained in:
J. Nick Koston
2025-09-28 16:33:36 -05:00
committed by GitHub
parent a2f833d665
commit 34b4cb46f6
6 changed files with 136 additions and 39 deletions

View File

@@ -43,7 +43,7 @@ void BLEAdvertising::remove_service_uuid(ESPBTUUID uuid) {
this->advertising_uuids_.end());
}
void BLEAdvertising::set_service_data(const std::vector<uint8_t> &data) {
void BLEAdvertising::set_service_data(std::span<const uint8_t> data) {
delete[] this->advertising_data_.p_service_data;
this->advertising_data_.p_service_data = nullptr;
this->advertising_data_.service_data_len = data.size();
@@ -54,6 +54,10 @@ void BLEAdvertising::set_service_data(const std::vector<uint8_t> &data) {
}
}
void BLEAdvertising::set_service_data(const std::vector<uint8_t> &data) {
this->set_service_data(std::span<const uint8_t>(data));
}
void BLEAdvertising::set_manufacturer_data(const std::vector<uint8_t> &data) {
delete[] this->advertising_data_.p_manufacturer_data;
this->advertising_data_.p_manufacturer_data = nullptr;
@@ -84,7 +88,7 @@ esp_err_t BLEAdvertising::services_advertisement_() {
esp_err_t err;
this->advertising_data_.set_scan_rsp = false;
this->advertising_data_.include_name = !this->scan_response_;
this->advertising_data_.include_name = this->include_name_in_adv_ || !this->scan_response_;
this->advertising_data_.include_txpower = !this->scan_response_;
err = esp_ble_gap_config_adv_data(&this->advertising_data_);
if (err != ESP_OK) {