增加app发起运动log
authorCaisking <Casiking@zhihuishixun.com>
Wed, 15 Oct 2025 02:37:08 +0000 (10:37 +0800)
committerCaisking <Casiking@zhihuishixun.com>
Wed, 15 Oct 2025 02:37:08 +0000 (10:37 +0800)
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/n9/nativeapp/nativeui/traing/training_card/src/TraingCardPresenter.cpp
code/sdk/application/wearable/n9/service/msg_center/src/msg_center_customer.cpp
code/sdk/zhihui/services/ble_service/bleservice/bleEvent.c

index 1485333..0fff18f 100644 (file)
@@ -292,7 +292,7 @@ int TraingModel::GetBleSportId(Exercisetype sporttype, UIResourceTextId id) {
     offset = 0;
     break;
   }
-  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, " offset %d id %d", offset, id);
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "编译id offset %d id %d", offset, id);
   return id - offset;
 }
 
@@ -780,7 +780,15 @@ void TraingModel::SetTimestamp() {
     Startstate = true;
     Endstate = false; // 确保"开始"和"结束"状态互斥
 
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始运动");
+     //打印目前运动配置项
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "*******************************");
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开始运动");
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportType:%d", sportdata->sportType);
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportId:%d", sportdata->sportId);
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportTagType:%d", sportdata->sportTagType);
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "sportTag:%d", sportdata->tag);
+     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "*******************************");
+ 
 
     sport_start_data_timer(300); //开启数据获取定时器 刷新频率是300ms
 
@@ -1395,8 +1403,7 @@ bool TraingModel::SaveSportData() {
   Trainingdata data;
   data.src = Openingway;
   data.bt = static_cast<uint32_t>(sportdata->sportType);
-  data.ty = static_cast<uint32_t>(
-      GetBleSportId(sportdata->sportType, sportdata->sportId));
+  data.ty = static_cast<uint32_t>(GetBleSportId(sportdata->sportType, sportdata->sportId));
   data.st = static_cast<uint32_t>(sportdata->starttime);
   data.sp = static_cast<uint32_t>(sportdata->endtime);
   data.tgt = static_cast<uint32_t>(sportdata->sportTagType);
@@ -3142,7 +3149,7 @@ static void gnss_timer_callbackProc(int data) {
   if (gps_timer_count == 2) {
 #if defined(SUPPORT_GNSS)
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开启gps");
-    gnss_start();
+    // gnss_start();
 #endif
   }
 #if defined(SUPPORT_GNSS)
@@ -3515,8 +3522,30 @@ char *struct_to_json_buf_malloc_(uint8_t day) {
       cJSON_AddNumberToObject(itemJSON, "spc", data->spc);
       cJSON_AddNumberToObject(itemJSON, "std", data->std);
       cJSON_AddNumberToObject(itemJSON, "cdc", data->cdc);
-
       cJSON_AddItemReferenceToArray(data_arryJSON, itemJSON);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*******************************");
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"src:%d",data->src);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"bt:%d",data->bt);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ty:%d",data->ty);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"st:%d",data->st);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sp:%d",data->sp);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"tgt:%d",data->tgt);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"tg:%d",data->tg);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"pg:%d",data->pg);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"du:%d",data->du);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ca:%d",data->ca);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"di:%d",data->di);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"hr:%d",data->hr);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"stp:%d",data->stp);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ti:%d",data->ti);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cir:%d",data->cir);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"alt:%d",data->alt);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"apc:%d",data->apc);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"fpc:%d",data->fpc);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"spc:%d",data->spc);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"std:%d",data->std);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cdc:%d",data->cdc);
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*******************************");
       free(data);
       data = NULL;
     } else {
@@ -3620,6 +3649,30 @@ cJSON* ble_get_Trainingdata_by_timetamp_(uint32_t timetamp)
         if(data!=NULL)
         {
             WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"%d,%d\r\n",timetamp,data->st);
+            // 打印data数据
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*******************************");
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"src:%d",data->src);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"bt:%d",data->bt);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ty:%d",data->ty);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"st:%d",data->st);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sp:%d",data->sp);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"tgt:%d",data->tgt);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"tg:%d",data->tg);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"pg:%d",data->pg);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"du:%d",data->du);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ca:%d",data->ca);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"di:%d",data->di);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"hr:%d",data->hr);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"stp:%d",data->stp);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"ti:%d",data->ti);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cir:%d",data->cir);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"alt:%d",data->alt);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"apc:%d",data->apc);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"fpc:%d",data->fpc);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"spc:%d",data->spc);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"std:%d",data->std);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"cdc:%d",data->cdc);
+            WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*******************************");
             int time_error= timetamp>data->st ? timetamp-data->st:data->st-timetamp;
             if(time_error<=2)
             {
index c0ccf3b..3d65e36 100644 (file)
@@ -145,7 +145,7 @@ void TraingCardPresenter::UpdateTimeOfControl() {
   bool isNeedGPS = TraingModel::GetInstance()->IsNeedGPS(TraingModel::GetInstance()->GetSportEvent());\r
   if(isNeedGPS == false)\r
   {\r
-    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "该运动项不需要GPS");\r
+    WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "该运动项不需要GPS");\r
     return;\r
   }\r
   \r
