// WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_hid_server_handle %d\r\n",g_hid_server_handle);\r
ble_cywee_store_report_handle(result->value_handle);\r
// }\r
+\r
+ ble_cywee_store_recv_handle(65) ;\r
}\r
#endif\r
return;\r
void cywee_stop(void);
uint8_t cywee_get_active_state(void);
uint8_t cywee_get_static_state(void);
+void cywee_restart_acc(void);
+void cywee_log_switch(int cmd);
extern uint8_t hrs_mode_state;
#pragma pack()
* @Author: penglei 1624952103@qq.com
* @Date: 2024-03-26 20:29:58
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-12 12:08:23
+ * @LastEditTime: 2024-08-16 15:46:30
* @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
* @Description:
*
#define CYWEE_SERVICE_CMD_CLOSE_SEDENTARY 0x34
+#define CYWEE_SERVICE_CMD_RESTART_ACC 0x35
+
errcode_t uapi_cywee_service_init(void);
void uapi_cywee_service_deinit(void);
if(buf != NULL)
printf("cywee_recv_cmd_data len %d , handle 0x%X ,*buf 0x%02X\r\n",event_size,handle,*buf);
/****此处为接收指令,处理后反馈结果的参考**/
-
+ cywee_log_switch(*buf);
/*****参考结束****/
}
case CYWEE_SERVICE_CMD_CLOSE_SEDENTARY:
cywee_set_sedentary_switch(0);
break;
-
+ case CYWEE_SERVICE_CMD_RESTART_ACC:
+ cywee_restart_acc();
+ break;
default:
PRINT("unkonw cmd \r\n");
break;
app_task_definition_t taskcfg = {0};
taskcfg.create_queue_handle = create_cywee_queue;
taskcfg.attr.name = "cywee_service";
- taskcfg.attr.priority = osPriorityBelowNormal1;
+ taskcfg.attr.priority = osPriorityBelowNormal4;
taskcfg.attr.stack_size = CYWEE_APP_BOARD_TASK_SIZE;
taskcfg.func = cywee_service_check_task;
taskcfg.use_mem = USE_EXTEND_MEM;
static uint8_t g_cywee_installed = 0;
+extern uint8_t cywee_ble_service_flag;
/************************/
/*** Function Defines ***/
int CWM_OS_dbgOutput(const char * format)
{
PRINT("%s", format);
-#if 0
- ble_cywee_server_send_input_report((uint8_t *)format,strlen(format));
-#endif
+ if(cywee_ble_service_flag)
+ ble_cywee_server_send_input_report((uint8_t *)format,strlen(format));
return 0;
}
static char chipInfo[64] = {0};
-static int get_acc_swtich = 0;
+static int get_acc_swtich = 1;
static int sedentary_interval = 1;
static uint8_t is_static_state = 0;
+uint8_t cywee_ble_service_flag = 0;
+
int cm__hs1__init(void);
int cm__hs1__deinit(void);
+void cywee_log_switch(int cmd)
+{
+ if(cmd)
+ {
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[3] = 9;
+ scl.iData[4] = 5;
+ scl.iData[7] = -1;
+ CWM_SettingControl(SCL_LOG, &scl);
+ cywee_ble_service_flag = 1;
+ }
+ else
+ {
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ CWM_SettingControl(SCL_LOG, &scl);
+ cywee_ble_service_flag = 0;
+ }
+}
+
+
+void cywee_restart_acc(void)
+{
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ scl.iData[2] = 0;
+ CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
+ memset(&scl, 0, sizeof(scl));
+ scl.iData[0] = 1;
+ scl.iData[1] = 1;
+ scl.iData[2] = 1; //1=acc,1+2=a+g,1+2+4=a+g+m
+ CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
+}
+
uint8_t cywee_get_static_state(void)
{
return is_static_state;
t[i].y= gxyz_t_queue[left_falg].y;
t[i].z= gxyz_t_queue[left_falg].z;
+ gxyz_t_queue[left_falg].x = 0.0f;
+ gxyz_t_queue[left_falg].y = 0.0f;
+ gxyz_t_queue[left_falg].z = 0.0f;
+
if(num_falg)
{
left_falg++;
gxyz_t.z = sensorEVT->fData[2];
// CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",
- // sensorEVT->fData[0] * 4096 / 10,
- // sensorEVT->fData[1] * 4096 / 10,
- // sensorEVT->fData[2] * 4096 / 10
+ // sensorEVT->fData[0],
+ // sensorEVT->fData[1],
+ // sensorEVT->fData[2]
// );
if(get_acc_swtich)
//设置运动识别
cywee_ar_alert_switch(get_motion_recognition_from_config_model());
-#if 0
- memset(&scl, 0, sizeof(scl));
- scl.iData[0] = 1;
- scl.iData[3] = 9;
- scl.iData[4] = 5;
- scl.iData[7] = -1;
- CWM_SettingControl(SCL_LOG, &scl);
-#endif
-
//呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
\r
static uint8_t hx3695_chip_id = 0;\r
\r
+static int timeout = 0;\r
+\r
//////// spo2 para and switches\r
const uint8_t COUNT_BLOCK_NUM = 25; //delay the block of some single good signal after a series of bad signal\r
const uint8_t SPO2_LOW_XCORR_THRE = 30; //(64*xcorr)'s square below this threshold, means error signal\r
\r
for(ii=0; ii<*count; ii++)\r
{\r
+ if(gsensordata[ii].x == 0.0f && gsensordata[ii].y == 0.0f && gsensordata[ii].z == 0.0f)\r
+ {\r
+ timeout++;\r
+ if(timeout > 20)\r
+ {\r
+ do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESTART_ACC,NULL);\r
+ }\r
+ }\r
+ else\r
+ {\r
+ timeout = 0;\r
+ }\r
if(ii == 8)\r
{\r
gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1];\r
}\r
//PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
//PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
+ PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsensordata[ii].x,gsensordata[ii].y,gsensordata[ii].z,ppg_s_data.green_cur);\r
\r
}\r
hrs_wear_status = hx3695_hrs_get_wear_status();\r
wear_mode_timeout_handler(NULL);
continue;
}else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){
- do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL);
+ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL);
cmd = "hrs";
enable = 1;
uapi_pm_add_sleep_veto(PM_ID_HEART);
enable = 0;
wear_mode_state = 0;
}else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){
- do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_GET_ACC,NULL);
+ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_GET_ACC,NULL);
cmd = "hrs";
enable = 0;
uapi_pm_remove_sleep_veto(PM_ID_HEART);
app_task_definition_t taskcfg={0};
taskcfg.create_queue_handle = create_ppg_queue;
taskcfg.attr.name="ppg_service";
- taskcfg.attr.priority = osPriorityBelowNormal1;
+ taskcfg.attr.priority = osPriorityBelowNormal4;
taskcfg.attr.stack_size = PPG_SERVICE_TASK_SIZE;
taskcfg.func = ppg_service_check_task;
taskcfg.use_mem = USE_EXTEND_MEM;