diff --git a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c index a5e6c05cf8..2e663543d8 100644 --- a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c @@ -69,22 +69,23 @@ static prepare_type_env_t prepare_write_env; //#define CONFIG_SET_RAW_ADV_DATA #ifdef CONFIG_SET_RAW_ADV_DATA static uint8_t raw_adv_data[] = { - /* flags */ - 0x02, 0x01, 0x06, - /* tx power*/ - 0x02, 0x0a, 0xeb, - /* service uuid */ - 0x03, 0x03, 0xFF, 0x00, - /* device name */ - 0x0E, 0x09, 'B', 'L', 'E', '_', 'C', 'O','M', 'P', '_', 'T','E', 'S', 'T' + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, + /* TX Power */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xeb, + /* Service UUID */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xFF, 0x00, + /* Device Name */ + 0x0E, ESP_BLE_AD_TYPE_NAME_CMPL, 'B', 'L', 'E', '_', 'C', 'O', 'M', 'P', '_', 'T', 'E', 'S', 'T' }; + static uint8_t raw_scan_rsp_data[] = { - /* flags */ - 0x02, 0x01, 0x06, - /* tx power */ - 0x02, 0x0a, 0xeb, - /* service uuid */ - 0x03, 0x03, 0xFF,0x00 + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, + /* TX Power */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xeb, + /* Service UUID */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xFF, 0x00 }; #else diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c index 310b6e8895..d39131d6b4 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c @@ -44,11 +44,11 @@ static const uint16_t spp_service_uuid = 0xABF0; static const uint8_t spp_adv_data[23] = { /* Flags */ - 0x02,0x01,0x06, + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, /* Complete List of 16-bit Service Class UUIDs */ - 0x03,0x03,0xF0,0xAB, + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xF0, 0xAB, /* Complete Local Name in advertising */ - 0x0F,0x09, 'E', 'S', 'P', '_', 'S', 'P', 'P', '_', 'S', 'E', 'R','V', 'E', 'R' + 0x0F, ESP_BLE_AD_TYPE_NAME_CMPL, 'E', 'S', 'P', '_', 'S', 'P', 'P', '_', 'S', 'E', 'R', 'V', 'E', 'R' }; static uint16_t spp_mtu_size = 23; diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c index 58176e3101..4e8b418817 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -97,12 +97,17 @@ static uint8_t adv_config_done = 0; #ifdef CONFIG_EXAMPLE_SET_RAW_ADV_DATA static uint8_t raw_adv_data[] = { - 0x02, 0x01, 0x06, - 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, + /* TX Power Level */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xEB, + /* Service UUID */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xAB, 0xCD }; + static uint8_t raw_scan_rsp_data[] = { - 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44, - 0x45, 0x4d, 0x4f + /* Complete Local Name */ + 0x0F, ESP_BLE_AD_TYPE_NAME_CMPL, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D', 'E', 'M', 'O' }; #else diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c index 12a7b28161..77a864055d 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c @@ -74,13 +74,17 @@ static uint8_t adv_config_done = 0; #ifdef CONFIG_SET_RAW_ADV_DATA static uint8_t raw_adv_data[] = { - 0x02, 0x01, 0x06, // Length 2, Data Type 1 (Flags), Data 1 (LE General Discoverable Mode, BR/EDR Not Supported) - 0x02, 0x0a, 0xeb, // Length 2, Data Type 10 (TX power leve), Data 2 (-21) - 0x03, 0x03, 0xab, 0xcd, // Length 3, Data Type 3 (Complete 16-bit Service UUIDs), Data 3 (UUID) + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, // Length 2, Data Type ESP_BLE_AD_TYPE_FLAG, Data 1 (LE General Discoverable Mode, BR/EDR Not Supported) + /* TX Power Level */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xEB, // Length 2, Data Type ESP_BLE_AD_TYPE_TX_PWR, Data 2 (-21) + /* Complete 16-bit Service UUIDs */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xAB, 0xCD // Length 3, Data Type ESP_BLE_AD_TYPE_16SRV_CMPL, Data 3 (UUID) }; -static uint8_t raw_scan_rsp_data[] = { // Length 15, Data Type 9 (Complete Local Name), Data 1 (ESP_GATTS_DEMO) - 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44, - 0x45, 0x4d, 0x4f + +static uint8_t raw_scan_rsp_data[] = { + /* Complete Local Name */ + 0x0F, ESP_BLE_AD_TYPE_NAME_CMPL, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D', 'E', 'M', 'O' // Length 15, Data Type ESP_BLE_AD_TYPE_NAME_CMPL, Data (ESP_GATTS_DEMO) }; #else diff --git a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c index 52978dcabf..c18c583c8f 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c @@ -61,22 +61,24 @@ static prepare_type_env_t prepare_write_env; #define CONFIG_SET_RAW_ADV_DATA #ifdef CONFIG_SET_RAW_ADV_DATA static uint8_t raw_adv_data[] = { - /* flags */ - 0x02, 0x01, 0x06, - /* tx power*/ - 0x02, 0x0a, 0xeb, - /* service uuid */ - 0x03, 0x03, 0xFF, 0x00, - /* device name */ - 0x0f, 0x09, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D','E', 'M', 'O' + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, + /* TX Power Level */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xEB, + /* Complete 16-bit Service UUIDs */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xFF, 0x00, + /* Complete Local Name */ + 0x0F, ESP_BLE_AD_TYPE_NAME_CMPL, + 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D', 'E', 'M', 'O' }; + static uint8_t raw_scan_rsp_data[] = { - /* flags */ - 0x02, 0x01, 0x06, - /* tx power */ - 0x02, 0x0a, 0xeb, - /* service uuid */ - 0x03, 0x03, 0xFF,0x00 + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, + /* TX Power Level */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xEB, + /* Complete 16-bit Service UUIDs */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xFF, 0x00 }; #else diff --git a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/Kconfig.projbuild b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/Kconfig.projbuild new file mode 100644 index 0000000000..912aedf7ea --- /dev/null +++ b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/Kconfig.projbuild @@ -0,0 +1,14 @@ +menu "Example 'GATTC_GATTS_COEX' Config" + + config SET_RAW_ADV_DATA + bool "Use raw data for advertising packets and scan response data" + help + If this config item is set, raw binary data will be used to generate advertising & scan response data. + This option uses the esp_ble_gap_config_adv_data_raw() and esp_ble_gap_config_scan_rsp_data_raw() + functions. + + If this config item is unset, advertising & scan response data is provided via a higher-level + esp_ble_adv_data_t structure. The lower layer will generate the BLE packets. This option has higher + overhead at runtime. + +endmenu diff --git a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c index 5de1868749..9b58ceac84 100644 --- a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c +++ b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c @@ -116,6 +116,22 @@ esp_attr_value_t gatts_demo_char1_val = { .attr_value = char1_str, }; +#ifdef CONFIG_SET_RAW_ADV_DATA +static uint8_t raw_adv_data[] = { + /* Flags */ + 0x02, ESP_BLE_AD_TYPE_FLAG, 0x06, // Length 2, Data Type ESP_BLE_AD_TYPE_FLAG, Data 1 (LE General Discoverable Mode, BR/EDR Not Supported) + /* TX Power Level */ + 0x02, ESP_BLE_AD_TYPE_TX_PWR, 0xEB, // Length 2, Data Type ESP_BLE_AD_TYPE_TX_PWR, Data 2 (-21) + /* Complete 16-bit Service UUIDs */ + 0x03, ESP_BLE_AD_TYPE_16SRV_CMPL, 0xAB, 0xCD // Length 3, Data Type ESP_BLE_AD_TYPE_16SRV_CMPL, Data 3 (UUID) +}; + +static uint8_t raw_scan_rsp_data[] = { + /* Complete Local Name */ + 0x0F, ESP_BLE_AD_TYPE_NAME_CMPL, 'E', 'S', 'P', '_', 'G', 'A', 'T', 'T', 'S', '_', 'D', 'E', 'M', 'O' // Length 15, Data Type ESP_BLE_AD_TYPE_NAME_CMPL, Data (ESP_GATTS_DEMO) +}; + +#else static uint8_t service_uuid128[32] = { /* LSB <--------------------------------------------------------------------------------> MSB */ //first uuid, 16bit, [12],[13] is the value @@ -156,6 +172,7 @@ static esp_ble_adv_data_t scan_rsp_data = { .p_service_uuid = NULL, .flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT), }; +#endif /* CONFIG_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { .adv_int_min = 0x20,