Merge branch 'feat/support_blufi_adv_with_name_v5.5' into 'release/v5.5'

feat(bt/blufi): Support Blufi start advertising with specified name (v5.5)

See merge request espressif/esp-idf!41338
This commit is contained in:
Island
2025-09-04 12:02:40 +08:00
4 changed files with 28 additions and 1 deletions

View File

@@ -381,7 +381,15 @@ void esp_blufi_deinit(void)
void esp_blufi_adv_start(void) void esp_blufi_adv_start(void)
{ {
esp_ble_gap_set_device_name(BLUFI_DEVICE_NAME); esp_ble_gap_config_adv_data(&blufi_adv_data);
}
void esp_blufi_adv_start_with_name(const char *name)
{
if (name != NULL) {
esp_ble_gap_set_device_name(name);
}
esp_ble_gap_config_adv_data(&blufi_adv_data); esp_ble_gap_config_adv_data(&blufi_adv_data);
} }

View File

@@ -85,6 +85,9 @@ void esp_blufi_adv_stop(void);
/* Start advertisement */ /* Start advertisement */
void esp_blufi_adv_start(void); void esp_blufi_adv_start(void);
/* Start advertisement with specified name. if the name is NULL just start advertisement */
void esp_blufi_adv_start_with_name(const char *name);
void esp_blufi_send_encap(void *arg); void esp_blufi_send_encap(void *arg);
#ifdef CONFIG_BT_NIMBLE_ENABLED #ifdef CONFIG_BT_NIMBLE_ENABLED

View File

@@ -468,6 +468,15 @@ void esp_blufi_adv_start(void)
} }
} }
void esp_blufi_adv_start_with_name(const char *name)
{
if (name != NULL) {
ble_svc_gap_device_name_set(name);
}
esp_blufi_adv_start();
}
uint8_t esp_blufi_init(void) uint8_t esp_blufi_init(void)
{ {
blufi_env.enabled = true; blufi_env.enabled = true;

View File

@@ -45,6 +45,13 @@ esp_err_t esp_blufi_host_init(void)
} }
BLUFI_INFO("BD ADDR: "ESP_BD_ADDR_STR"\n", ESP_BD_ADDR_HEX(esp_bt_dev_get_address())); BLUFI_INFO("BD ADDR: "ESP_BD_ADDR_STR"\n", ESP_BD_ADDR_HEX(esp_bt_dev_get_address()));
/* Set the default device name */
ret = esp_ble_gap_set_device_name(BLUFI_DEVICE_NAME);
if (ret) {
BLUFI_ERROR("%s set device name failed: %s\n", __func__, esp_err_to_name(ret));
return ESP_FAIL;
}
return ESP_OK; return ESP_OK;
} }