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
d4311824
Commit
d4311824
authored
Jul 02, 2024
by
chen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:修改蓝牙名称使蓝牙名称变成随机值
parent
299f458c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
38 deletions
+80
-38
app_BT_User.c
qianjiang/main/app_BT_User.c
+16
-16
app_BT_User.h
qianjiang/main/app_BT_User.h
+2
-2
bt_app_hf.c
qianjiang/main/bt_app_hf.c
+3
-3
gatts_table_creat_demo.c
qianjiang/main/gatts_table_creat_demo.c
+59
-17
No files found.
qianjiang/main/app_BT_User.c
View file @
d4311824
...
...
@@ -78,22 +78,22 @@ void BT_User_Process(void )
{
break
;
}
case
Call_Miss
:
{
if
(
BT_User
.
HF_Ctrl
==
HF_Reject
)
{
hf_reject_handler
();
}
break
;
}
case
Call_Hangup
:
{
if
(
BT_User
.
HF_Ctrl
==
HF_Reject
)
{
hf_reject_handler
();
}
break
;
}
//
case Call_Miss:
//
{
//
if(BT_User.HF_Ctrl == HF_Reject)
//
{
//
hf_reject_handler();
//
}
//
break;
//
}
//
case Call_Hangup:
//
{
//
if(BT_User.HF_Ctrl == HF_Reject)
//
{
//
hf_reject_handler();
//
}
//
break;
//
}
}
BT_User
.
HF_Ctrl
=
HF_Idle
;
...
...
qianjiang/main/app_BT_User.h
View file @
d4311824
...
...
@@ -17,8 +17,8 @@ typedef enum
Call_IncomeCalling
,
Call_OutCalling
,
Call_InProcess
,
Call_Miss
,
Call_Hangup
,
//
Call_Miss,
//
Call_Hangup,
}
Call_Sts_Enum
;
typedef
enum
...
...
qianjiang/main/bt_app_hf.c
View file @
d4311824
...
...
@@ -334,14 +334,14 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
if
((
param
->
call
.
status
==
0
)
&&
((
BT_User
.
Call_Sts
==
Call_InProcess
)
||
(
BT_User
.
Call_Sts
==
Call_OutCalling
)
||
(
BT_User
.
Call_Sts
==
Call_IncomeCalling
)))
{
BT_User
.
Call_Sts
=
Call_
Hangup
;
BT_User
.
Call_Sts
=
Call_
Idle
;
call_timer
=
0
;
printf
(
"call Hangup
\r\n
"
);
}
else
if
((
param
->
call
.
status
==
1
)
&&
((
BT_User
.
Call_Sts
==
Call_OutCalling
)
||
(
BT_User
.
Call_Sts
==
Call_IncomeCalling
)
||
(
BT_User
.
Call_Sts
==
Call_InProcess
)))
{
BT_User
.
Call_Sts
=
Call_InProcess
;
//
printf("call Call_InProcess\r\n");
printf
(
"call Call_InProcess
\r\n
"
);
}
break
;
}
...
...
@@ -357,7 +357,7 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_
// {
if
(
param
->
call_setup
.
status
==
0
&&
(
BT_User
.
Call_Sts
==
Call_IncomeCalling
))
{
BT_User
.
Call_Sts
=
Call_
Miss
;
BT_User
.
Call_Sts
=
Call_
Idle
;
call_timer
=
0
;
printf
(
"call Miss
\r\n
"
);
}
...
...
qianjiang/main/gatts_table_creat_demo.c
View file @
d4311824
...
...
@@ -138,7 +138,7 @@ void simple_ota_service(void)
uint8_t
BT_Device_Name
[
14
]
=
"QJ
-
Viva"
;
uint8_t
BT_Device_Name
[
14
]
=
"QJViva"
;
#define GATTS_TABLE_TAG "GATTS_TABLE_DEMO"
...
...
@@ -182,7 +182,7 @@ static uint8_t raw_adv_data[] = {
0x02
,
0x01
,
0x02
,
0x03
,
0x03
,
0x69
,
0x67
,
0x09
,
0xff
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x00
,
0x0
8
,
0x09
,
'Q'
,
'J'
,
'-'
,
'V'
,
'i'
,
'v'
,
'a'
,
0x0
7
,
0x09
,
'Q'
,
'J'
,
'-'
,
'V'
,
'i'
,
'v'
,
// 0x08, 0x16, 0x60, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00,
};
...
...
@@ -240,7 +240,7 @@ static esp_ble_adv_params_t adv_params = {
.
adv_int_min
=
0x20
,
.
adv_int_max
=
0x40
,
.
adv_type
=
ADV_TYPE_IND
,
.
own_addr_type
=
BLE_ADDR_TYPE_
RANDOM
,
.
own_addr_type
=
BLE_ADDR_TYPE_
PUBLIC
,
.
channel_map
=
ADV_CHNL_ALL
,
.
adv_filter_policy
=
ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY
,
};
...
...
@@ -654,7 +654,7 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
{
switch
(
event
)
{
case
ESP_GATTS_REG_EVT
:{
esp_ble_gap_set_rand_addr
(
rand_addr
);
//
esp_ble_gap_set_rand_addr(rand_addr);
esp_err_t
set_dev_name_ret
=
esp_ble_gap_set_device_name
((
const
char
*
)
BT_Device_Name
);
if
(
set_dev_name_ret
){
ESP_LOGE
(
GATTS_TABLE_TAG
,
"set device name failed, error code = %x"
,
set_dev_name_ret
);
...
...
@@ -894,15 +894,55 @@ void Get_Mac_Init(void )
char
temp
[
10
]
=
{
0
};
char
temp1
[
20
]
=
{
0
};
esp_read_mac
(
ble_mac
,
ESP_MAC_BT
);
// printf("%d\n",temp);
sprintf
(
temp
,
"%02X%02X"
,
ble_mac
[
4
],
ble_mac
[
5
]);
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
4
]
=
temp
[
0
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
3
]
=
temp
[
1
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
2
]
=
temp
[
2
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
1
]
=
temp
[
3
];
// sprintf(temp, "%02X%02X", ble_mac[4], ble_mac[5]);
int
g
;
for
(
g
=
0
;
g
<
6
;
g
++
)
{
srand
((
int
)
ble_mac
[
g
]);
if
(
g
==
0
)
{
temp
[
g
]
=
(
char
)
rand
()
%
5
;
}
else
{
temp
[
g
]
=
(
char
)
rand
()
%
10
;
temp
[
g
]
+=
48
;
}
printf
(
"%d "
,
temp
[
g
]);
// printf("%d\n",);
//printf("%d ",ble_mac[g]);
}
printf
(
"
\n
"
);
if
(
temp
[
0
]
==
0
)
{
temp
[
0
]
+=
69
;
}
else
if
(
temp
[
0
]
==
1
)
{
temp
[
0
]
=
70
;
}
else
if
(
temp
[
0
]
==
2
)
{
temp
[
0
]
=
72
;
}
else
if
(
temp
[
0
]
==
3
)
{
temp
[
0
]
=
73
;
}
else
if
(
temp
[
0
]
==
4
)
{
temp
[
0
]
=
85
;
}
// srand (ble_mac[0]);
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
6
]
=
temp
[
0
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
5
]
=
temp
[
1
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
4
]
=
temp
[
2
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
3
]
=
temp
[
3
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
2
]
=
temp
[
4
];
raw_adv_data
[
sizeof
(
raw_adv_data
)
-
1
]
=
temp
[
5
];
// ESP_LOGW(GATTS_TABLE_TAG, "BLE_MAC IS %s : ",
// &raw_adv_data[11]);
// ESP_LOGW(GATTS_TABLE_TAG, "BLE_MAC IS %s : ",
...
...
@@ -911,11 +951,13 @@ void Get_Mac_Init(void )
// printf("My MAC:\n");
esp_log_buffer_hex
(
GATTS_TABLE_TAG
,
ble_mac
,
6
);
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
11
]
=
temp
[
0
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
10
]
=
temp
[
1
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
9
]
=
temp
[
2
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
8
]
=
temp
[
3
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
14
]
=
temp
[
0
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
13
]
=
temp
[
1
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
12
]
=
temp
[
2
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
11
]
=
temp
[
3
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
10
]
=
temp
[
4
];
BT_Device_Name
[
sizeof
(
BT_Device_Name
)
-
9
]
=
temp
[
5
];
raw_adv_data
[
11
]
=
ble_mac
[
0
];
raw_adv_data
[
12
]
=
ble_mac
[
1
];
raw_adv_data
[
13
]
=
ble_mac
[
2
];
...
...
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