From: Caisking <3449750381@qq.com> Date: Thu, 26 Sep 2024 08:12:31 +0000 (+0800) Subject: app发起运动进行状态改变的时候进行时长校验 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=8bc93affa33b8caee6532281553f5cef375656a7;p=mirrors%2FFD230.git app发起运动进行状态改变的时候进行时长校验 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h index 2231fc5ed..887efca21 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingModel.h @@ -243,6 +243,7 @@ namespace OHOS SportData *GetSportdata(); /*获取训练数据*/ void SetIntensity(int heart); /*设置训练强度*/ UIResourceTextId GetIntensity(); /*获取训练强度STR*/ + uint32_t GetSportTime(); /*获取目前运动时长*/ bool SaveSportData(); /*保存数据*/ void SendLiveData(); /*发送实时数据*/ int CalculateAverageHeartRate(int newHeartRate); /*平均心率计算*/ diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp index 3998ebb47..fc3b2da5f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp @@ -1230,7 +1230,11 @@ namespace OHOS { return Openstate; } - + /*获取运动时长*/ + uint32_t TraingModel::GetSportTime() + { + return sportdata->duration; + } /*获取训练量是否达标*/ bool TraingModel::GetMomentum() { #if 0 diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index 9d1ea290c..725313ab2 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -26,6 +26,7 @@ #include "traing/training_card/include/TrainingControlView.h" #include "uicomponents/UIComponents.h" #include "vibrator_service.h" + #include #include #include @@ -420,14 +421,20 @@ bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) { WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ExerciseState::End [%d]\r\n", cmdState); + uint32_t sport_time = TraingModel::GetInstance()->GetSportTime(); + WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sport_time[%d]\r\n", sport_time); + switch (cmdState) { case ExerciseState::End: + reply_APP_SportStopModeCmd(sport_time); handleEndState(); break; case ExerciseState::Pause: + reply_APP_SportPasueResetCmd(sport_time); handlePauseState(); break; case ExerciseState::Continue: + reply_APP_SportPasueResetCmd(sport_time); handleContinueState(); break; case ExerciseState::Start: diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 20c133904..b1d1aa6de 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -3841,7 +3841,7 @@ static void OpenSportModeCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *to } } -void reply_APP_StopSportModeCmd(uint16_t time) +void reply_APP_SportStopModeCmd(uint16_t time) { char data[3]={0}; uint32_t data_len=3; diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h index 0afd573dd..7b8b25df7 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h @@ -828,7 +828,7 @@ void GetwatchSaveMac(uint8_t *mac,uint8_t *mactype); void reply_APP_SportPasueResetCmd(uint16_t time); -void reply_APP_StopSportModeCmd(uint16_t time); +void reply_APP_SportStopModeCmd(uint16_t time); ///////////////////////////自定义文件传输协议///////////////////////////// #define OTA_FILE_MSG_CMD 0x0601