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
31b25547
Commit
31b25547
authored
May 06, 2024
by
薛小虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: 第三版
parent
f6a59176
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
87 deletions
+8
-87
gatts_table_creat_demo.c
qianjiang/main/gatts_table_creat_demo.c
+8
-87
No files found.
qianjiang/main/gatts_table_creat_demo.c
View file @
31b25547
...
...
@@ -177,6 +177,12 @@ typedef struct {
static
prepare_type_env_t
prepare_write_env
;
static
const
uint8_t
service_1_uuid
[
16
]
=
{
0Xbc
,
0Xbc
,
0Xc6
,
0Xbf
,
0Xb1
,
0Xea
,
0Xf0
,
0Xbd
,
0Xec
,
0Xc7
,
0Xd8
,
0Xd6
,
0X60
,
0Xb3
,
0X00
,
0X00
};
static
const
uint8_t
char_1_uuid
[
16
]
=
{
0Xbc
,
0Xbc
,
0Xc6
,
0Xbf
,
0Xb1
,
0Xea
,
0Xf0
,
0Xbd
,
0Xec
,
0Xc7
,
0Xd8
,
0Xd6
,
0X62
,
0Xb3
,
0X00
,
0X00
};
static
uint8_t
raw_adv_data
[]
=
{
0x02
,
0x01
,
0x02
,
0x0d
,
0x09
,
'Q'
,
'I'
,
'A'
,
'N'
,
'J'
,
'I'
,
'A'
,
'N'
,
'V'
,
'i'
,
'v'
,
'a'
,
...
...
@@ -185,56 +191,11 @@ static uint8_t raw_adv_data[] = {
// 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static
uint8_t
raw_scan_rsp_data
[]
=
{
/* flags */
0x02
,
0x01
,
0x02
,
/* service uuid */
0x03
,
0x03
,
0x69
,
0x67
,
};
static
uint8_t
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
,
0xFF
,
0x00
,
0x00
,
0x00
,
};
/* The length of adv data must be less than 31 bytes */
static
esp_ble_adv_data_t
adv_data
=
{
.
set_scan_rsp
=
false
,
.
include_name
=
true
,
.
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,
.
service_data_len
=
0
,
.
p_service_data
=
NULL
,
.
service_uuid_len
=
sizeof
(
service_uuid
),
.
p_service_uuid
=
service_uuid
,
.
flag
=
(
ESP_BLE_ADV_FLAG_GEN_DISC
|
ESP_BLE_ADV_FLAG_BREDR_NOT_SPT
),
};
// scan response data
static
esp_ble_adv_data_t
scan_rsp_data
=
{
.
set_scan_rsp
=
true
,
.
include_name
=
true
,
.
include_txpower
=
true
,
.
min_interval
=
0x0006
,
.
max_interval
=
0x0010
,
.
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
(
service_uuid
),
.
p_service_uuid
=
service_uuid
,
.
flag
=
(
ESP_BLE_ADV_FLAG_GEN_DISC
|
ESP_BLE_ADV_FLAG_BREDR_NOT_SPT
),
};
static
uint8_t
test_manufacturer
[
3
]
=
{
'E'
,
'S'
,
'P'
};
static
uint8_t
test_manufacturer
[
0
]
=
{
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
};
static
uint8_t
sec_service_uuid
[
16
]
=
{
/* LSB <--------------------------------------------------------------------------------> MSB */
...
...
@@ -289,31 +250,7 @@ struct gatts_profile_inst {
esp_bt_uuid_t
descr_uuid
;
};
static
void
ble_init_adv_data
(
const
char
*
name
)
{
int
len
=
strlen
(
name
);
uint8_t
raw_adv_data1
[
len
+
5
];
//flag
raw_adv_data1
[
0
]
=
2
;
raw_adv_data1
[
1
]
=
1
;
raw_adv_data1
[
2
]
=
(
ESP_BLE_ADV_FLAG_GEN_DISC
|
ESP_BLE_ADV_FLAG_BREDR_NOT_SPT
);
//adv name
raw_adv_data1
[
3
]
=
len
+
1
;
raw_adv_data1
[
4
]
=
ESP_BLE_AD_TYPE_NAME_CMPL
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
raw_adv_data1
[
i
+
5
]
=
*
(
name
++
);
}
//The length of adv data must be less than 31 bytes
esp_err_t
raw_adv_ret
=
esp_ble_gap_config_adv_data_raw
(
raw_adv_data1
,
sizeof
(
raw_adv_data1
));
if
(
raw_adv_ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"config raw adv data failed, error code = 0x%x "
,
raw_adv_ret
);
}
esp_err_t
raw_scan_ret
=
esp_ble_gap_config_scan_rsp_data_raw
(
raw_adv_data1
,
sizeof
(
raw_adv_data1
));
if
(
raw_scan_ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"config raw scan rsp data failed, error code = 0x%x"
,
raw_scan_ret
);
}
}
static
void
gatts_profile_event_handler
(
esp_gatts_cb_event_t
event
,
...
...
@@ -360,10 +297,6 @@ const uint16_t Dev_Svc_2A50_Str = 0x2A50;
const
uint8_t
char_prop_write_writenr_notify
=
ESP_GATT_CHAR_PROP_BIT_WRITE_NR
|
ESP_GATT_CHAR_PROP_BIT_WRITE
|
ESP_GATT_CHAR_PROP_BIT_NOTIFY
;
static
const
uint8_t
service_1_uuid
[
16
]
=
{
0Xbc
,
0Xbc
,
0Xc6
,
0Xbf
,
0Xb1
,
0Xea
,
0Xf0
,
0Xbd
,
0Xec
,
0Xc7
,
0Xd8
,
0Xd6
,
0X60
,
0Xb3
,
0X00
,
0X00
};
static
const
uint8_t
char_1_uuid
[
16
]
=
{
0Xbc
,
0Xbc
,
0Xc6
,
0Xbf
,
0Xb1
,
0Xea
,
0Xf0
,
0Xbd
,
0Xec
,
0Xc7
,
0Xd8
,
0Xd6
,
0X62
,
0Xb3
,
0X00
,
0X00
};
/* Full Database Description - Used to add attributes into the database */
...
...
@@ -722,18 +655,6 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
esp_ble_gap_config_local_privacy
(
true
);
// 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);
// }
// adv_config_done |= ADV_CONFIG_FLAG;
// esp_err_t raw_scan_ret = esp_ble_gap_config_scan_rsp_data_raw(raw_scan_rsp_data, sizeof(raw_scan_rsp_data));
// if (raw_scan_ret){
// ESP_LOGE(GATTS_TABLE_TAG, "config raw scan rsp data failed, error code = %x", raw_scan_ret);
// }
// adv_config_done |= SCAN_RSP_CONFIG_FLAG;
printf
(
"adv configed
\r\n
"
);
//config adv data
...
...
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