#endif
#ifdef SUPPORT_CYWEE_SERVICE
+#include "cywee_hal.h"
#include "cywee_service.h"
#endif
}
int flag = 0;
static void Training_Notify(void *args, const Topic topic, Request *request) {
-#ifdef CYWEE_ACTIVITY_ENABLE
+#ifdef SUPPORT_CYWEE_SERVICE
UNUSED(args);
UNUSED(topic);
if (request == NULL) {
"memcpy_s act_result_t fail ret = %d", rets);
return;
}
- // GraphicService::GetInstance()->PostGraphicEvent(
- // std::bind(&TraingCardPresenter::send_sport_cmd,
- // TraingCardPresenter::GetInstance(), traingbleInfo));
+#ifdef BLE_SERVER_ENABLE
TraingCardPresenter::GetInstance()->send_sport_cmd(traingbleInfo);
+#endif
delete traingbleInfo;
}
//增加训练runtime控制
return sum / sortedHeartRates.size(); // 返回平均值
}
-#ifdef CYWEE_ACTIVITY_ENABLE
+#ifdef SUPPORT_CYWEE_SERVICE
/*分析数据*/
void TraingModel::AnalysisData(act_result_t *cyweeInfo) {
+ if (cyweeInfo == NULL)
+ return;
+
// 不同的运动类型解析不同的数据
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
+ "AnalysisData:[steps %d, distance %d,calories %d, pace %d, "
+ "step_frequency %d, step_length %d]",
+ cyweeInfo->steps, cyweeInfo->distance, cyweeInfo->calories,
+ cyweeInfo->pace, cyweeInfo->step_frequency,
+ cyweeInfo->step_length);
// 通用数据
sportdata->steps = cyweeInfo->steps;
sportdata->distance = cyweeInfo->distance;
#endif
/*分析activity extra info数据*/
-#ifdef CYWEE_ACTIVITY_ENABLE
+#ifdef SUPPORT_CYWEE_SERVICE
void TraingModel::AnalysisExtraData(act_ext_result_t *cyweeInfo) {
- WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]",
+ //判断是否为特殊训练
+ if (isspecialsport_ == false) {
+ return;
+ }
+
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "[apc:%d fpc:%d cdc:%d std:%d]",
cyweeInfo->avg_pace, cyweeInfo->max_pace,
cyweeInfo->avg_step_freq, cyweeInfo->avg_step_len);
//平均配速
// 检查重复时间戳
for (const auto &entry : heartRateTable) {
if (entry.timestamp == timestamp) {
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,
- "时间戳重复无法添加数据 AddHeartRateData is error!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"时间戳重复无法添加数据 AddHeartRateData is error!");
return false; // 返回重复
}
}
if (heartRateTable.size() >= MAX_ENTRIES) {
- WEARABLE_LOGE(
- WEARABLE_LOG_MODULE_APP,
- "达到最大心率数据条目限制 无法添加新的数据 AddHeartRateData is error!");
+ WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"达到最大心率数据条目限制 无法添加新的数据 AddHeartRateData is error!");
return false; // 返回条目满了
}
if (g_motionTimes > 0) {
sportdata->duration = g_motionTimes; // 设置训练时长
- // 每分钟进行配速和心率数据存储
- StoreDataIfMinutePassed();
}
return motionDuration; // 返回格式化的运动时长
}
}
- WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "duration:[%d] g_motionTimes[%d]\r\n",
+ WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "duration:[%d] g_motionTimes[%d]\r\n",
sportdata->duration, g_motionTimes);
}
pauseStartTimestamp = sportdata->starttime;
}
- uint32_t currentTimestamp =
- OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳
- g_motionTimes = (currentTimestamp - pauseStartTimestamp) +
- totalPausedDuration; // 更新运动时间
+ uint32_t currentTimestamp =OHOS::TraingModel::GetInstance()->get_current_time(); // 获取当前时间戳
+ g_motionTimes = (currentTimestamp - pauseStartTimestamp) + totalPausedDuration; // 更新运动时间
sportdata->duration = g_motionTimes; // 更新持续时间
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,
return;
}
WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "sport_data_callbackProc");
-#ifdef CYWEE_ACTIVITY_ENABLE
+#ifdef SUPPORT_CYWEE_SERVICE
act_result_t cyweeInfo;
cywee_get_act_data(&cyweeInfo);
- TraingModel::GetInstance()->AnalysisData(cyweeInfo);
+ TraingModel::GetInstance()->AnalysisData(&cyweeInfo);
// 更新其他目标完成度
TraingModel::GetInstance()->CheckSportTag();
act_ext_result_t cyweeInfo_ext;
cywee_get_act_ext_data(&cyweeInfo_ext);
- TraingModel::GetInstance()->AnalysisExtraData(cyweeInfo_ext);
+ TraingModel::GetInstance()->AnalysisExtraData(&cyweeInfo_ext);
#endif
//训练心率
uint8_t hrs = 0;