This commit is contained in:
lmx
2025-12-09 16:30:25 +08:00
parent 3f02a9f9be
commit 2f4e1d7e5b
14 changed files with 647 additions and 42 deletions

View File

@ -628,6 +628,7 @@ c_SRC_FILES := \
apps/earphone/xtell_Sensor/sensor/MMC56.c \
apps/earphone/xtell_Sensor/sensor/BMP280.c \
apps/earphone/xtell_Sensor/sensor/AK8963.c \
apps/earphone/xtell_Sensor/sensor/WF282A.c \
# 需要编译的 .S 文件

View File

@ -26,6 +26,7 @@
#include "./sensor/MMC56.h"
#include "./sensor/BMP280.h"
#include "./sensor/AK8963.h"
#include "./sensor/WF282A.h"
#include "asm/rtc.h"
#include "system/timer.h"
#include "adv_time_stamp_setting.h"
@ -167,7 +168,11 @@ void sensor_collect_task(void){
if(interval >= 4){
interval = 0;
SL_data_index = 0;
#if BMP280
bmp280_read_data(&temperature, &pressure);//每40ms读取一次
#else
WF_GET_Temperature_Pressure(&temperature, &pressure);
#endif
for(int i = 0;i<MPU_FIFO_LEN;i++){
send_data.sensor_package[i].temperature = (int16_t)(temperature * 1000.0f);
send_data.sensor_package[i].pressure = (int32_t)(pressure * 1000.0f);
@ -260,14 +265,14 @@ void data_log(uint8_t* data){
float pressure = (float)press_raw / 1000.0f;
// 打印解析后的数据
// if(i % 8 == 0){
// printf(" ==================ble index: %d\n", *p);
// printf("Package[%d]:\n", i);
// printf(" ACC(g): x=%.3f, y=%.3f, z=%.3f\n", acc_g[0], acc_g[1], acc_g[2]);
// printf(" GYR(dps):x=%.3f, y=%.3f, z=%.3f\n", gyr_dps[0], gyr_dps[1], gyr_dps[2]);
// printf(" MAG(Gs): x=%.3f, y=%.3f, z=%.3f\n", mag_gauss[0], mag_gauss[1], mag_gauss[2]);
// printf(" TEMP(C): %.3f, PRESS(Pa): %.3f\n", temperature, pressure);
// }
if(i % 8 == 0){
printf(" ==================ble index: %d\n", *p);
printf("Package[%d]:\n", i);
printf(" ACC(g): x=%.3f, y=%.3f, z=%.3f\n", acc_g[0], acc_g[1], acc_g[2]);
printf(" GYR(dps):x=%.3f, y=%.3f, z=%.3f\n", gyr_dps[0], gyr_dps[1], gyr_dps[2]);
printf(" MAG(Gs): x=%.3f, y=%.3f, z=%.3f\n", mag_gauss[0], mag_gauss[1], mag_gauss[2]);
printf(" TEMP(C): %.3f, PRESS(Pa): %.3f\n", temperature, pressure);
}
}
// printf("--- End of Packet ---\n\n");
@ -511,7 +516,11 @@ void test_func(void){
SL_SC7U22_Config();
mmc5603nj_init();
bmp280_init();
#if BMP280
BMP280_init();
#else
WF_Init();
#endif
os_task_create(BLE_send_fuc,NULL,5,1024,32,"BLE_send_fuc");
os_task_create(sensor_collect_task,NULL,5,1024,32,"sensor_collect_task");
// create_process(&test_id, "sensor_test",NULL,data_send_task ,3);

View File

@ -135,18 +135,18 @@ static float compensate_pressure(int32_t adc_P) {
uint8_t bmp280_init(void) {
uint8_t BMP280_init(void) {
uint8_t id;
uint8_t calib_data[24];
// 1. 检查芯片ID
if (bmp280_read_regs(BMP280_REG_ID, &id, 1) == 0) {
printf("bmp280 get id error:%d\n",id );
return 1; // I2C读取失败
// return 1; // I2C读取失败
}
if (id != 0x58) {
printf("bmp280 check diff:%d\n",id );
return 1; // ID不匹配
// return 1; // ID不匹配
}
printf("bmp280 get id:0%X\n",id );

View File

@ -4,7 +4,7 @@
#include <stdint.h>
#define BMP_PULL_UP 0 //外部是否接的上拉
#define BMP_PULL_UP 1 //外部是否接的上拉
// I2C 从设备地址
#if BMP_PULL_UP == 1 //外部接的高
@ -33,7 +33,7 @@
* @return 0: 成功, 1: 芯片ID错误, 2: 读取校准参数失败
* @note 此函数会完成ID检查、软复位、读取校准参数并设置传感器为连续测量模式。
*/
uint8_t bmp280_init(void);
uint8_t BMP280_init(void);
/**
* @brief 从BMP280读取温度和气压数据

View File

@ -6,6 +6,15 @@
#include <stdint.h> // 推荐使用标准类型
#include "gSensor/gSensor_manage.h"
#define ENABLE_XLOG 1
#ifdef xlog
#undef xlog
#endif
#if ENABLE_XLOG
#define xlog(format, ...) printf("[XT:%s] " format, __func__, ##__VA_ARGS__)
#else
#define xlog(format, ...) ((void)0)
#endif
/*==================================================================================*/
/* WF282A 内部定义 */
/*==================================================================================*/
@ -109,13 +118,14 @@ uint8_t WF_Init() {
// 1. 配置传感器工作模式
// 推荐配置压力8次过采样温度1次过采样测量速率16Hz
wf282a_write_reg(WF_PRS_CFG, (PM_RATE_16 << 4) | PM_PRC_8);
wf282a_write_reg(WF_TMP_CFG, (TMP_RATE_16 << 4) | TMP_PRC_1 | TMP_INT_SENSOR);
wf282a_write_reg(WF_PRS_CFG, (PM_RATE_32 << 4) | PM_PRC_32);
wf282a_write_reg(WF_TMP_CFG, TMP_INT_SENSOR | (TMP_RATE_32 << 4) | TMP_PRC_32);
wf282a_write_reg(WF_MEAS_CFG, 0x07); // 启动连续压力和温度测量
wf282a_write_reg(WF_CFG_REG, 0x00); // 无中断或FIFO移位配置
// 2. 一次性读取所有校准系数 (从0x10到0x21共18字节)
if (wf282a_read_regs(COEF_C0, calib_buf, 18) != 0) {
if (wf282a_read_regs(COEF_C0, calib_buf, 18) == 0) {
xlog("Failed to read the calibration coefficient\n");
return 2; // 读取校准数据失败
}
parse_calibration_data(calib_buf);
@ -123,6 +133,7 @@ uint8_t WF_Init() {
// 3. 检查配置是否写入成功
wf282a_read_regs(WF_MEAS_CFG, &check_cfg, 1);
if (check_cfg != 0x07) {
xlog("WF_Init error, check_cfg: %d\n", check_cfg);
return 1; // 错误
} else {
return 0; // 成功
@ -168,6 +179,19 @@ float WF_Pressure_Calculate() {
return Pcomp;
}
void WF_GET_Temperature_Pressure(float* temperature, float* precessure){
int32_t Traw = Get_Traw();
int32_t Praw = Get_Praw();
float Traw_sc = (float)Traw / KT;// 缩放原始温度值
float Praw_sc = (float)Praw / KP;// 缩放原始压力值
*temperature = (float)c0 * 0.5f + (float)c1 * Traw_sc;
*precessure = (float)c00
+ Praw_sc * ((float)c10 + Praw_sc * ((float)c20 + Praw_sc * (float)c30))
+ Traw_sc * (float)c01
+ Traw_sc * Praw_sc * ((float)c11 + Praw_sc * (float)c21);
}
float WF_Altitude_Calculate() {
float pressure_pa = WF_Pressure_Calculate();
// 使用标准大气压公式计算海拔

View File

@ -4,8 +4,19 @@
#include <stdint.h> // 使用标准整数类型
// 标定值
#define KT 524288.0f
#define KP 1572864.0f
/*
Oversampling Rate Scale Factor (kP or kT
1 (single) 524288
2 times (Low Power) 1572864
4 times 3670016
8 times 7864320
16 times (Standard) 253952
32 times 516096
64 times (High Precision) 1040384
128 times 2088960
*/
#define KT 516096.0f //温度
#define KP 516096.0f //压力
#define WF_PULL_UP 1 //外部是否接的上拉
@ -95,7 +106,7 @@
#define TMP_RATE_32 0x05 // 32 次/秒
#define TMP_RATE_64 0x06 // 64 次/秒
#define TMP_RATE_128 0x07 // 128 次/秒
// 温度配置 (TMP_CFG[3:0]) - 过采样率
// 温度配置 (TMP_CFG[2:0]) - 过采样率
#define TMP_PRC_1 0x00 // 1 次
#define TMP_PRC_2 0x01 // 2 次
#define TMP_PRC_4 0x02 // 4 次
@ -145,4 +156,6 @@ float WF_Pressure_Calculate(void);
*/
float WF_Temperature_Calculate(void);
void WF_GET_Temperature_Pressure(float* temperature, float* precessure);
#endif // _WF282A_H_

View File

@ -7,4 +7,6 @@
#define ACC_RANGE 16 //g加速度满量程:2、4、8、16
#define BMP280 1
#endif

View File

@ -49,6 +49,7 @@
#include "./sensor/MMC56.h"
#include "./sensor/BMP280.h"
#include "./sensor/AK8963.h"
#include "./sensor/WF282A.h"
#include "./calculate/skiing_tracker.h"
///////////////////////////////////////////////////////////////////////////////////////////////////
//宏定义
@ -83,13 +84,13 @@ extern u8 init_ok;
extern u8 sniff_out;
unsigned char xtell_bl_state=0; //存放经典蓝牙的连接状态0断开1是连接
u8 bt_newname =0;
unsigned char xt_ble_new_name[9] = "skiing_2F";
unsigned char xt_ble_new_name[9] = "skiing_D7";
static u16 play_poweron_ok_timer_id = 0;
// -- 初始化标志位 --
u8 SC7U22_init = 0x10; //六轴是否初始化
u8 MMC5603nj_init = 0x20; //地磁是否初始化
u8 BMP280_init = 0x30; //气压计初始化
u8 barometer_init = 0x30; //气压计初始化
u8 foot_init = 0x40; //数据来源初始化左脚0x41 or 右脚0x42
// -- 线程id --
@ -232,6 +233,7 @@ void le_user_app_event(u8* buffer){
send_data_to_ble_client(&send2_0,5);
// start_calibration();
}else if(buffer[4] == 0x02){ //地磁
if(mmc5603nj_init() == 0){
MMC5603nj_init = 0x20;
send2_0[4] = MMC5603nj_init; //地磁初始化失败
@ -242,16 +244,29 @@ void le_user_app_event(u8* buffer){
send2_0[4] = MMC5603nj_init; //地磁初始化成功
send_data_to_ble_client(&send2_0,5);
}else if(buffer[4] == 0x03){ //气压计初始化
if(bmp280_init() != 0){
#if BMP280
if(BMP280_init() != 0){
//初始化失败
BMP280_init = 0x30;
send2_0[4] = BMP280_init;
barometer_init = 0x30;
send2_0[4] = barometer_init;
send_data_to_ble_client(&send2_0,5);
return;
}
BMP280_init = 0x31;
send2_0[4] = BMP280_init; //气压计初始化成功
barometer_init = 0x31;
send2_0[4] = barometer_init; //气压计初始化成功
send_data_to_ble_client(&send2_0,5);
#else
if(WF_Init() != 0){
//初始化失败
barometer_init = 0x30;
send2_0[4] = barometer_init;
send_data_to_ble_client(&send2_0,5);
return;
}
barometer_init = 0x31;
send2_0[4] = barometer_init; //气压计初始化成功
send_data_to_ble_client(&send2_0,5);
#endif
}
break;
case 0x01: //设置传感器采集对象左脚or右脚
@ -271,13 +286,13 @@ void le_user_app_event(u8* buffer){
}else if(buffer[4] == 0x02){ //地磁
send2_2[4] = MMC5603nj_init;
}else if(buffer[4] == 0x03){ //气压计
send2_2[4] = BMP280_init;
send2_2[4] = barometer_init;
}
send_data_to_ble_client(&send2_2,5);
break;
case 0x03: //开始/停止滑雪计算
if(buffer[4] == 0x01){ //开始滑雪计算
if(SC7U22_init == 0x10 || MMC5603nj_init == 0x20 || BMP280_init == 0x30){ //传感器未进行初始化
if(SC7U22_init == 0x10 || MMC5603nj_init == 0x20 || barometer_init == 0x30){ //传感器未进行初始化
u8 send2_3[5] = {0xBB,0xBE,0x02,0x00,0x00};
send_data_to_ble_client(&send2_3,5);
return;
@ -366,15 +381,15 @@ void le_user_app_event_handler(struct sys_event* event){
send2_0[4] = MMC5603nj_init; //地磁初始化成功
send_data_to_ble_client(&send2_0,5);
}else if(event->u.app.buffer[4] == 0x03){ //气压计初始化
if(bmp280_init() != 0){
if(BMP280_init() != 0){
//初始化失败
BMP280_init = 0x30;
send2_0[4] = BMP280_init;
barometer_init = 0x30;
send2_0[4] = barometer_init;
send_data_to_ble_client(&send2_0,5);
return;
}
BMP280_init = 0x31;
send2_0[4] = BMP280_init; //气压计初始化成功
barometer_init = 0x31;
send2_0[4] = barometer_init; //气压计初始化成功
send_data_to_ble_client(&send2_0,5);
}
break;
@ -395,13 +410,13 @@ void le_user_app_event_handler(struct sys_event* event){
}else if(event->u.app.buffer[4] == 0x02){ //地磁
send2_2[4] = MMC5603nj_init;
}else if(event->u.app.buffer[4] == 0x03){ //气压计
send2_2[4] = BMP280_init;
send2_2[4] = barometer_init;
}
send_data_to_ble_client(&send2_2,5);
break;
case 0x03: //开始/停止滑雪计算
if(event->u.app.buffer[4] == 0x01){ //开始滑雪计算
if(SC7U22_init == 0x10 || MMC5603nj_init == 0x20 || BMP280_init == 0x30){ //传感器未进行初始化
if(SC7U22_init == 0x10 || MMC5603nj_init == 0x20 || barometer_init == 0x30){ //传感器未进行初始化
u8 send2_3[5] = {0xBB,0xBE,0x02,0x00,0x00};
send_data_to_ble_client(&send2_3,5);
return;

View File

@ -0,0 +1,528 @@
#include "system/includes.h"
#include "media/includes.h"
#include "tone_player.h"
#include "earphone.h"
#include "app_config.h"
#include "app_action.h"
#include "app_task.h"
#include "btstack/avctp_user.h"
#include "btstack/btstack_task.h"
#include "btctrler/btctrler_task.h"
#include "btstack/frame_queque.h"
#include "user_cfg.h"
// #include "aec_user.h"
#include "classic/hci_lmp.h"
#include "bt_common.h"
#include "bt_ble.h"
#include "bt_tws.h"
#include "pbg_user.h"
#include "btstack/bluetooth.h"
#include "colorful_lights/colorful_lights.h"
#include "app_chargestore.h"
#include "jl_kws/jl_kws_api.h"
#include "asm/charge.h"
#include "app_charge.h"
#include "ui_manage.h"
#include "app_chargestore.h"
#include "app_umidigi_chargestore.h"
#include "app_testbox.h"
#include "app_online_cfg.h"
#include "app_main.h"
#include "app_power_manage.h"
#include "gSensor/gSensor_manage.h"
#include "key_event_deal.h"
#include "classic/tws_api.h"
#include "asm/pwm_led.h"
#include "ir_sensor/ir_manage.h"
#include "in_ear_detect/in_ear_manage.h"
#include "vol_sync.h"
#include "bt_background.h"
#include "default_event_handler.h"
#include "debug.h"
#include "system/event.h"
#include "../nvs/nvs.h"
#if (JL_EARPHONE_APP_EN)
#include "rcsp_adv_bluetooth.h"
#endif
///////////////////////////////////////////////////////////////////////////////////////////////////
//宏定义
#define LOG_TAG_CONST EARPHONE
#define LOG_TAG "[EARPHONE]"
#define LOG_ERROR_ENABLE
#define LOG_DEBUG_ENABLE
#define xlog_ENABLE
#if(USE_DMA_UART_TEST) //使用dm串口测试时不能同时打开
#define MY_SNIFF_EN 0
#else
#define MY_SNIFF_EN 1 //默认打开
#endif
#define ENABLE_XLOG 1
#ifdef xlog
#undef xlog
#endif
#if ENABLE_XLOG
#define xlog(format, ...) printf("[XT:%s] " format, __func__, ##__VA_ARGS__)
#else
#define xlog(format, ...) ((void)0)
#endif
//
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
//变量
extern u8 init_ok;
extern u8 sniff_out;
unsigned char xtell_bl_state=0; //存放经典蓝牙的连接状态0断开1是连接
u8 bt_newname =0;
unsigned char xt_ble_new_name[9] = "CM-55555";
static u16 play_poweron_ok_timer_id = 0;
// -- 初始化标志位 --
u8 SC7U22_init = 0x10; //六轴是否初始化
u8 MMC5603nj_init = 0x20; //地磁是否初始化
u8 barometer_init = 0x30; //气压计初始化
// -- 线程id --
u16 SC7U22_calibration_id;
u16 start_collect_fuc_id;
u16 BLE_send_fuc_id;
u16 rfid_fuc_id;
//
///////////////////////////////////////////////////////////////////////////////////////////////////
extern int bt_hci_event_handler(struct bt_event *bt);
extern void SC7U22_static_calibration(void);
extern void create_process(u16* pid, const char* name, void *priv, void (*func)(void *priv), u32 msec);
extern void close_process(u16* pid,char* name);
extern void start_collect_fuc(void);
extern void BLE_send_fuc(void);
extern void xtell_ble_central_test_start(void);
///////////////////////////////////////////////////////////////////////////////////////////////////
/*
* 模式状态机, 通过start_app()控制状态切换
*/
/* extern int audio_mic_init(); */
static int state_machine(struct application *app, enum app_state state, struct intent *it){
int error = 0;
static u8 tone_player_err = 0;
xlog("bt_state_machine=%d\n", state);
switch (state) {
case APP_STA_CREATE:
xlog("APP_STA_CREATE\n");
/* set_adjust_conn_dac_check(0); */
break;
case APP_STA_START:
xlog("APP_STA_START\n");
if (!it) {
xlog("APP_STA_START:it none\n");
break;
}
switch (it->action) {
case ACTION_EARPHONE_MAIN:
xlog("ble init\n");
/*
* handler 初始化
*/
clk_set("sys", BT_NORMAL_HZ);
u32 sys_clk = clk_get("sys");
bt_pll_para(TCFG_CLOCK_OSC_HZ, sys_clk, 0, 0);
/* bredr_set_dut_enble(1, 1); */
bt_function_select_init();
bredr_handle_register();
EARPHONE_STATE_INIT();
btstack_init();
sys_auto_shut_down_enable();
bt_sniff_feature_init();
sys_auto_sniff_controle(MY_SNIFF_EN, NULL);
app_var.dev_volume = -1;
break;
case ACTION_A2DP_START: //蓝牙音频传输协议
xlog("ACTION_A2DP_START\n");
break;
case ACTION_BY_KEY_MODE:
xlog("ACTION_BY_KEY_MODE\n");
break;
case ACTION_TONE_PLAY:
xlog("ACTION_TONE_PLAY\n");
// STATUS *p_tone = get_tone_config();
// tone_play_index(p_tone->bt_init_ok, 1);
break;
case ACTION_DO_NOTHING:
xlog("ACTION_DO_NOTHING\n");
break;
}
break;
case APP_STA_PAUSE:
xlog("APP_STA_PAUSE\n");
break;
case APP_STA_RESUME:
xlog("APP_STA_RESUME\n");
//恢复前台运行
sys_auto_shut_down_disable();
sys_key_event_enable();
break;
case APP_STA_STOP:
xlog("APP_STA_STOP\n");
break;
case APP_STA_DESTROY:
xlog("APP_STA_DESTROY\n");
r_printf("APP_STA_DESTROY\n");
if (!app_var.goto_poweroff_flag) {
bt_app_exit(NULL);
}
break;
}
xlog("state machine error\n");
return error;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
//handle
void le_user_app_send_event(size_t command, unsigned char* data, size_t size)
{
// 中断->事件
static unsigned char buffer[512];
if(data && size && size <= sizeof(buffer)) {
// 拷贝到缓存,避免转发事件的时候,地址发送改变。
memcpy(buffer, data, size);
struct sys_event event;
event.type = SYS_APP_USER_EVENT;
event.u.app.command = command;
event.u.app.buffer = buffer;
event.u.app.size = size;
sys_event_notify(&event);
}
}
void le_user_app_event_handler(struct sys_event* event){
switch (event->type) {
// 打印接收到的数据
printf("BLE data\n");
put_buf(event->u.app.buffer, event->u.app.size);
case SYS_APP_USER_EVENT:
if (event->u.app.buffer[0] == 0xBE && event->u.app.buffer[1] == 0xBB) {
if(event->u.app.buffer[2] == 0x01){ //后面的数据长度 1
switch (event->u.app.buffer[3]){
case 0x01:
nvs_test_factory_info();
break;
case 0x02:
// factory_info_t read_info;;
// nvs_read_factory_info(&read_info);
extern void rfid_task_fuc(void);
create_process(&rfid_fuc_id,"rfid",NULL,rfid_task_fuc,2000);
break;
case 0xff: //测试
int ret = hw_iic_init(0);
// int ret = soft_iic_init(0);
xlog("init iic result:%d\n", ret); //返回0成功
extern void i2c_scanner_probe(void);
i2c_scanner_probe();
break;
default:
break;
}
}else if(event->u.app.buffer[2] == 0x02){ //后面数据长度为2
switch (event->u.app.buffer[3]){ //数据包类型
case 0x00:
break;
}
}
}
break;
default:
xlog("%d\n",event->type);
break;
}
}
static void play_poweron_ok_timer(void *priv)
{
app_var.wait_timer_do = 0;
log_d("\n-------play_poweron_ok_timer-------\n", priv);
if (is_dac_power_off()) {
#if TCFG_USER_TWS_ENABLE
bt_tws_poweron();
#else
bt_wait_connect_and_phone_connect_switch(0);
#endif
return;
}
app_var.wait_timer_do = sys_timeout_add(priv, play_poweron_ok_timer, 100);
}
static void play_bt_connect_dly(void *priv)
{
app_var.wait_timer_do = 0;
log_d("\n-------play_bt_connect_dly-------\n", priv);
if (!app_var.goto_poweroff_flag) {
STATUS *p_tone = get_tone_config();
tone_play_index(p_tone->bt_connect_ok, 1);
}
}
static int bt_connction_status_event_handler(struct bt_event *bt)
{
STATUS *p_tone = get_tone_config();
u8 *phone_number = NULL;
switch (bt->event) {
case BT_STATUS_INIT_OK:
/*
* 蓝牙初始化完成
*/
xlog("BT_STATUS_INIT_OK\n");
init_ok = 1;
__set_sbc_cap_bitpool(38);
#if (TCFG_USER_BLE_ENABLE)
if (BT_MODE_IS(BT_BQB)) {
ble_bqb_test_thread_init();
} else {
#if !TCFG_WIRELESS_MIC_ENABLE
bt_ble_init(); // lmx初始化完初始化ble决定ble是作为主设备还是从设备
// xtell_ble_central_test_start(); //xtell
#endif
}
#endif
bt_init_ok_search_index();
#if TCFG_TEST_BOX_ENABLE
testbox_set_bt_init_ok(1);
#endif
#if ((CONFIG_BT_MODE == BT_BQB)||(CONFIG_BT_MODE == BT_PER))
bt_wait_phone_connect_control(1);
#else
if (is_dac_power_off()) {
bt_wait_connect_and_phone_connect_switch(0);
} else {
app_var.wait_timer_do = sys_timeout_add(NULL, play_poweron_ok_timer, 100);
}
#endif
/*if (app_var.play_poweron_tone) {
tone_play_index(p_tone->power_on, 1);
}*/
break;
case BT_STATUS_SECOND_CONNECTED:
clear_current_poweron_memory_search_index(0);
case BT_STATUS_FIRST_CONNECTED:
xlog("BT_STATUS_CONNECTED\n");
xtell_bl_state = 1; //蓝牙连接成功 置1
if(strcmp(xt_ble_new_name,"CM-11111") != 0){
//蓝牙连接成功
bt_newname =1;
u8 temp[5]={0xBB,0xBE,0x02,0x04,0x00};
temp[4] = xtell_bl_state; //经典蓝牙连接状态
// send_data_to_ble_client(&temp,5);
}
earphone_change_pwr_mode(PWR_DCDC15, 3000);
sys_auto_shut_down_disable();
ui_update_status(STATUS_BT_CONN); //单台在此处设置连接状态,对耳的连接状态需要同步在bt_tws.c中去设置
/* tone_play(TONE_CONN); */
/*os_time_dly(40); // for test*/
xlog("tone status:%d\n", tone_get_status());
if (get_call_status() == BT_CALL_HANGUP) {
if (app_var.phone_dly_discon_time) {
sys_timeout_del(app_var.phone_dly_discon_time);
app_var.phone_dly_discon_time = 0;
} else {
app_var.wait_timer_do = sys_timeout_add(NULL, play_bt_connect_dly, 1600);
/* tone_play_index(p_tone->bt_connect_ok, 1); */
}
}
/*int timeout = 5000 + rand32() % 10000;
sys_timeout_add(NULL, connect_phone_test, timeout);*/
break;
case BT_STATUS_FIRST_DISCONNECT:
case BT_STATUS_SECOND_DISCONNECT:
xlog("BT_STATUS_DISCONNECT\n");
xtell_bl_state = 0; //断开蓝牙 清0
//蓝牙断开连接
if(bt_newname){ //已经改成新蓝牙名字,断开才播报
bt_newname=0;
u8 temp[5]={0xBB,0xBE,0x02,0x04,0x00};
temp[4] = xtell_bl_state; //经典蓝牙连接状态
// send_data_to_ble_client(&temp,5);
}
if (app_var.goto_poweroff_flag) {
/*关机不播断开提示音*/
/*关机时不改UI*/
break;
}
// bt_discon_dly_handle(NULL);
break;
//phone status deal
case BT_STATUS_PHONE_INCOME:
break;
case BT_STATUS_PHONE_OUT:
break;
case BT_STATUS_PHONE_ACTIVE:
break;
case BT_STATUS_PHONE_HANGUP:
break;
case BT_STATUS_PHONE_NUMBER:
break;
case BT_STATUS_INBAND_RINGTONE: //铃声
break;
case BT_STATUS_CALL_VOL_CHANGE:
break;
case BT_STATUS_SNIFF_STATE_UPDATE:
xlog(" BT_STATUS_SNIFF_STATE_UPDATE %d\n", bt->value); //0退出SNIFF
if (bt->value == 0) {
sniff_out = 1;
sys_auto_sniff_controle(MY_SNIFF_EN, bt->args);
} else {
sys_auto_sniff_controle(0, bt->args);
}
break;
case BT_STATUS_LAST_CALL_TYPE_CHANGE:
break;
case BT_STATUS_CONN_A2DP_CH:
case BT_STATUS_CONN_HFP_CH:
if ((!is_1t2_connection()) && (get_current_poweron_memory_search_index(NULL))) { //回连下一个device
if (get_esco_coder_busy_flag()) {
clear_current_poweron_memory_search_index(0);
} else {
user_send_cmd_prepare(USER_CTRL_START_CONNECTION, 0, NULL);
}
}
break;
case BT_STATUS_PHONE_MANUFACTURER:
break;
case BT_STATUS_VOICE_RECOGNITION:
break;
case BT_STATUS_AVRCP_INCOME_OPID:
xlog("BT_STATUS_AVRCP_INCOME_OPID:%d\n", bt->value);
break;
default:
xlog(" BT STATUS DEFAULT\n");
break;
}
return 0;
}
static int event_handler(struct application *app, struct sys_event *event)
{
le_user_app_event_handler(event);
if (SYS_EVENT_REMAP(event)) {
g_printf("****SYS_EVENT_REMAP**** \n");
return 0;
}
switch (event->type) {
case SYS_KEY_EVENT:
break;
case SYS_BT_EVENT:
/*
* 蓝牙事件处理
*/
if ((u32)event->arg == SYS_BT_EVENT_TYPE_CON_STATUS) {
printf("in event_handler:bt_connction_status_event_handler");
bt_connction_status_event_handler(&event->u.bt);
} else if ((u32)event->arg == SYS_BT_EVENT_TYPE_HCI_STATUS) {
bt_hci_event_handler(&event->u.bt);
}
break;
case SYS_DEVICE_EVENT:
/*
* 系统设备事件处理
*/
if ((u32)event->arg == DEVICE_EVENT_FROM_CHARGE) {
} else if ((u32)event->arg == DEVICE_EVENT_FROM_POWER) {
return app_power_event_handler(&event->u.dev);
}
#if (JL_EARPHONE_APP_EN)
else if ((u32)event->arg == DEVICE_EVENT_FROM_RCSP) {
xlog("DEVICE_EVENT_FROM_RCSP: %d", event->u.rcsp.event);
switch (event->u.rcsp.event) {
case MSG_JL_UPDATE_START:
xlog(">>> Xtell APP: MSG_JL_UPDATE_START\n");
// You can add UI notifications here, like LED blinking or a tone.
break;
default:
break;
}
}
#endif
#if TCFG_UMIDIGI_BOX_ENABLE
else if ((u32)event->arg == DEVICE_EVENT_UMIDIGI_CHARGE_STORE) {
app_umidigi_chargestore_event_handler(&event->u.umidigi_chargestore);
}
#endif
#if TCFG_TEST_BOX_ENABLE
else if ((u32)event->arg == DEVICE_EVENT_TEST_BOX) {
app_testbox_event_handler(&event->u.testbox);
}
#endif
break;
default:
return false;
}
SYS_EVENT_HANDLER_SPECIFIC(event);
#ifdef CONFIG_BT_BACKGROUND_ENABLE
if (app) {
default_event_handler(event);
}
#endif
return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
static const struct application_operation app_handler_ops = {
.state_machine = state_machine,
.event_handler = event_handler,
};
/*
* 注册earphone模式
*/
REGISTER_APPLICATION(app_handler) = {
.name = "handler",
.action = ACTION_EARPHONE_MAIN,
.ops = &app_handler_ops,
.state = APP_STA_DESTROY,
};

Binary file not shown.

View File

@ -10,7 +10,7 @@ copy ..\..\ota.bin .
copy ..\..\anc_coeff.bin .
copy ..\..\anc_gains.bin .
..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg p11_code.bin ..\..\eq_cfg_hw.bin -uboot_compress -format all
..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br28 -boot 0x120000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin -res ..\..\cfg_tool.bin tone.cfg p11_code.bin ..\..\eq_cfg_hw.bin -uboot_compress -format all -key 646-AC690X-7603.key
@REM..\..\isd_download.exe ..\..\isd_config.ini -tonorflash -dev br34 -boot 0x20000 -div8 -wait 300 -uboot ..\..\uboot.boot -app ..\..\app.bin ..\..\cfg_tool.bin -res tone.cfg kws_command.bin p11_code.bin -uboot_compress

File diff suppressed because one or more lines are too long

View File

@ -5305,7 +5305,7 @@ objs/apps/earphone/xtell_Sensor/xtell_handler.c.o
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,test_func,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,SL_SC7U22_Config,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,mmc5603nj_init,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,bmp280_init,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,BMP280_init,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,start_clloct,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,stop_clloct,l
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,le_user_app_send_event,pl
@ -5354,7 +5354,7 @@ objs/apps/earphone/xtell_Sensor/xtell_handler.c.o
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,xt_ble_new_name,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,SC7U22_init,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,MMC5603nj_init,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,BMP280_init,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,barometer_init,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,foot_init,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,gsensor_test_id,pl
-r=objs/apps/earphone/xtell_Sensor/xtell_handler.c.o,app_var,l
@ -5393,7 +5393,7 @@ objs/apps/earphone/xtell_Sensor/send_data.c.o
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,test_func,pl
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,SL_SC7U22_Config,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,mmc5603nj_init,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,bmp280_init,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,BMP280_init,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,puts,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,foot_init,l
-r=objs/apps/earphone/xtell_Sensor/send_data.c.o,j,pl
@ -5494,7 +5494,7 @@ objs/apps/earphone/xtell_Sensor/sensor/MMC56.c.o
-r=objs/apps/earphone/xtell_Sensor/sensor/MMC56.c.o,puts,l
-r=objs/apps/earphone/xtell_Sensor/sensor/MMC56.c.o,cal_data,pl
objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o
-r=objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o,bmp280_init,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o,BMP280_init,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o,printf,l
-r=objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o,os_time_dly,l
-r=objs/apps/earphone/xtell_Sensor/sensor/BMP280.c.o,bmp280_read_data,pl
@ -5511,6 +5511,19 @@ objs/apps/earphone/xtell_Sensor/sensor/AK8963.c.o
-r=objs/apps/earphone/xtell_Sensor/sensor/AK8963.c.o,MPU9250_Read_Mag_Raw,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/AK8963.c.o,MPU9250_Read_Mag_uT,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/AK8963.c.o,puts,l
objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Init,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,printf,l
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Sleep,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Wakeup,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_GetID,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Temperature_Calculate,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Pressure_Calculate,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_GET_Temperature_Pressure,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,WF_Altitude_Calculate,pl
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,powf,l
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,gravity_sensor_command,l
-r=objs/apps/earphone/xtell_Sensor/sensor/WF282A.c.o,_gravity_sensor_get_ndata,l
cpu/br28/liba/cpu.a.llvm.19376.crc16.c
-r=cpu/br28/liba/cpu.a.llvm.19376.crc16.c,__crc16_mutex_init,pl
-r=cpu/br28/liba/cpu.a.llvm.19376.crc16.c,os_mutex_create,l