Skip to content

Commit 4445f5f

Browse files
committed
ble: fix empty advertised name
1 parent c176cc3 commit 4445f5f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

main/src/user/ble_app.c

+3-2
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[] = {
24+
static uint8_t adv_data_raw[5 + sizeof(CONFIG_BT_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,
28+
1 + sizeof(CONFIG_BT_NAME),
2929
ESP_BLE_AD_TYPE_NAME_CMPL
3030
};
3131

@@ -72,6 +72,7 @@ void ble_app_init(void)
7272
esp_ble_gap_set_rand_addr(ble_get_mac_address());
7373
esp_ble_gap_register_callback(ble_gap_event_handler);
7474

75+
strcpy((char *)adv_data_raw + 5, CONFIG_BT_NAME);
7576
esp_ble_gap_config_adv_data_raw(adv_data_raw, sizeof(adv_data_raw));
7677

7778
esp_ble_gatts_register_callback(ble_gatts_event_handler);

0 commit comments

Comments
 (0)