Skip to content

Commit 5f49f62

Browse files
committed
ble: use random address
1 parent 8436c05 commit 5f49f62

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

main/Kconfig.projbuild

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ config BT_NAME
88
config ENABLE_BLE_CONTROL_IF
99
bool "Enable BLE Control Interface"
1010
default n
11+
12+
config BLE_NAME
13+
string "BLE Control Interface Name"
14+
default "Bluetooth Visual Speaker BLE"
15+
depends on ENABLE_BLE_CONTROL_IF
1116
endmenu
1217

1318
menu "Audio Configuration"

main/src/user/ble_app.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
#define BLE_APP_TAG "ble_app"
2222
#define BLE_GAP_TAG "ble_gap"
2323

24-
static uint8_t adv_data_raw[5 + sizeof(CONFIG_BT_NAME)] = {
24+
static uint8_t adv_data_raw[5 + sizeof(CONFIG_BLE_NAME)] = {
2525
2,
2626
ESP_BT_EIR_TYPE_FLAGS,
2727
ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT,
28-
1 + sizeof(CONFIG_BT_NAME),
28+
1 + sizeof(CONFIG_BLE_NAME),
2929
ESP_BLE_AD_TYPE_NAME_CMPL
3030
};
3131

@@ -54,6 +54,10 @@ static void ble_gap_event_handler(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_p
5454
ESP_LOGE(BLE_GAP_TAG, "failed to stop advertising");
5555
}
5656
break;
57+
case ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT:
58+
strcpy((char *)adv_data_raw + 5, CONFIG_BLE_NAME);
59+
esp_ble_gap_config_adv_data_raw(adv_data_raw, sizeof(adv_data_raw));
60+
break;
5761
default:
5862
break;
5963
}
@@ -68,12 +72,8 @@ void ble_app_init(void)
6872
{
6973
xEventGroupSetBits(user_event_group, BLE_GATTS_IDLE_BIT);
7074

71-
esp_ble_gap_set_device_name(CONFIG_BT_NAME);
72-
esp_ble_gap_set_rand_addr(ble_get_mac_address());
7375
esp_ble_gap_register_callback(ble_gap_event_handler);
74-
75-
strcpy((char *)adv_data_raw + 5, CONFIG_BT_NAME);
76-
esp_ble_gap_config_adv_data_raw(adv_data_raw, sizeof(adv_data_raw));
76+
esp_ble_gap_config_local_privacy(true);
7777

7878
esp_ble_gatts_register_callback(ble_gatts_event_handler);
7979
esp_ble_gatts_app_register(PROFILE_IDX_OTA);

0 commit comments

Comments
 (0)