* @Author: penglei 1624952103@qq.com
* @Date: SLEPPNOTIFY24-06-26 19:36:48
* @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-09-18 16:54:42
+ * @LastEditTime: 2024-09-23 18:21:49
* @FilePath: /FD230/code/sdk/application/wearable/fd230app/nativeui/sleep/src/SleepModel.cpp
* @Description:
*
static char status_file_path[64] = {0};
static uint32_t fall_asleep_timestamp = 0;
- static uint32_t history_wake_up_timestamp = 0;
+ // static uint32_t history_wake_up_timestamp = 0;
static char day[12] = {0};
static char dir_path[64] = {0};
-
void clean_sleep_data(void)
{
total_time = 0;
bool save_sleep_data(SLEEP_T *data)
{
- bool ephemeral_data = false; //临时数据标志
if(access(time_file_path, F_OK) == -1)
{
total_deep_sleep_time -= data->total_deep_sleep_time;
total_mild_sleep_time -= data->total_mild_sleep_time;
total_rem_sleep_time -= data->total_rem_sleep_time;
- ephemeral_data = true;
}
if(access(status_file_path, F_OK) == -1)
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail");
return false;
}
- history_wake_up_timestamp = data->wake_up_timestamp;
+ // if(data->wake_up_timestamp != 0)
+ // {
+ // history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳
+ // }
fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
}
else
WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "save_sleep_data fopen fail");
return false;
}
-
- if(!ephemeral_data && history_wake_up_timestamp != data->wake_up_timestamp && ((data->fall_asleep_timestamp - history_wake_up_timestamp) < 2 * 60 * 60))
- {
- fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END);
- SLEEP_STATE_T sleep_status = {0,0};
- sleep_status.stat = 3; //清醒状态
- sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间
- history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳
- fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态
- fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件
- }
- else
- {
- if(data->wake_up_timestamp != 0)
- {
- history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳
- }
- fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
- }
+ fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
+ // if(history_wake_up_timestamp != data->wake_up_timestamp && ((data->fall_asleep_timestamp - history_wake_up_timestamp) < 2 * 60 * 60))
+ // {
+ // fseek(fp, -sizeof(SLEEP_STATE_T), SEEK_END);
+ // SLEEP_STATE_T sleep_status = {0,0};
+ // fread(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp);
+ // if(sleep_status.stat == 4) //如果存在出睡睡觉 替换为清醒
+ // {
+ // sleep_status.stat = 3; //清醒状态
+ // sleep_status.timestamp = history_wake_up_timestamp; //清醒状态时间为上一次的出睡时间
+ // fwrite(&sleep_status, sizeof(SLEEP_STATE_T), 1, fp); //替换历史出睡数据 改为清醒状态
+ // fwrite(&data->sleep_status[1], sizeof(SLEEP_STATE_T), data->status_num - 1, fp); //跳过入睡状态写入文件
+ // }
+ // else
+ // {
+ //fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
+ //}
+ // }
+ // else
+ // {
+ // fwrite(data->sleep_status, sizeof(SLEEP_STATE_T), data->status_num, fp);
+ // }
+
+ // if(data->wake_up_timestamp != 0)
+ // {
+ // history_wake_up_timestamp = data->wake_up_timestamp; //更新历史出睡时间戳
+ // }
}
fclose(fp);
send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST);
else
send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST);
+#else
+ memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT));
+ csd.sensorType = CUSTOM_OFFBODY_DETECT;
+ csd.fData[0] = 1;
+ CWM_CustomSensorInput(&csd);
#endif
}
if((int)sensorEVT->fData[1] == CUSTOM_ON_CHARGING)
memset(&scl, 0, sizeof(scl));
scl.iData[0] = 1;
#ifdef AP_ENABLE_DML_SDO_LISTEN
- scl.iData[2] = 4+16; //分离式DML
+ scl.iData[2] = 2+16; //分离式DML
+ CWM_CustomSensorInput_Fifo_Init(GSENSON_MSG_COUNT);
#else
scl.iData[1] = 18; //00000000000000000000000000010010 高位在前
#endif
scl.iData[0] = 1;
scl.iData[1] = 1;
#ifdef AP_ENABLE_DML_SDO_LISTEN
+ scl.iData[1] = 2;
scl.iData[3] = 3;
#endif
CWM_SettingControl(SCL_DML_DRV_INIT, &scl);
#endif
//CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
// CWM_Sensor_Enable(IDX_GYRO);
- CWM_Sensor_Enable(IDX_ALGO_NO_MOTION);
+ //CWM_Sensor_Enable(IDX_ALGO_NO_MOTION);
//CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__);
// CWM_Sensor_Enable(IDX_ALGO_ANY_MOTION);
CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC);
if(isopen)
{
power_on_cat1();
- if(!uapi_dev_runtime_get_saveele_status())
+ // if(!uapi_dev_runtime_get_saveele_status())
{
uapi_dev_runtime_set_cat1_powerstat(1);
}
else
{
power_off_cat1();
- if(!uapi_dev_runtime_get_saveele_status())
+ // if(!uapi_dev_runtime_get_saveele_status())
{
uapi_dev_runtime_set_cat1_powerstat(0);
}
//配置runtime
uapi_dev_runtime_set_saveele_status(1);
+ //关闭抬腕亮屏
+ uapi_take_to_wake(0);
+
+ //亮度最低
+ uapi_setScreenBrightness(51);
//关闭蓝牙
- if(uapi_dev_runtime_get_bt_powerstat())
- {
- stop_custom_ble_service();
- }
-
+ // if(uapi_dev_runtime_get_bt_powerstat())
+ // {
+ // stop_custom_ble_service();
+ // }
+ //断联蓝牙
+ uapi_disconnect_remote_device();
+ //关br 保持ble连接
+ uapi_close_br_scan();
+
//关闭cat1
if(uapi_dev_runtime_get_cat1_powerstat())
{
{
PRINT("Exit Power Saving Mode !!! \r\n");
+ //打开抬腕亮屏
+ if(mmi_flip_wrist_switch_get())
+ {
+ uapi_take_to_wake(1);
+ }
- //打开蓝牙
- if(cm_custom_ble_service_on_flag())
- start_custom_ble_service();
+ //恢复亮度
+ uapi_setScreenBrightness(cm_getScreenBrightness());
+ // //打开蓝牙
+ // if(cm_custom_ble_service_on_flag())
+ // start_custom_ble_service();
+ //开广播
+ if(cm_custom_ble_service_on_flag())
+ uapi_open_br_scan();
//打开cat1
if(cm_poweron_cat1_on_bootup_flag())
uapi_set4GCapability(true);
int status = -1;
uint8_t index = 0;
char timestampe_str[10] = {0};
- char status_str[10] = {0};
+ char status_str[20] = {0};
uapi_get_file_data(timepath,sleep_data,&datelen);
case 7:
strcpy(status_str,"出睡最后一笔输出");
break;
+ case 9:
+ strcpy(status_str,"未出睡最后一笔输出");
+ break;
case 12:
strcpy(status_str,"快速动眼");
break;