蓝牙协议完成
This commit is contained in:
@ -87,9 +87,9 @@ unsigned char xt_ble_new_name[9] = "CM-22222";
|
||||
static u16 play_poweron_ok_timer_id = 0;
|
||||
|
||||
// -- 初始化标志位 --
|
||||
u8 SC7U22_init = 0; //六轴是否初始化
|
||||
u8 MMC5603nj_init = 0; //地磁是否初始化
|
||||
|
||||
u8 SC7U22_init = 0x10; //六轴是否初始化
|
||||
u8 MMC5603nj_init = 0x20; //地磁是否初始化
|
||||
u8 BMP280_init = 0x30; //气压计初始化
|
||||
// -- 线程id --
|
||||
u16 SC7U22_calibration_id;
|
||||
u16 start_collect_fuc_id;
|
||||
@ -213,7 +213,8 @@ void le_user_app_event_handler(struct sys_event* 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:
|
||||
case 0xff: //测试
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -225,20 +226,31 @@ void le_user_app_event_handler(struct sys_event* event){
|
||||
if(event->u.app.buffer[4] == 0x01){ //六轴
|
||||
if (SL_SC7U22_Config() == 0) {
|
||||
send2_0[4] = 0x00; //初始化失败
|
||||
SC7U22_init = 0;
|
||||
SC7U22_init = 0x10;
|
||||
send_data_to_ble_client(&send2_0,5);
|
||||
return;
|
||||
}
|
||||
create_process(&SC7U22_calibration_id,"SC7U22_calibration",NULL,SC7U22_static_calibration,10);
|
||||
}else if(event->u.app.buffer[4] == 0x02){ //地磁
|
||||
if(mmc5603nj_init() == 0){
|
||||
MMC5603nj_init = 0;
|
||||
send2_0[4] = 0x02; //地磁初始化失败
|
||||
MMC5603nj_init = 0x20;
|
||||
send2_0[4] = MMC5603nj_init; //地磁初始化失败
|
||||
send_data_to_ble_client(&send2_0,5);
|
||||
return;
|
||||
}
|
||||
MMC5603nj_init = 1;
|
||||
send2_0[4] = 0x03; //地磁初始化成功
|
||||
MMC5603nj_init = 0x21;
|
||||
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){
|
||||
//初始化失败
|
||||
BMP280_init = 0x30;
|
||||
send2_0[4] = BMP280_init;
|
||||
send_data_to_ble_client(&send2_0,5);
|
||||
return;
|
||||
}
|
||||
BMP280_init = 0x31;
|
||||
send2_0[4] = BMP280_init; //气压计初始化成功
|
||||
send_data_to_ble_client(&send2_0,5);
|
||||
}
|
||||
break;
|
||||
@ -247,17 +259,17 @@ void le_user_app_event_handler(struct sys_event* event){
|
||||
if(event->u.app.buffer[4] == 0x01){ //六轴
|
||||
send2_1[4] = SC7U22_init;
|
||||
}else if(event->u.app.buffer[4] == 0x02){ //地磁
|
||||
send2_1[4] = MMC5603nj_init + 2;
|
||||
send2_1[4] = MMC5603nj_init;
|
||||
}else if(event->u.app.buffer[4] == 0x03){ //气压计
|
||||
send2_1[4] = BMP280_init;
|
||||
}
|
||||
send_data_to_ble_client(&send2_1,5);
|
||||
break;
|
||||
case 0x02: //开始/停止滑雪计算
|
||||
if(event->u.app.buffer[4] == 0x01){ //开始滑雪计算
|
||||
if(SC7U22_init == 0 || MMC5603nj_init == 0){ //传感器未进行初始化
|
||||
if(SC7U22_init == 0x10 || MMC5603nj_init == 0x20 || BMP280_init == 0x30){ //传感器未进行初始化
|
||||
u8 send2_2[5] = {0xBB,0xBE,0x02,0x00,0x00};
|
||||
send_data_to_ble_client(&send2_2,5);
|
||||
send2_2[4] = 0x02;
|
||||
send_data_to_ble_client(&send2_2,5);
|
||||
return;
|
||||
}
|
||||
create_process(&start_collect_fuc_id,"start_collect",NULL,start_collect_fuc,10);
|
||||
|
||||
Reference in New Issue
Block a user