mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt : use real adv data to set raw adv data
This commit is contained in:
parent
02460ff864
commit
cf917567e9
@ -1,10 +1,12 @@
|
|||||||
menu "Example 'GATT SERVER' Config"
|
menu "Example 'GATT SERVER' Config"
|
||||||
|
|
||||||
config SET_RAW_ADV_DATA
|
config SET_RAW_ADV_DATA
|
||||||
bool "adv data or scan_rsp data use raw data or structure"
|
bool "Use raw data for advertising packets and scan response data"
|
||||||
default "y"
|
|
||||||
help
|
help
|
||||||
Set raw advertising data/scan response data by self or use adv_data/scan_rsp_data structure to
|
If this config item is set, raw binary data will be used to generate advertising & scan response data.
|
||||||
set advertising data/scan response data. If use structure, lower layer will encapsulate the packets.
|
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
|
endmenu
|
||||||
|
@ -51,21 +51,25 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
#define TEST_DEVICE_NAME "ESP_GATTS_DEMO"
|
#define TEST_DEVICE_NAME "ESP_GATTS_DEMO"
|
||||||
#define TEST_MANUFACTURER_DATA_LEN 17
|
#define TEST_MANUFACTURER_DATA_LEN 17
|
||||||
|
|
||||||
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 0x40
|
#define GATTS_DEMO_CHAR_VAL_LEN_MAX 0x40
|
||||||
|
|
||||||
uint8_t char1_str[] = {0x11,0x22,0x33};
|
uint8_t char1_str[] = {0x11,0x22,0x33};
|
||||||
esp_attr_value_t gatts_demo_char1_val =
|
esp_attr_value_t gatts_demo_char1_val =
|
||||||
{
|
{
|
||||||
.attr_max_len = GATTS_DEMO_CHAR_VAL_LEN_MAX,
|
.attr_max_len = GATTS_DEMO_CHAR_VAL_LEN_MAX,
|
||||||
.attr_len = sizeof(char1_str),
|
.attr_len = sizeof(char1_str),
|
||||||
.attr_value = char1_str,
|
.attr_value = char1_str,
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_SET_RAW_ADV_DATA
|
#ifdef CONFIG_SET_RAW_ADV_DATA
|
||||||
static uint8_t raw_adv_data[] = {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf,
|
static uint8_t raw_adv_data[] = {
|
||||||
0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe};
|
0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
|
||||||
static uint8_t raw_scan_rsp_data[] = {0x7, 0x7, 0x7, 0x7, 0x8, 0x8, 0x8, 0x8, 0x9, 0x9, 0x9, 0x9, 0xa, 0xa, 0xa, 0xa,
|
0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
|
||||||
0xb, 0xb, 0xb, 0xb, 0xc, 0xc, 0xc, 0xc, 0xd, 0xd, 0xd, 0xd, 0xe, 0xe, 0xe};
|
};
|
||||||
|
static uint8_t raw_scan_rsp_data[] = {
|
||||||
|
0x02, 0x01, 0x06, 0x0f, 0x09, 0x45, 0x53, 0x50, 0x5f, 0x47, 0x41, 0x54, 0x54, 0x53, 0x5f, 0x44,
|
||||||
|
0x45, 0x4d, 0x4f, 0x02, 0x0a, 0xeb, 0x03, 0x03, 0xab, 0xcd
|
||||||
|
};
|
||||||
#else
|
#else
|
||||||
static uint8_t test_service_uuid128[32] = {
|
static uint8_t test_service_uuid128[32] = {
|
||||||
/* LSB <--------------------------------------------------------------------------------> MSB */
|
/* LSB <--------------------------------------------------------------------------------> MSB */
|
||||||
@ -211,7 +215,7 @@ static void gatts_profile_a_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
case ESP_GATTS_ADD_INCL_SRVC_EVT:
|
case ESP_GATTS_ADD_INCL_SRVC_EVT:
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_ADD_CHAR_EVT: {
|
case ESP_GATTS_ADD_CHAR_EVT: {
|
||||||
uint16_t length = 0;
|
uint16_t length = 0;
|
||||||
const uint8_t *prf_char;
|
const uint8_t *prf_char;
|
||||||
|
|
||||||
ESP_LOGI(GATTS_TAG, "ADD_CHAR_EVT, status %d, attr_handle %d, service_handle %d\n",
|
ESP_LOGI(GATTS_TAG, "ADD_CHAR_EVT, status %d, attr_handle %d, service_handle %d\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user