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
c588759b
Commit
c588759b
authored
May 05, 2024
by
薛晓虎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:屏蔽部分打印,修改重连时间为30s
parent
50b6561d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
145 additions
and
57 deletions
+145
-57
settings.json
.vscode/settings.json
+3
-1
Protocol_User.c
qianjiang/main/Protocol_User.c
+2
-2
app_BT_User.c
qianjiang/main/app_BT_User.c
+11
-6
bt_app_main.c
qianjiang/main/bt_app_main.c
+48
-26
bt_app_main.h
qianjiang/main/bt_app_main.h
+1
-1
gatts_table_creat_demo.c
qianjiang/main/gatts_table_creat_demo.c
+8
-8
main_user.c
qianjiang/main/main_user.c
+61
-3
sdkconfig
qianjiang/sdkconfig
+11
-10
No files found.
.vscode/settings.json
View file @
c588759b
...
...
@@ -6,6 +6,8 @@
"gatts_table_creat_demo.h"
:
"c"
,
"app_ble_user.h"
:
"c"
,
"main_user.h"
:
"c"
,
"mcu_core_protocol.h"
:
"c"
"mcu_core_protocol.h"
:
"c"
,
"app_bt_user.h"
:
"c"
,
"bt_app_main.h"
:
"c"
}
}
\ No newline at end of file
qianjiang/main/Protocol_User.c
View file @
c588759b
...
...
@@ -242,8 +242,8 @@ static void Protocol_UartHandle(const Protocol_Data_t *pData)
memcpy
((
uint8_t
*
)
ble_uerid
,
(
uint8_t
*
)
&
(
pData
->
Data
[
1
]),
32
);
}
esp_log_buffer_hex
(
TAG
,
ble_uerid
,
32
);
esp_log_buffer_hex
(
TAG
,
&
(
pData
->
Data
[
1
]),
32
);
//
esp_log_buffer_hex(TAG, ble_uerid, 32);
//
esp_log_buffer_hex(TAG, &(pData->Data[1]), 32);
if
(
Ble_User
.
UseridUpdate
==
0
)
{
...
...
qianjiang/main/app_BT_User.c
View file @
c588759b
...
...
@@ -11,21 +11,23 @@ extern esp_bd_addr_t peer_addr;
BT_User_Control_Struct
BT_User
;
#define BT_ReConn_T 3
5
0
#define BT_ReConn_T 3
00
0
void
BT_User_Init
(
void
)
{
BT_User
.
BT_Sts
=
BT_Idle
;
BT_User
.
Call_Sts
=
Call_Idle
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
0
;
BT_User
.
HF_Ctrl
=
HF_Idle
;
printf
(
"BT INIT!!
\r\n
"
);
}
void
BT_Connect_Event_Pro
(
void
)
{
BT_User
.
BT_Sts
=
BT_Conn
;
BT_User
.
Call_Sts
=
Call_Idle
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
0
;
BT_User
.
HF_Ctrl
=
HF_Idle
;
printf
(
"TB CONN
\r\n
"
);
}
...
...
@@ -35,7 +37,7 @@ void BT_DisConnect_Event_Pro(void )
{
BT_User
.
BT_Sts
=
BT_Idle
;
BT_User
.
Call_Sts
=
Call_Idle
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
;
BT_User
.
ReconnTime
=
BT_ReConn_T
-
50
0
;
BT_User
.
HF_Ctrl
=
HF_Idle
;
printf
(
"TB DISCONN
\r\n
"
);
}
...
...
@@ -88,8 +90,11 @@ void BT_User_Process(void )
if
(
BT_User
.
ReconnTime
>=
BT_ReConn_T
)
{
printf
(
"Connect Start..............................
\n
"
);
app_BT_Get_BondDev
();
esp_hf_client_connect
(
peer_addr
);
if
(
app_BT_Get_BondDev
()
==
1
)
{
esp_hf_client_connect
(
peer_addr
);
}
printf
(
"Connect..............................
\n
"
);
BT_User
.
ReconnTime
=
0
;
...
...
qianjiang/main/bt_app_main.c
View file @
c588759b
...
...
@@ -34,24 +34,46 @@ static uint8_t peer_bdname_len;
int
bond_dev_num
;
int
last_bond_dev_num
=
-
1
;
void
app_BT_Get_BondDev
(
void
)
// esp_bt_gap_remove_bond_device
uint8_t
app_BT_Get_BondDev
(
void
)
{
uint8_t
ret
=
0
;
bond_dev_num
=
esp_bt_gap_get_bond_device_num
();
printf
(
"dev_num %d
\n
"
,
bond_dev_num
);
if
(
last_bond_dev_num
!=
bond_dev_num
)
if
(
bond_dev_num
)
{
if
(
bond_dev_num
)
esp_bd_addr_t
*
dev_list
=
(
esp_bd_addr_t
*
)
malloc
(
sizeof
(
esp_bd_addr_t
)
*
bond_dev_num
);
esp_bt_gap_get_bond_device_list
(
&
bond_dev_num
,
dev_list
);
memcpy
(
peer_addr
,
dev_list
[
0
],
6
);
if
(
bond_dev_num
>
1
)
{
esp_bd_addr_t
*
dev_list
=
(
esp_bd_addr_t
*
)
malloc
(
sizeof
(
esp_bd_addr_t
)
*
bond_dev_num
);
esp_bt_gap_get_bond_device_list
(
&
bond_dev_num
,
dev_list
);
memcpy
(
peer_addr
,
dev_list
[
0
],
6
);
esp_log_buffer_hex
(
BT_HF_TAG
,
peer_addr
,
ESP_BD_ADDR_LEN
);
for
(
int
i
=
1
;
i
<
bond_dev_num
;
i
++
)
{
esp_bt_gap_remove_bond_device
(
dev_list
[
i
]
);
}
}
last_bond_dev_num
=
bond_dev_num
;
ret
=
1
;
}
else
{
memset
(
peer_addr
,
0
,
6
);
ret
=
0
;
}
return
ret
;
}
void
BT_Remove_Other_BondDev
(
void
)
{
}
...
...
@@ -95,14 +117,14 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
case
ESP_BT_GAP_DISC_RES_EVT
:
{
// esp_hf_client_connect(peer_addr);
// esp_bt_gap_cancel_discovery();
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
}
case
ESP_BT_GAP_DISC_STATE_CHANGED_EVT
:
ESP_LOGI
(
BT_HF_TAG
,
"ESP_BT_GAP_DISC_STATE_CHANGED_EVT"
);
case
ESP_BT_GAP_RMT_SRVCS_EVT
:
case
ESP_BT_GAP_RMT_SRVC_REC_EVT
:
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
case
ESP_BT_GAP_AUTH_CMPL_EVT
:
{
if
(
param
->
auth_cmpl
.
stat
==
ESP_BT_STATUS_SUCCESS
)
{
...
...
@@ -112,7 +134,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
ESP_LOGE
(
BT_HF_TAG
,
"authentication failed, status:%d"
,
param
->
auth_cmpl
.
stat
);
}
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
}
case
ESP_BT_GAP_PIN_REQ_EVT
:
{
...
...
@@ -131,7 +153,7 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
esp_bt_gap_pin_reply
(
param
->
pin_req
.
bda
,
true
,
4
,
pin_code
);
}
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
}
...
...
@@ -140,26 +162,26 @@ void esp_bt_gap_cb(esp_bt_gap_cb_event_t event, esp_bt_gap_cb_param_t *param)
ESP_LOGI
(
BT_HF_TAG
,
"ESP_BT_GAP_CFM_REQ_EVT Please compare the numeric value: %"
PRIu32
,
param
->
cfm_req
.
num_val
);
esp_bt_gap_ssp_confirm_reply
(
param
->
cfm_req
.
bda
,
true
);
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
case
ESP_BT_GAP_KEY_NOTIF_EVT
:
ESP_LOGI
(
BT_HF_TAG
,
"ESP_BT_GAP_KEY_NOTIF_EVT passkey:%"
PRIu32
,
param
->
key_notif
.
passkey
);
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
case
ESP_BT_GAP_KEY_REQ_EVT
:
ESP_LOGI
(
BT_HF_TAG
,
"ESP_BT_GAP_KEY_REQ_EVT Please enter passkey!"
);
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
#endif
case
ESP_BT_GAP_MODE_CHG_EVT
:
ESP_LOGI
(
BT_HF_TAG
,
"ESP_BT_GAP_MODE_CHG_EVT mode:%d"
,
param
->
mode_chg
.
mode
);
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
default:
{
ESP_LOGI
(
BT_HF_TAG
,
"event: %d"
,
event
);
printf
(
"event state %d
\n
"
,
event
);
//
printf("event state %d\n", event);
break
;
}
}
...
...
@@ -233,14 +255,14 @@ void bsp_BT_Init(void)
/* Register commands */
// register_hfp_hf();
printf
(
"
\n
==================================================
\n
"
);
printf
(
" | Steps to test hfp_hf |
\n
"
);
printf
(
" | |
\n
"
);
printf
(
" | 1. Print 'help' to gain overview of commands |
\n
"
);
printf
(
" | 2. Setup a service level connection |
\n
"
);
printf
(
" | 3. Run hfp_hf to test |
\n
"
);
printf
(
" | |
\n
"
);
printf
(
" =================================================
\n\n
"
);
//
printf("\n ==================================================\n");
//
printf(" | Steps to test hfp_hf |\n");
//
printf(" | |\n");
//
printf(" | 1. Print 'help' to gain overview of commands |\n");
//
printf(" | 2. Setup a service level connection |\n");
//
printf(" | 3. Run hfp_hf to test |\n");
//
printf(" | |\n");
//
printf(" =================================================\n\n");
// start console REPL
// ESP_ERROR_CHECK(esp_console_start_repl(repl));
...
...
qianjiang/main/bt_app_main.h
View file @
c588759b
...
...
@@ -8,5 +8,5 @@
#define BT_APP_MAN_H
void
bsp_BT_Init
(
void
);
void
app_BT_Get_BondDev
(
void
);
uint8_t
app_BT_Get_BondDev
(
void
);
#endif
\ No newline at end of file
qianjiang/main/gatts_table_creat_demo.c
View file @
c588759b
...
...
@@ -811,10 +811,10 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
memcpy
(
heart_rate_handle_table
,
param
->
add_attr_tab
.
handles
,
sizeof
(
heart_rate_handle_table
));
esp_ble_gatts_start_service
(
heart_rate_handle_table
[
IDX_SVC
]);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
printf
(
"heart_rate_handle_table[%d] = %d
\r\n
"
,
ii
,
heart_rate_handle_table
[
ii
]);
}
//
for(int ii = 0; ii<4; ii++)
//
{
//
printf("heart_rate_handle_table[%d] = %d\r\n", ii, heart_rate_handle_table[ii]);
//
}
}
}
else
{
if
(
param
->
add_attr_tab
.
status
!=
ESP_GATT_OK
){
...
...
@@ -829,10 +829,10 @@ static void gatts_profile_event_handler(esp_gatts_cb_event_t event, esp_gatt_if_
memcpy
(
heart_rate_handle_table2
,
param
->
add_attr_tab
.
handles
,
sizeof
(
heart_rate_handle_table2
));
esp_ble_gatts_start_service
(
heart_rate_handle_table2
[
IDX_SVC2
]);
for
(
int
ii
=
0
;
ii
<
4
;
ii
++
)
{
printf
(
"heart_rate_handle_table2[%d] = %d
\r\n
"
,
ii
,
heart_rate_handle_table2
[
ii
]);
}
//
for(int ii = 0; ii<4; ii++)
//
{
//
printf("heart_rate_handle_table2[%d] = %d\r\n", ii, heart_rate_handle_table2[ii]);
//
}
}
}
break
;
...
...
qianjiang/main/main_user.c
View file @
c588759b
...
...
@@ -15,9 +15,23 @@
#include "bt_app_main.h"
#include "app_BT_User.h"
#define TAG "MAIN_USER"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "esp_log.h"
#include "driver/uart.h"
#include "string.h"
#include "driver/gpio.h"
#include "MCU_Core_Protocol.h"
#include "Protocol_Lib.h"
#include "app_Ble_User.h"
#include "app_BT_User.h"
#include "bt_app_hf.h"
#define TAG "MAIN_USER"
extern
esp_bd_addr_t
peer_addr
;
uint32_t
Sys_1ms_Cnt
;
#define SYS_RUN_TASK_1MS (1)
...
...
@@ -75,11 +89,14 @@ static void Sys_Run_Tasks(void *arg)
simple_ota_service
();
testcnt
++
;
if
(
testcnt
>=
5
)
if
(
testcnt
>=
10
)
{
testcnt
=
0
;
// printf("BT_User.BT_Sts = %d\r\n", BT_User.BT_Sts);
printf
(
"BT_User.BT_Sts = %d
\r\n
"
,
BT_User
.
BT_Sts
);
printf
(
"Ble_User.Ble_Sts = %d
\r\n
"
,
Ble_User
.
Ble_Sts
);
// esp_log_buffer_hex(TAG, peer_addr, 6);
// printf("Ble_User.Navi_Updat = %d\r\n", Ble_User.Navi_Updat);
...
...
@@ -87,6 +104,45 @@ static void Sys_Run_Tasks(void *arg)
// Ble_Msg_RequestNavi_RLY();
// if(Prot_User.State < Prot_Normal)
// {
// Prot_User.State = Prot_Normal;
// printf("Prot_Normal \r\n");
// }
// if(Prot_User.State >= Prot_Start)
// {
// // if(pData->DataLen == 33)
// {
// // if(BT_User.HF_Ctrl != pData->Data[0])
// // {
// // BT_User.HF_Ctrl = pData->Data[0];
// // }
// // if(strncmp((const char *) ble_uerid, (const char *)&(pData->Data[1]), 32) != 0)
// // {
// // memcpy(( uint8_t * )ble_uerid, (uint8_t *)&(pData->Data[1]), 32);
// // }
// esp_log_buffer_hex(TAG, ble_uerid, 32);
// // esp_log_buffer_hex(TAG, &(pData->Data[1]), 32);
// if(Ble_User.UseridUpdate == 0)
// {
// bsp_Ble_Init();
// printf("get uuid and init ble!!! \r\n");
// }
// Ble_User.UseridUpdate = 0xAA;
// }
// }
}
}
...
...
@@ -105,6 +161,8 @@ void app_main(void)
// bsp_Ble_Init();
bsp_Uart_Init
();
printf
(
"KL30 INIT OVER~~~~~~~~~"
);
xTaskCreatePinnedToCore
(
Sys_Run_Tasks
,
"Sys_Run_Tasks"
,
4096
,
NULL
,
3
,
NULL
,
1
);
}
...
...
qianjiang/sdkconfig
View file @
c588759b
...
...
@@ -213,11 +213,11 @@ CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set
CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
# CONFIG_BOOTLOADER_LOG_LEVEL_INFO is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set
# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set
CONFIG_BOOTLOADER_LOG_LEVEL=
3
CONFIG_BOOTLOADER_LOG_LEVEL=
2
#
# Serial Flash Configurations
...
...
@@ -1336,15 +1336,16 @@ CONFIG_HEAP_TRACING_OFF=y
#
# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
CONFIG_LOG_DEFAULT_LEVEL_WARN=y
# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
CONFIG_LOG_DEFAULT_LEVEL=
3
CONFIG_LOG_DEFAULT_LEVEL=
2
CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y
# CONFIG_LOG_MAXIMUM_LEVEL_INFO is not set
# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set
# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set
CONFIG_LOG_MAXIMUM_LEVEL=
3
CONFIG_LOG_MAXIMUM_LEVEL=
2
CONFIG_LOG_COLORS=y
CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y
# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set
...
...
@@ -1899,11 +1900,11 @@ CONFIG_WPA_MBEDTLS_TLS_CLIENT=y
# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set
CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y
CONFIG_LOG_BOOTLOADER_LEVEL_WARN=y
# CONFIG_LOG_BOOTLOADER_LEVEL_INFO is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set
# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set
CONFIG_LOG_BOOTLOADER_LEVEL=
3
CONFIG_LOG_BOOTLOADER_LEVEL=
2
# CONFIG_APP_ROLLBACK_ENABLE is not set
# CONFIG_FLASH_ENCRYPTION_ENABLED is not set
# CONFIG_FLASHMODE_QIO is not set
...
...
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