Skip to content

Commit 6b7d55a

Browse files
committed
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
2 parents ba4300c + 272e652 commit 6b7d55a

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

components/bt/common/btc/profile/esp/blufi/bluedroid_host/esp_blufi.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,15 @@ void esp_blufi_deinit(void)
381381

382382
void esp_blufi_adv_start(void)
383383
{
384-
esp_ble_gap_set_device_name(BLUFI_DEVICE_NAME);
384+
esp_ble_gap_config_adv_data(&blufi_adv_data);
385+
}
386+
387+
void esp_blufi_adv_start_with_name(const char *name)
388+
{
389+
if (name != NULL) {
390+
esp_ble_gap_set_device_name(name);
391+
}
392+
385393
esp_ble_gap_config_adv_data(&blufi_adv_data);
386394
}
387395

components/bt/common/btc/profile/esp/blufi/include/esp_blufi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ void esp_blufi_adv_stop(void);
8585
/* Start advertisement */
8686
void esp_blufi_adv_start(void);
8787

88+
/* Start advertisement with specified name. if the name is NULL just start advertisement */
89+
void esp_blufi_adv_start_with_name(const char *name);
90+
8891
void esp_blufi_send_encap(void *arg);
8992

9093
#ifdef CONFIG_BT_NIMBLE_ENABLED

components/bt/common/btc/profile/esp/blufi/nimble_host/esp_blufi.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,15 @@ void esp_blufi_adv_start(void)
468468
}
469469
}
470470

471+
void esp_blufi_adv_start_with_name(const char *name)
472+
{
473+
if (name != NULL) {
474+
ble_svc_gap_device_name_set(name);
475+
}
476+
477+
esp_blufi_adv_start();
478+
}
479+
471480
uint8_t esp_blufi_init(void)
472481
{
473482
blufi_env.enabled = true;

examples/bluetooth/blufi/main/blufi_init.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ esp_err_t esp_blufi_host_init(void)
4545
}
4646
BLUFI_INFO("BD ADDR: "ESP_BD_ADDR_STR"\n", ESP_BD_ADDR_HEX(esp_bt_dev_get_address()));
4747

48+
/* Set the default device name */
49+
ret = esp_ble_gap_set_device_name(BLUFI_DEVICE_NAME);
50+
if (ret) {
51+
BLUFI_ERROR("%s set device name failed: %s\n", __func__, esp_err_to_name(ret));
52+
return ESP_FAIL;
53+
}
54+
4855
return ESP_OK;
4956

5057
}

0 commit comments

Comments
 (0)