蓝牙不开启待查

This commit is contained in:
lmx
2025-10-30 18:30:40 +08:00
parent 1d0eaa037b
commit 517beaa1a8
19 changed files with 158514 additions and 158278 deletions

View File

@ -74,12 +74,7 @@ void send_sensor_data_task(void) {
send_data_to_ble_client(&temp,5);
}
void create_process(u16* pid, const char* name, void *priv, void (*func)(void *priv), u32 msec){
xlog("Create Task: %s, pid=%d\n", name, *pid);
if (*pid != 0) return;
*pid = sys_timer_add(priv, func, msec);
xlog("Task %s is created, pid=%d\n", name, *pid);
}
extern void create_process(u16* pid, const char* name, void *priv, void (*func)(void *priv), u32 msec);
void rcsp_adv_fill_mac_addr(u8 *mac_addr_buf) //by xtell
{
@ -88,15 +83,8 @@ void rcsp_adv_fill_mac_addr(u8 *mac_addr_buf) //by xtell
void xtell_task_create(void){
u8 mac_data[6];
soft_iic_init(0);
extern u8 LIS2DH12_Config(void);
LIS2DH12_Config();
rcsp_adv_fill_mac_addr(mac_data); //读取MAC地址
xlog("xtell BT mac data:%x:%x:%x:%x:%x:%x",mac_data[0],mac_data[1],mac_data[2],mac_data[3],mac_data[4],mac_data[5]);
xlog("xtell_task_create\n");
//开经典蓝牙

View File

@ -14,7 +14,7 @@
#include "bt_profile_cfg.h"
#include "dev_manager/dev_manager.h"
#include "update_loader_download.h"
#include "avctp_user.h"
#define xlog(format, ...) printf("[%s] " format, __func__, ##__VA_ARGS__)
@ -34,6 +34,9 @@ u8 user_at_cmd_send_support = 1;
extern APP_VAR app_var;
u16 close_BL_number=0;
/*
* 2ms timer中断回调函数
@ -73,6 +76,33 @@ static void app_poweron_check(int update)
#endif
}
void create_process(u16* pid,char* name, void *priv, void (*func)(void *priv), u32 msec){
xlog("1 name=%s, pid =%d\n",name,*pid);
if (*pid != 0) return;
*pid = sys_timer_add(priv, func, msec);
xlog("2 name=%s, pid =%d\n",name,*pid);
}
void close_process(u16* pid,char* name){
xlog("name=%s,pid =%d\n",name,*pid);
if (*pid == 0) return;
sys_timer_del(*pid);
*pid = 0;
}
void close_BL(){
/**开机默认关闭 经典蓝牙 */
// close_BL_flag++;
xlog("xtell Classic Bluetooth off\n");
user_send_cmd_prepare(USER_CTRL_DISCONNECTION_HCI, 0, NULL); //断开此时经典蓝牙的连接,经典蓝牙还是可以被发现
delay_2ms(50);
user_send_cmd_prepare(USER_CTRL_WRITE_SCAN_DISABLE, 0, NULL); //关闭蓝牙可发现,已连接时不能操作
delay_2ms(50);
user_send_cmd_prepare(USER_CTRL_WRITE_CONN_DISABLE, 0, NULL); //关闭蓝牙可连接,
// sys_timer_del(close_BL_number); //删除定时器任务
close_process(&close_BL_number,__func__);
}
extern u32 timer_get_ms(void);
void xtell_app_main()
@ -81,7 +111,7 @@ void xtell_app_main()
u32 addr = 0, size = 0;
struct intent it;
xlog("==============xtell_app_main================\n");
xlog("==============xtell_app_main start================\n");
if (!UPDATE_SUPPORT_DEV_IS_NULL()) {
update = update_result_deal();
@ -89,29 +119,54 @@ void xtell_app_main()
app_var_init();
// if (get_charge_online_flag()) {
if (get_charge_online_flag()) {
#if(TCFG_SYS_LVD_EN == 1)
vbat_check_init();
#endif
// init_intent(&it);
// it.name = "idle";
// it.action = ACTION_IDLE_MAIN;
// start_app(&it);
// } else {
xlog("==============idle================\n");
init_intent(&it);
it.name = "idle";
it.action = ACTION_IDLE_MAIN;
start_app(&it);
} else {
xlog("==============handler================\n");
check_power_on_voltage();
app_poweron_check(update);
init_intent(&it);
it.name = "handler";
it.action = ACTION_EARPHONE_MAIN;
start_app(&it);
// }
}
log_info("app_main\n");
app_var.start_time = timer_get_ms();
//////////////////////////////////////////////////
//开机必须延时关闭经典蓝牙,不然底层代码会再次把蓝牙 打开
create_process(&close_BL_number, "close_BL",NULL, close_BL, 3000);
soft_iic_init(0);
extern u8 LIS2DH12_Config(void);
LIS2DH12_Config();
u8 mac_data[6];
rcsp_adv_fill_mac_addr(mac_data); //读取MAC地址
xlog("xtell BT mac data:%x:%x:%x:%x:%x:%x",mac_data[0],mac_data[1],mac_data[2],mac_data[3],mac_data[4],mac_data[5]);
user_send_cmd_prepare(USER_CTRL_WRITE_SCAN_ENABLE, 0, NULL); //打开蓝牙可发现,已连接时不能操作
delay_2ms(50);
user_send_cmd_prepare(USER_CTRL_WRITE_CONN_ENABLE, 0, NULL); //打开蓝牙可连接
delay_2ms(50);
extern void xtell_task_create(void);
xtell_task_create();
xlog("==============xtell_app_end================\n");
}