优化运动数据协议传输,优化蓝牙产测获取PPGID,降低并且统一mag、ppg、cywee线程优先级以改善卡片播放音乐流畅度 498/target/2 505/1 505/head
authorpenglei <1624952103@qq.com>
Thu, 11 Jul 2024 10:36:25 +0000 (18:36 +0800)
committerpenglei <1624952103@qq.com>
Thu, 11 Jul 2024 10:36:25 +0000 (18:36 +0800)
code/sdk/application/wearable/fd230app/nativeui/alarm/src/AlarmClockModel.cpp
code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingModel.cpp
code/sdk/application/wearable/service/ble_service/blemoder/bletest.cpp
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c
code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.h
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/mag/service/mag_service.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp

index 5e8bf30..05fb071 100644 (file)
@@ -746,6 +746,7 @@ int AlarmClockModel::AlarmPlayerStat()
         return OHOS_FAILURE;
     }
     playerCtr->SetAudioSessionId(sessionId);
+    playerCtr->SetVolume(amIntance.GetMaxVolume(AUDIO_STREAM_ALARM_CLOCK),amIntance.GetMaxVolume(AUDIO_STREAM_ALARM_CLOCK));
     // 播放
     playerCtr->Play();
     return OHOS_SUCCESS;
index bf5c716..d9c8030 100644 (file)
@@ -207,6 +207,7 @@ namespace OHOS
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "TraingModel::~TraingModel()");
         TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 取消订阅
         TraingUnsubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
+        TraingUnsubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
     }
     TraingModel *TraingModel::GetInstance(void)
     {
@@ -218,6 +219,7 @@ namespace OHOS
     {
         TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_UPDATE); // 进行消息订阅
         TraingSubscribeTopic(TOPIC_EVENT_BLE_TRAINING);
+        TraingSubscribeTopic(TOPIC_EVENT_ACTIVITY_EXTRA_INFO_UPDATE);
     }
     /*设置运动类型*/
     void TraingModel::SetSportType(Exercisetype type)
@@ -373,7 +375,7 @@ namespace OHOS
         sportdata->pc = cyweeInfo->pace;
         sportdata->distance = cyweeInfo->distance;
 
-        if (sportdata->spc == 0 || sportdata->spc > sportdata->pc)
+        if (sportdata->spc < sportdata->pc)
         {
             sportdata->spc = sportdata->pc;
         }
@@ -391,6 +393,7 @@ namespace OHOS
             custom_VibratorFunc(VibratorType::VIBRATOR_TYPE_TWO); // 震动提醒
             TraingCardView::GetInstance()->SetPopupViewStatus(HeartPopup, true);
         }
+#if 0
         // sportdata->duration = cyweeInfo->duration;
         WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "normal sportdata->calories[%d],sportdata->heart[%d] \r\n", sportdata->calories, sportdata->heart);
         switch (type)
@@ -406,6 +409,7 @@ namespace OHOS
         default:
             break;
         }
+#endif
         /* -------------------------------------------------------------------------- */
         // 首先需要判断有没有设置训练目标,并且保障弹窗只出现一次
         if (sportdata->tag && (!Gettagstuats))
@@ -441,8 +445,8 @@ namespace OHOS
         sportdata->apc = cyweeInfo->avg_pace;
         sportdata->fpc = cyweeInfo->max_pace;
     }
+    
     /*打印函数*/
-
     void TraingModel::printf_data(SportData *data)
     {
         /*打印测试一下数据*/
index 0152012..0b32e83 100644 (file)
@@ -1029,6 +1029,7 @@ char *  struct_to_json_buf_malloc_(uint8_t day)
             cJSON_AddNumberToObject(itemJSON,"ti",data->ti);
             cJSON_AddNumberToObject(itemJSON,"cir",data->cir);
             cJSON_AddNumberToObject(itemJSON,"alt",data->alt);
+            cJSON_AddNumberToObject(itemJSON,"apc",data->apc);
             cJSON_AddNumberToObject(itemJSON,"fpc",data->fpc);
             cJSON_AddNumberToObject(itemJSON,"spc",data->spc);
             cJSON_AddNumberToObject(itemJSON,"std",data->std);
index 46472a8..485b2d6 100644 (file)
@@ -2110,6 +2110,10 @@ void GetAiResultCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,u
         sendBleData(sendBuf,19);\r
     } \r
 }\r
+void GetGPSCmd(uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)\r
+{\r
+   send_big_data(1,NULL,0,0,1,1,0x4f,2);\r
+}\r
 \r
 void query_dial_installed(ble_read_data *buffer_handle,uint16_t cmd,uint8_t *data,uint16_t len,uint8_t *totalData,uint8_t crcvalue)//\r
 {\r
@@ -2385,6 +2389,10 @@ void type2AE4Data(ble_read_data *buffer_handle,uint8_t *buf_cmd,uint8_t *data,ui
             GetAiResultCmd(typeID,data,datalen,totalData,crcvalue);\r
             break;\r
         \r
+         case SYN_APP_GET_GPS_DATA_CMD://app获取GPS数据\r
+            GetGPSCmd(typeID,data,datalen,totalData,crcvalue);\r
+            break;\r
+\r
         default:\r
             break;\r
     }\r
index d1a79a9..38fa114 100644 (file)
@@ -616,6 +616,8 @@ TYPE:02
 
 #define SYN_TODAY_BASIC_TRAIN_TXT_CMD 0x024D //同步当天任意时间之后的基础训练记录
 
+#define SYN_APP_GET_GPS_DATA_CMD 0x024F //同步gps信息
+
 #pragma pack(1)
 typedef struct {
     uint8_t drink_on;//提醒开关 0关闭 1开启
index de96d09..dd85af1 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2024-07-05 19:00:56\r
+ * @LastEditTime: 2024-07-11 17:35:34\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -36,6 +36,7 @@
 #include "custom_runtime.h"\r
 #include "bletest.h"\r
 #include "battery_service.h"\r
+#include "cywee_service.h"\r
 \r
 #pragma pack(1)\r
 typedef struct factorytest_cmd_header_t\r
@@ -502,7 +503,24 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t
                         0x02,\r
                         &send_data,\r
                         1);\r
+            } else if(testitem == 0x03) \r
+            {\r
+                uint8_t send_data = 0x00;\r
+\r
+                do_cywee_service_check_msg(CYWEE_SERVICE_CMD_STOP_ACC,NULL);\r
+                stop_custom_ble_service();\r
+                LOS_Msleep(50);\r
+                uapi_set4GCapability(false);\r
+                LOS_Msleep(50);\r
+                mcu_pm_lcd_off(NULL,NULL) ;\r
+                mcu_pm_remove_vote(NULL,NULL);\r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON,\r
+                        BLE_TEST_CMD_COMMON_SUB_MODE_POWERCONSUMPTION,\r
+                        0x03,\r
+                        &send_data,\r
+                        1);\r
             }\r
+            \r
             break;\r
 \r
         case BLE_TEST_CMD_COMMON_SUB_MODE_OTA:\r
@@ -1139,8 +1157,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //获取 ppg_id\r
                 uint8_t ppg_id;\r
-                hx3695_get_id(&ppg_id);\r
-\r
+                uapi_ppg_get_id(&ppg_id);\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS,\r
                         0x01,\r
index efe40b3..b68bddc 100644 (file)
@@ -439,7 +439,7 @@ errcode_t uapi_cywee_service_init(void)
     app_task_definition_t taskcfg = {0};
     taskcfg.create_queue_handle = create_cywee_queue;
     taskcfg.attr.name = "cywee_service";
-    taskcfg.attr.priority = osPriorityNormal1;
+    taskcfg.attr.priority = osPriorityBelowNormal1;
     taskcfg.attr.stack_size = CYWEE_APP_BOARD_TASK_SIZE;
     taskcfg.func = cywee_service_check_task;
     taskcfg.use_mem = USE_EXTEND_MEM;
index 2492923..c45867d 100644 (file)
@@ -81,7 +81,7 @@ osTimerId_t g_mag_service_timer = NULL;
 static bool g_mag_sensor_exist = false;
 
 static bool g_bat_timer_is_running = false;
-#define MAG_CHECK_MS 20
+#define MAG_CHECK_MS 40
 static unsigned long g_app_queue;
 
 static bool mag_service_running_stat = false;
index 2a23769..362bff8 100644 (file)
@@ -127,6 +127,8 @@ int cywee_data[2] = {0};
 \r
 int wear_mode_status = -1;\r
 \r
+static uint8_t hx3695_chip_id = 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
@@ -362,6 +364,7 @@ bool hx3695_chip_check(void)
 {\r
     uint8_t i = 0;\r
     uint8_t chip_id = 0;\r
+    hx3695_chip_id = 0;\r
     for(i=0; i<5; i++)\r
     {\r
         hx3695_ppg_on();\r
@@ -372,6 +375,7 @@ bool hx3695_chip_check(void)
         {\r
             //printf("hx3695_chip_check ok  chip_id: 0x%x \r\n",chip_id);\r
                        //Efuse_Mode_Check();\r
+            hx3695_chip_id = chip_id;\r
             return true;\r
         }\r
     }\r
@@ -383,21 +387,7 @@ bool hx3695_chip_check(void)
 \r
 void hx3695_get_id(uint8_t *ppg_id)\r
 {\r
-    uint8_t i = 0;\r
-    uint8_t chip_id = 0;\r
-    for(i=0; i<5; i++)\r
-    {\r
-        hx3695_ppg_on();\r
-        hx3695_delay_ms(5);\r
-        chip_id = hx3695_read_reg(0x00);\r
-\r
-        if (chip_id == 0x65)\r
-        {\r
-            *ppg_id = chip_id;\r
-            break;\r
-        }\r
-    }\r
-    hx3695_ppg_off();\r
+    *ppg_id = hx3695_chip_id;\r
 }\r
 \r
 uint8_t hx3695_read_fifo_size(void)\r
index c198c3b..9f7b9e3 100644 (file)
@@ -369,7 +369,7 @@ errcode_t uapi_ppg_service_init(void)
     app_task_definition_t taskcfg={0};
     taskcfg.create_queue_handle = create_ppg_queue;
     taskcfg.attr.name="ppg_service";
-    taskcfg.attr.priority = osPriorityNormal1;
+    taskcfg.attr.priority = osPriorityBelowNormal1;
     taskcfg.attr.stack_size = PPG_SERVICE_TASK_SIZE;
     taskcfg.func = ppg_service_check_task;
     taskcfg.use_mem = USE_EXTEND_MEM;