cun
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
|
||||
#include "system/app_core.h"
|
||||
#include "system/includes.h"
|
||||
#include "btstack/btstack_task.h"
|
||||
@ -5,7 +6,7 @@
|
||||
#include "le_common.h"
|
||||
#include "ble_user.h"
|
||||
|
||||
#if 1 //ENABLE_THIS_TEST
|
||||
#if 0 //ENABLE_THIS_TEST
|
||||
|
||||
#define LOG_TAG_CONST EARPHONE
|
||||
#define LOG_TAG "[BLE_TEST]"
|
||||
|
||||
1569
apps/earphone/xtell_Sensor/client_handler.c
Normal file
1569
apps/earphone/xtell_Sensor/client_handler.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,24 +1,15 @@
|
||||
#include "system/includes.h"
|
||||
/*#include "btcontroller_config.h"*/
|
||||
#include "btstack/btstack_task.h"
|
||||
#include "app_config.h"
|
||||
#include "app_action.h"
|
||||
#include "asm/pwm_led.h"
|
||||
#include "tone_player.h"
|
||||
#include "gpio.h"
|
||||
#include "app_main.h"
|
||||
#include "asm/charge.h"
|
||||
#include "update.h"
|
||||
#include "update_loader_download.h"
|
||||
#include "app_power_manage.h"
|
||||
#include "app_charge.h"
|
||||
#include "bt_profile_cfg.h"
|
||||
#include "dev_manager/dev_manager.h"
|
||||
#include "update_loader_download.h"
|
||||
#include "avctp_user.h"
|
||||
#include "debug.h"
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//宏定义
|
||||
#define ENABLE_XLOG 1
|
||||
@ -41,89 +32,71 @@
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//变量
|
||||
|
||||
//-------------------------------------------------------------------------------------------------//
|
||||
// 外部函数/变量声明
|
||||
//-------------------------------------------------------------------------------------------------//
|
||||
extern APP_VAR app_var;
|
||||
u16 close_BL_number=0;
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//函数定义
|
||||
extern void timer_2ms_handler();
|
||||
extern void app_var_init(void);
|
||||
void app_earphone_play_voice_file(const char *name);
|
||||
void clr_wdt(void);
|
||||
extern void check_power_on_key(void);
|
||||
extern int cpu_reset_by_soft();
|
||||
extern int audio_dec_init();
|
||||
extern int audio_enc_init();
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------------------//
|
||||
// 系统主函数 app_main
|
||||
//-------------------------------------------------------------------------------------------------//
|
||||
|
||||
|
||||
|
||||
/*充电拔出,CPU软件复位, 不检测按键,直接开机*/
|
||||
static void app_poweron_check(int update)
|
||||
{
|
||||
if (!update && cpu_reset_by_soft()) {
|
||||
app_var.play_poweron_tone = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
void create_process(u16* pid,char* name, void *priv, void (*func)(void *priv), u32 msec){
|
||||
/**
|
||||
* @brief 创建一个周期性执行的系统定时器任务
|
||||
*/
|
||||
void create_process(u16* pid, const 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){
|
||||
|
||||
/**
|
||||
* @brief 关闭一个系统定时器任务
|
||||
*/
|
||||
void close_process(u16* pid, const char* name){
|
||||
xlog("name=%s,pid =%d\n",name,*pid);
|
||||
if (*pid == 0) return;
|
||||
sys_timer_del(*pid);
|
||||
*pid = 0;
|
||||
*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__);
|
||||
/*充电拔出,CPU软件复位, 不检测按键,直接开机*/
|
||||
static void app_poweron_check(int update)
|
||||
{
|
||||
extern int cpu_reset_by_soft();
|
||||
if (!update && cpu_reset_by_soft()) {
|
||||
app_var.play_poweron_tone = 0;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void xtell_set_ble_name(char* name){
|
||||
|
||||
}
|
||||
|
||||
|
||||
extern u32 timer_get_ms(void);
|
||||
/**
|
||||
* @brief 应用层主入口
|
||||
*/
|
||||
void xtell_app_main()
|
||||
{
|
||||
int update = 0;
|
||||
u32 addr = 0, size = 0;
|
||||
struct intent it;
|
||||
|
||||
xlog("==============xtell_app_main start================\n");
|
||||
log_info("app_main\n");
|
||||
extern u32 timer_get_ms(void);
|
||||
app_var.start_time = timer_get_ms();
|
||||
|
||||
|
||||
|
||||
// 检查是否有固件升级
|
||||
if (!UPDATE_SUPPORT_DEV_IS_NULL()) {
|
||||
update = update_result_deal();
|
||||
}
|
||||
|
||||
// 初始化应用层变量
|
||||
extern void app_var_init(void);
|
||||
app_var_init();
|
||||
|
||||
// 根据充电状态决定进入 idle 模式还是 handler 模式
|
||||
if (get_charge_online_flag()) {
|
||||
#if(TCFG_SYS_LVD_EN == 1)
|
||||
vbat_check_init();
|
||||
@ -144,30 +117,5 @@ void xtell_app_main()
|
||||
xlog("==============handler end================\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
//开机必须延时关闭经典蓝牙,不然底层代码会再次把蓝牙 打开
|
||||
// create_process(&close_BL_number, "close_BL",NULL, close_BL, 3000);
|
||||
|
||||
|
||||
|
||||
|
||||
u8 mac_data[6];
|
||||
extern void rcsp_adv_fill_mac_addr(u8 *mac_addr_buf);
|
||||
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);
|
||||
|
||||
|
||||
|
||||
xlog("==============xtell_app_end================\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -302,8 +302,8 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
ble_bqb_test_thread_init();
|
||||
} else {
|
||||
#if !TCFG_WIRELESS_MIC_ENABLE
|
||||
bt_ble_init();
|
||||
xtell_ble_central_test_start();
|
||||
// bt_ble_init();
|
||||
// xtell_ble_central_test_start(); //xtell
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@ -337,7 +337,7 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
bt_newname =1;
|
||||
u8 temp[5]={0xBB,0xBE,0x02,0x04,0x00};
|
||||
temp[4] = xtell_bl_state; //经典蓝牙连接状态
|
||||
send_data_to_ble_client(&temp,5);
|
||||
// send_data_to_ble_client(&temp,5);
|
||||
}
|
||||
earphone_change_pwr_mode(PWR_DCDC15, 3000);
|
||||
sys_auto_shut_down_disable();
|
||||
@ -370,7 +370,7 @@ static int bt_connction_status_event_handler(struct bt_event *bt)
|
||||
bt_newname=0;
|
||||
u8 temp[5]={0xBB,0xBE,0x02,0x04,0x00};
|
||||
temp[4] = xtell_bl_state; //经典蓝牙连接状态
|
||||
send_data_to_ble_client(&temp,5);
|
||||
// send_data_to_ble_client(&temp,5);
|
||||
}
|
||||
if (app_var.goto_poweroff_flag) {
|
||||
/*关机不播断开提示音*/
|
||||
|
||||
Reference in New Issue
Block a user