@@ -502,6 +502,12 @@ bool TraingCardPresenter::send_sport_cmd(training_ble *cmd) {
         }\r
       }\r
       reply_APP_OpenSportModeCmd(true);\r
+      // 打印app开启的运动的数据\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*************app开启运动******************");\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sportType:%d",cmd->sportType);\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sportTagType:%d",cmd->sportTagType);\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"sportTag:%d",cmd->sportTag);\r
+      WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"*******************************");\r
       handleStartState();\r
       return true;\r
     } else {\r
@@ -611,6 +617,14 @@ void TraingCardPresenter::handleContinueState() {
 void TraingCardPresenter::handleStartState() {\r
   ControlSensor(ExerciseState::Start);\r
   TraingModel::GetInstance()->SetSportOpenWay(true);\r
+  //开启心率\r
+  TraingModel::GetInstance()->start_training_heart();\r
+#if defined(SUPPORT_GNSS)\r
+  WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "开启gps定时器");\r
+  TraingModel::GetInstance()->gnss_start_timer(1000);\r
+#endif\r
+  // 快捷训练都属于健身类\r
+  TraingModel::GetInstance()->SetSportType(Exercisetype::FITNESS);\r
 }\r
 \r
 } // namespace OHOS\r
index ac3946b..37f7369 100644 (file)
@@ -1536,9 +1536,9 @@ static MsgCenterNotifyTable g_msgCenterNotifyTable[] = {
     {TOPIC_EVENT_AR_ALERT_TYPE_UPDATE,       MsgCenterNotifyArAlertProc},
     {TOPIC_EVENT_INACTIVITY_UPDATE,       MsgCenterNotifyInactivityProc},
     {TOPIC_EVENT_INACTIVITY_ACCUMULATE_TIME_UPDATE,       MsgCenterNotifyInactivityAccumulateTimeProc},
-    {TOPIC_EVENT_BLE_TRAINING,       MsgCenterNotifybleAPPtraining},
     {TOPIC_EVENT_GOAL_SHOW_VIEW,    MsgCenterNotifygoalnotificationviewProc},
 #endif
+    {TOPIC_EVENT_BLE_TRAINING,       MsgCenterNotifybleAPPtraining},
     {TOPIC_EVENT_BLE_TRANSMIT,       MsgCenterNotifybleTransmit},
 
     {TOPIC_EVENT_CHARGE_PLUG,        MsgCenterNotifyChargePlugProc},
index b8115ac..2deac88 100644 (file)
@@ -6024,7 +6024,7 @@ static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id)
         switch (id)
         {
             case 0x49:
-                json_format=struct_to_json_buf_malloc_(day);
+                json_format=struct_to_json_buf_malloc(day);
                 break;
             case 0x01:
                 json_format=struct_to_json_buf_malloc_Alarm();
@@ -6070,7 +6070,7 @@ static void Send_json_Data_Cmd(uint8_t day,uint16_t pack_size,uint8_t id)
            else
            {
                 
-                  WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack);
+                WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP,"%d %d %d %d\r\n",data_len,surplus_len,pack_id,pack);
                 ble_data_type type_={0x01,id,data_len,pack,pack_id};
                 send_big_data(type_,json_format+offset,surplus_len);
                 //send_big_data(1,json_format+offset,surplus_len,data_len,pack_id,pack,id,1);
@@ -6781,10 +6781,12 @@ void readDevDataBle(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u
                  uapi_dev_runtime_set_goal_storage_status(0);
                 break;
             case 0x49://同步基础训练历史数据
+                WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"同步基础训练历史数据 目前存储状态:%d",uapi_dev_runtime_get_train_storage_status());
 
                 if(uapi_dev_runtime_get_train_storage_status())
                 {
                     ble_reply_cmdarr(SYN_BASIC_TRANIN_HISTORY_DATA_CMD,NULL,0);
+                    WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP,"同步基础训练历史数据 失败");
                     return;
                 }
 
@@ -6795,7 +6797,7 @@ void readDevDataBle(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u
                     num=482;
                 }
                  uapi_dev_runtime_set_train_storage_status(1);
-                Send_json_Data_Cmd(data[0],num,0x49);
+                 Send_json_Data_Cmd(data[0],num,0x49);
                  uapi_dev_runtime_set_train_storage_status(0);
                 break;
             case 0x01://同步闹钟