Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Q
QJ_500-7c
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
时昊
QJ_500-7c
Commits
f6a59176
Commit
f6a59176
authored
May 06, 2024
by
薛小虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: 第二版
parent
8ee9c7ab
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
40 deletions
+73
-40
gatts_table_creat_demo.c
qianjiang/main/gatts_table_creat_demo.c
+73
-40
No files found.
qianjiang/main/gatts_table_creat_demo.c
View file @
f6a59176
...
...
@@ -176,8 +176,7 @@ typedef struct {
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
[]
=
{
0x02
,
0x01
,
0x02
,
0x0d
,
0x09
,
'Q'
,
'I'
,
'A'
,
'N'
,
'J'
,
'I'
,
'A'
,
'N'
,
'V'
,
'i'
,
'v'
,
'a'
,
...
...
@@ -194,7 +193,6 @@ static uint8_t raw_scan_rsp_data[] = {
0x03
,
0x03
,
0x69
,
0x67
,
};
#else
static
uint8_t
service_uuid
[
16
]
=
{
/* LSB <--------------------------------------------------------------------------------> MSB */
//first uuid, 16bit, [12],[13] is the value
...
...
@@ -234,7 +232,38 @@ static esp_ble_adv_data_t scan_rsp_data = {
.
p_service_uuid
=
service_uuid
,
.
flag
=
(
ESP_BLE_ADV_FLAG_GEN_DISC
|
ESP_BLE_ADV_FLAG_BREDR_NOT_SPT
),
};
#endif
/* CONFIG_SET_RAW_ADV_DATA */
static
uint8_t
test_manufacturer
[
3
]
=
{
'E'
,
'S'
,
'P'
};
static
uint8_t
sec_service_uuid
[
16
]
=
{
/* LSB <--------------------------------------------------------------------------------> MSB */
//first uuid, 16bit, [12],[13] is the value
0xfb
,
0x34
,
0x9b
,
0x5f
,
0x80
,
0x00
,
0x00
,
0x80
,
0x00
,
0x10
,
0x00
,
0x00
,
0x18
,
0x0D
,
0x00
,
0x00
,
};
static
esp_ble_adv_data_t
heart_rate_adv_config
=
{
.
set_scan_rsp
=
false
,
.
include_txpower
=
true
,
.
min_interval
=
0x0006
,
//slave connection min interval, Time = min_interval * 1.25 msec
.
max_interval
=
0x0010
,
//slave connection max interval, Time = max_interval * 1.25 msec
.
appearance
=
0x00
,
.
manufacturer_len
=
0
,
//TEST_MANUFACTURER_DATA_LEN,
.
p_manufacturer_data
=
NULL
,
//&test_manufacturer[0],
.
service_data_len
=
0
,
.
p_service_data
=
NULL
,
.
service_uuid_len
=
sizeof
(
sec_service_uuid
),
.
p_service_uuid
=
sec_service_uuid
,
.
flag
=
(
ESP_BLE_ADV_FLAG_GEN_DISC
|
ESP_BLE_ADV_FLAG_BREDR_NOT_SPT
),
};
// config scan response data
static
esp_ble_adv_data_t
heart_rate_scan_rsp_config
=
{
.
set_scan_rsp
=
true
,
.
include_name
=
true
,
.
manufacturer_len
=
sizeof
(
test_manufacturer
),
.
p_manufacturer_data
=
test_manufacturer
,
};
static
esp_ble_adv_params_t
adv_params
=
{
.
adv_int_min
=
0x060
,
...
...
@@ -555,37 +584,41 @@ int bsp_Ble_Gatts_Send_Indicate( uint8_t len, uint8_t *data)
static
void
gap_event_handler
(
esp_gap_ble_cb_event_t
event
,
esp_ble_gap_cb_param_t
*
param
)
{
switch
(
event
)
{
#ifdef CONFIG_SET_RAW_ADV_DATA
case
ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT
:
// case ESP_GAP_BLE_ADV_DATA_RAW_SET_COMPLETE_EVT:
// adv_config_done &= (~ADV_CONFIG_FLAG);
// if (adv_config_done == 0){
// esp_ble_gap_start_advertising(&adv_params);
// printf("adv 1\r\n");
// }
// break;
// case ESP_GAP_BLE_SCAN_RSP_DATA_RAW_SET_COMPLETE_EVT:
// adv_config_done &= (~SCAN_RSP_CONFIG_FLAG);
// if (adv_config_done == 0){
// esp_ble_gap_start_advertising(&adv_params);
// printf("adv 2\r\n");
// }
// break;
case
ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT
:
adv_config_done
&=
(
~
ADV_CONFIG_FLAG
);
if
(
adv_config_done
==
0
){
esp_ble_gap_start_advertising
(
&
adv_params
);
}
printf
(
"adv 1
\r\n
"
);
}
break
;
case
ESP_GAP_BLE_SCAN_RSP_DATA_
RAW_
SET_COMPLETE_EVT
:
case
ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT
:
adv_config_done
&=
(
~
SCAN_RSP_CONFIG_FLAG
);
if
(
adv_config_done
==
0
){
esp_ble_gap_start_advertising
(
&
adv_params
);
}
printf
(
"adv 2
\r\n
"
);
}
break
;
#else
// case ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT:
// adv_config_done &= (~ADV_CONFIG_FLAG);
// if (adv_config_done == 0){
// esp_ble_gap_start_advertising(&adv_params);
// }
// break;
// case ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT:
// adv_config_done &= (~SCAN_RSP_CONFIG_FLAG);
// if (adv_config_done == 0){
// esp_ble_gap_start_advertising(&adv_params);
// }
// break;
#endif
case
ESP_GAP_BLE_ADV_START_COMPLETE_EVT
:
/* advertising start complete event to indicate advertising start successfully or failed */
if
(
param
->
adv_start_cmpl
.
status
!=
ESP_BT_STATUS_SUCCESS
)
{
...
...
@@ -686,10 +719,10 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
if
(
set_dev_name_ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"set device name failed, error code = %x"
,
set_dev_name_ret
);
}
#ifdef CONFIG_SET_RAW_ADV_DATA
esp_ble_gap_config_local_privacy
(
true
);
ble_init_adv_data
(
BLE_ADV_NAME
);
//
ble_init_adv_data(BLE_ADV_NAME);
// esp_err_t raw_adv_ret = esp_ble_gap_config_adv_data_raw(raw_adv_data, sizeof(raw_adv_data));
// if (raw_adv_ret){
// ESP_LOGE(GATTS_TABLE_TAG, "config raw adv data failed, error code = %x ", raw_adv_ret);
...
...
@@ -702,20 +735,20 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
// adv_config_done |= SCAN_RSP_CONFIG_FLAG;
printf
(
"adv configed
\r\n
"
);
#else
//
//
config adv data
// esp_err_t ret = esp_ble_gap_config_adv_data(&adv_data
);
//
if (ret){
//
ESP_LOGE(GATTS_TABLE_TAG, "config adv data failed, error code = %x", ret);
//
}
//
adv_config_done |= ADV_CONFIG_FLAG;
//
//
config scan response data
// ret = esp_ble_gap_config_adv_data(&scan_rsp_data
);
//
if (ret){
//
ESP_LOGE(GATTS_TABLE_TAG, "config scan response data failed, error code = %x", ret);
//
}
//
adv_config_done |= SCAN_RSP_CONFIG_FLAG;
#endif
//config adv data
esp_err_t
ret
=
esp_ble_gap_config_adv_data
(
&
heart_rate_adv_config
);
if
(
ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"config adv data failed, error code = %x"
,
ret
);
}
adv_config_done
|=
ADV_CONFIG_FLAG
;
//config scan response data
ret
=
esp_ble_gap_config_adv_data
(
&
heart_rate_scan_rsp_config
);
if
(
ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"config scan response data failed, error code = %x"
,
ret
);
}
adv_config_done
|=
SCAN_RSP_CONFIG_FLAG
;
esp_err_t
create_attr_ret
=
esp_ble_gatts_create_attr_tab
(
gatt_db
,
gatts_if
,
HRS_IDX_NB
,
SVC_INST_ID
);
if
(
create_attr_ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"create attr table failed, error code = %x"
,
create_attr_ret
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment