优化蓝牙产测地磁、gps 测试 2097/1 2097/head 2100/target/1
authorpenglei <1624952103@qq.com>
Mon, 18 Aug 2025 10:38:54 +0000 (18:38 +0800)
committerpenglei <1624952103@qq.com>
Mon, 18 Aug 2025 10:38:54 +0000 (18:38 +0800)
code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp
code/sdk/zhihui/UI/producttest/include/testPresenter.h
code/sdk/zhihui/UI/producttest/src/testgsenson.cpp
code/sdk/zhihui/UI/producttest/src/testmagnetic.cpp
code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h
code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_main.c
code/sdk/zhihui/drivers/mag/service/mag_hal.c
code/sdk/zhihui/drivers/mag/service/mag_hal.h
code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c
code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c

index 64639c4..d45048c 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2025-05-15 11:27:16
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-07-31 17:10:15
+ * @LastEditTime: 2025-08-18 17:38:37
  * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/compass/src/CompassModel.cpp
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
 #include "compass/include/CompassModel.h"
 #include <ctime>
 
-#ifdef SUPORT_MAG_SERVICE
-#include "mag/service/mag_service.h"
-#include "mag/mmc5603/mmc5603_hal.h"
-#endif
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#ifdef SUPORT_MAG_SERVICE
+#include "mag_service.h"
+#include "mag_hal.h"
+#endif
+
 using namespace OHOS;
 
 #ifdef __cplusplus
@@ -56,7 +57,11 @@ void CompassModel::SetCalibrationStatus(uint8_t status)
 uint8_t CompassModel::GetCalibrationStatus(void)
 {
     #ifdef SUPORT_MAG_SERVICE
-    if( mag_service_get_iAccuracy() < 3)
+
+    int iAccuracy = 0;
+    mag_get_iAccuracy(&iAccuracy);
+
+    if(iAccuracy < 3)
         return 1;
     else 
         return 0;
@@ -70,14 +75,16 @@ uint8_t CompassModel::GetCalibrationStatus(void)
 */
 void CompassModel::SetDisplayAngle(uint16_t angle)
 {
-    #ifdef SUPORT_MAG_SERVICE
-    displayAngle = (int16_t)mag_service_get_fAzimuth();
-    #else
+#ifdef SUPORT_MAG_SERVICE
+    float data = 0;
+    mag_get_fAzimuth(&data);
+    displayAngle = (int16_t)data;
+#else
     displayAngle += angle;
     if (displayAngle > 359) {
         displayAngle = 0;
     }
-    #endif
+#endif
 }
 
 /*
index 1d5a595..8671d6a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-08-23 10:50:37\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2025-08-13 14:38:27\r
+ * @LastEditTime: 2025-08-18 18:37:28\r
  * @FilePath: /FD230/code/sdk/application/wearable/fd230/nativeapp/nativeui/producttest/include/testPresenter.h\r
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\r
  */\r
 #include "producttest/include/testhrsenson.h" \r
 #include "components/ui_label_button_ext.h"\r
 #include "common/key_code.h"\r
+\r
+\r
+\r
+typedef struct {\r
+        bool lcd;        // LCD测试结果\r
+        bool tp;         // 触摸屏测试结果\r
+        bool mag;   // 磁力计测试结果\r
+        bool brightness;     // 亮度测试结果\r
+        bool bat;     // 亮度测试结果\r
+        bool spk;        // 喇叭测试结果\r
+        bool mic;     // 麦克风测试结果\r
+        bool motor;          // 马达测试结果\r
+        bool hr;   // 心率漏光测试结果\r
+        bool gsensor;        // 重力加速度传感器\r
+        bool cat1;      // 4g测试结果\r
+        bool button;    // 按键测试结果\r
+        bool bt;        // 蓝牙扫描测试结果\r
+        bool aplipay;   // 支付宝加密芯片测试结果\r
+        bool gps;       // gps测试结果\r
+        bool lowpower;  // 低功耗测试结果\r
+} FactoryTestResult;\r
+\r
+static FactoryTestResult g_factoryTestResult = {false};\r
+\r
 namespace OHOS\r
 {\r
     typedef enum\r
@@ -65,7 +89,6 @@ namespace OHOS
         MAX_TESTVIEWID,\r
     } TEST_VIEW;\r
 \r
-\r
     class testView;\r
     class testPresenter : public Presenter<testView>,\r
                             public UIView::OnClickListener,\r
@@ -83,6 +106,9 @@ namespace OHOS
 \r
         static testPresenter *GetInstance();\r
 \r
+        FactoryTestResult* GetFactoryTestResult() {return &g_factoryTestResult;}\r
+\r
+\r
     private:\r
         // 因为继承了OnClickListener,所以有OnClick属性,至于参数,原函数也这样直接继承;\r
         bool OnClick(UIView &view, const ClickEvent &event) override;\r
index c381c37..fb7b92a 100644 (file)
@@ -5,6 +5,7 @@
 #include "cmsis_os2.h"
 #include "cywee_hal.h" 
 #include "producttest/include/testView.h"
+#include "math.h"
 #ifdef __cplusplus
 #if __cplusplus
 extern "C"
@@ -19,6 +20,11 @@ extern "C"
 #endif
 #endif
 
+#ifdef SUPPORT_CYWEE_SERVICE
+static gsenson_t last_value = {0};
+static bool isInit = false;
+#endif
+
 //#include "acc_service.h"
 namespace OHOS
 {
@@ -66,6 +72,12 @@ namespace OHOS
     static osTimerId_t  Gsenson_TEST_timer=NULL;
     void testgsensonView::ClearAll()
     {
+#ifdef SUPPORT_CYWEE_SERVICE
+        last_value.x = 0;
+        last_value.y = 0;
+        last_value.z = 0;
+        isInit = false;
+#endif
         if(testGsonsonScrollView)
         {
             testGsonsonScrollView->RemoveAll();
@@ -112,15 +124,43 @@ namespace OHOS
     {
         
         MG_TEST_FALG++;
-        gsenson_t t;
+        char buf[124]={0};
+
 #ifdef SUPPORT_CYWEE_SERVICE
+        gsenson_t t;
         cywee_get_gsensor_data(1,&t);
+        sprintf(buf,"X:%.2f\nY:%.2f\nZ:%.2f",t.x,t.y,t.z);
+
+        // if (!isInit) 
+        // {
+        //     last_value.x = t.x;
+        //     last_value.y = t.y;
+        //     last_value.z = t.z;
+        //     isInit = true;
+        // } 
+        // else 
+        // {
+        //     bool xChanged = fabs(t.x - last_value.x) > 0.01f;
+        //     bool yChanged = fabs(t.y - last_value.y) > 0.01f;
+        //     bool zChanged = fabs(t.z - last_value.z) > 0.01f;
+
+        //     FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult();
+        //     if (g_ret) 
+        //     {
+        //         if (xChanged || yChanged || zChanged)
+        //             g_ret->gsensor = 1;
+        //         else
+        //             g_ret->gsensor = 2;
+        //     }
+        // }
+
+        // FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult();
+        // if (g_ret) {
+        //     printf("gsensor test result:%d\n", g_ret->gsensor);
+        // }
+
 #endif
-        char buf[124]={0};
-        float x_t=t.x;
-        float y_t=t.y;
-        float z_t=t.z;
-        sprintf(buf,"X:%.2f\nY:%.2f\nZ:%.2f",x_t,y_t,z_t);
+
         x->SetText(buf);
         RootView::GetInstance()->Invalidate();
 
index f55d1bb..3950822 100644 (file)
@@ -19,13 +19,17 @@ extern "C"
 #endif
     #include "pm_veto.h"
     #include "pm.h"
+#ifdef SUPPORT_MAG_SERVICE
+    #include "mag_hal.h" 
+#endif
 #ifdef __cplusplus
 #if __cplusplus
 }
 #endif
-#include "mag/mmc5603/mmc5603_hal.h"
 #endif
 
+static float last_value = 0;
+
 namespace OHOS
 {
 
@@ -52,6 +56,8 @@ namespace OHOS
      osTimerId_t  magneyic_TEST_timer=NULL;
     void testMagicView::ClearAll()
     {
+        last_value = 0;
+        
         if(testmagicScrollView)
         {
             testmagicScrollView->RemoveAll();
@@ -122,7 +128,36 @@ namespace OHOS
         RootView::GetInstance()->Invalidate();
 #else
        MG_TEST_FALG++;
-        float angle_value= mag_service_get_fAzimuth();
+        float angle_value = 0;
+
+#ifdef SUPPORT_MAG_SERVICE
+        mag_get_fAzimuth(&angle_value);
+#endif
+        if(angle_value && !last_value)
+        {
+            last_value = angle_value;
+        }
+        else if(last_value && angle_value && last_value != angle_value)
+        {
+            FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult();  
+            if(g_ret)
+            {
+                g_ret->mag = 1;
+            }
+        }
+        else if(!angle_value)
+        {
+            FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult();  
+            if(g_ret)
+            {
+                g_ret->mag = 2;
+            }
+        }
+
+        FactoryTestResult *g_ret = OHOS::testPresenter::GetInstance()->GetFactoryTestResult();  
+        if(g_ret)
+            printf("mag test result:%d\n",g_ret->mag);
+
         char buf[16]={0};
         sprintf(buf,"angle:%.2f",angle_value);
         x->SetText(buf);
@@ -211,7 +246,10 @@ namespace OHOS
         }
         testmagicScrollView->Add(title);
         /* -------------------------------------------------------------------------- */
-        uint16_t angle_value= (int16_t)mag_service_get_fAzimuth();
+        float angle_value = 0;
+#ifdef SUPPORT_MAG_SERVICE
+        mag_get_fAzimuth(&angle_value);
+#endif
         char buf[16]={0};
         sprintf(buf,"angle:%d",angle_value);
         Config = {
index 4968ca2..779810a 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2025-05-15 11:28:07
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-07-29 10:54:34
+ * @LastEditTime: 2025-08-18 17:34:06
  * @FilePath: /FD230/code/sdk/zhihui/drivers/mag/mmc5603/mmc5603_hal.h
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -36,8 +36,8 @@ int mmc5603_start(void);
 void mmc5603_poweron(void);
 void mmc5603_poweroff(void);
 
-float mag_service_get_fAzimuth(void);
-int mag_service_get_iAccuracy(void);
+void mag_service_get_fAzimuth(float *data);
+void mag_service_get_iAccuracy(int *data);
 
 #ifdef __cplusplus
 #if __cplusplus
index d88f6e9..54a24f9 100644 (file)
@@ -35,13 +35,13 @@ float magnetic_field_z;
 #define GPIO_PIN_PRG_LED_ON S_AGPIO_R0\r
 \r
 /* These variables are used to save the magnetic sensor calibrated data. */    \r
-float calMagX, calMagY, calMagZ;       \r
+static float calMagX, calMagY, calMagZ;        \r
 \r
 /* These variables are used to save the calibrated orientation output. */      \r
-float fAzimuth, fPitch, fRoll;\r
+static float fAzimuth, fPitch, fRoll;\r
 \r
 /* This variable is used to save the calibration accuracy. */  \r
-int iAccuracy;\r
+static int iAccuracy;\r
 \r
 /* Read saved calibration parameters. These para is saved in somewhere that can not disappear when power-off\r
  * ReadPara function should be create by customer.If customer can not implement this function, should comment it out\r
@@ -451,9 +451,10 @@ void mag_coordinate_raw_to_real(int layout, float *in, float *out)
                break;\r
        }\r
 }\r
-float mag_service_get_fAzimuth(void)\r
+void mag_service_get_fAzimuth(float *data)\r
 {\r
-       return fAzimuth;\r
+       if(data)\r
+               *data = fAzimuth;\r
 }\r
 \r
 float mag_service_get_fPitch(void)\r
@@ -466,9 +467,10 @@ float mag_service_get_fRoll(void)
        return fRoll;\r
 }\r
 \r
-int mag_service_get_iAccuracy(void)\r
+void mag_service_get_iAccuracy(int *data)\r
 {\r
-       return iAccuracy ;\r
+       if(data)\r
+               *data = iAccuracy;\r
 }\r
 \r
 int mmc5603_stop(void)\r
index f2ad863..a267b35 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2025-05-16 11:36:48
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-07-29 14:17:17
+ * @LastEditTime: 2025-08-18 17:33:25
  * @FilePath: /FD230/code/sdk/zhihui/drivers/mag/hal/mag_hal.c
  * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
  */
@@ -46,21 +46,19 @@ uint8_t mag_get_chip_id(void)
     return id;
 }
 
-int mag_get_iAccuracy(void)
+void mag_get_iAccuracy(int *data)
 {
-    int iAccuracy = 0;
 #ifdef MAG_MMC5603
-    iAccuracy = mag_service_get_iAccuracy();
+    if(data)
+        mag_service_get_iAccuracy(data);
 #endif
-    return iAccuracy;  
 }
 
 
-float mag_get_fAzimuth(void)
+void mag_get_fAzimuth(float *data)
 {
-    float fAzimuth = 0;
 #ifdef MAG_MMC5603
-    fAzimuth = (float)mag_service_get_fAzimuth();
+    if(data)
+        mag_service_get_fAzimuth(data);
 #endif
-    return fAzimuth;
 }
\ No newline at end of file
index 6c7b3b5..d08ed39 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-06-07 11:18:26
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2025-07-31 17:27:56
+ * @LastEditTime: 2025-08-18 17:33:40
  * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h
  * @Description: 
  * 
@@ -28,8 +28,9 @@ void mag_sensor_start(void);
 void mag_sensor_stop(void);
 
 uint8_t mag_get_chip_id(void);
-int mag_get_iAccuracy(void);
-float mag_get_fAzimuth(void);
+
+void mag_get_iAccuracy(int *data);
+void mag_get_fAzimuth(float *data);
 
 #ifdef __cplusplus
 #if __cplusplus
index 27d0fbb..34e90ba 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: 2025-08-16 18:15:33\r
+ * @LastEditTime: 2025-08-18 18:37:51\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -487,7 +487,7 @@ void aging_task(void)
             do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK);\r
             LOS_Msleep(1000);\r
 #ifdef SUPPORT_MAG_SERVICE\r
-            fAzimuth = mag_get_fAzimuth();\r
+            mag_get_fAzimuth(&fAzimuth);\r
 #endif\r
             do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK);\r
             if(fAzimuth < 0)\r
@@ -1692,13 +1692,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //地磁sensor测试\r
                 float fAzimuth,fPitch,fRoll;\r
-                \r
+#ifdef SUPPORT_MAG_SERVICE            \r
                 do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK);\r
                 LOS_Msleep(1000);\r
-#ifdef SUPPORT_MAG_SERVICE\r
-                fAzimuth = mag_get_fAzimuth();\r
-#endif\r
+\r
+                mag_get_fAzimuth(&fAzimuth);\r
+                printf("fAzimuth : %f\n",fAzimuth);\r
                 do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK);\r
+#endif\r
 #ifdef BOARD_FD230         \r
             \r
                 uint8_t databuf[6] = {0};\r
@@ -2204,6 +2205,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                         &send_data,\r
                         1);\r
             }\r
+            break;\r
         case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GPS:\r
 \r
             if (testitem == 0x01)\r
@@ -2268,12 +2270,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                     send_data[5] = (uint8_t)(((uint32_t)send_gps_data.th001_quality & 0x0000FF00) >> 8);\r
                     send_data[6] = (uint8_t)(((uint32_t)send_gps_data.th001_quality & 0x000000FF) >> 0);\r
 \r
-                    // PRINT("gps_data->num_sats : %d,gps_data->th001_valid_star_count : %d,gps_data->th000_signal_vga : %d,gps_data->th001_quality : %f\n",\r
-                    // send_gps_data.num_sats,send_gps_data.th001_valid_star_count,\r
-                    // send_gps_data.th000_signal_vga,send_gps_data.th001_quality\r
-                    // );\r
-                    // PRINT("%2X %2X %2X\r\n",send_data[0],send_data[1],send_data[2]);\r
-                    // PRINT("%2X %2X %2X %2X \r\n",send_data[3],send_data[4],send_data[5],send_data[6]);\r
+                    PRINT("gps_data->num_sats : %d,gps_data->th001_valid_star_count : %d,gps_data->th000_signal_vga : %d,gps_data->th001_quality : %f\n",\r
+                    send_gps_data.num_sats,send_gps_data.th001_valid_star_count,\r
+                    send_gps_data.th000_signal_vga,send_gps_data.th001_quality\r
+                    );\r
+                    PRINT("%2X %2X %2X\r\n",send_data[0],send_data[1],send_data[2]);\r
+                    PRINT("%2X %2X %2X %2X \r\n",send_data[3],send_data[4],send_data[5],send_data[6]);\r
                 }\r
 #endif\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
@@ -2284,7 +2286,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             }\r
 \r
             break;\r
-            break;\r
 \r
         default:\r
             printf("");\r
index aaba6b5..d7130ad 100644 (file)
@@ -290,7 +290,7 @@ void PGnssServerStart(void)
     #endif\r
     g_is_pgnss_poweron = 1;\r
     g_pgnss_stopflag = 0;\r
-\r
+    sw_debug_uart_deinit();\r
     // Step1: init\r
     int32_t ret = tiot_service_init();\r
     if (ret != 0) {\r
@@ -364,5 +364,7 @@ void PGnssServerStart(void)
     #endif\r
     uapi_pm_remove_sleep_veto(PM_ID_SYS);\r
     g_is_pgnss_poweron=0;\r
+    sw_debug_uart_deinit();\r
+    uart_config_init();\r
     printf("finish gnss samples\r\n");\r
 }\r