优化蓝牙产测
authorpenglei <1624952103@qq.com>
Tue, 2 Apr 2024 07:11:09 +0000 (15:11 +0800)
committerpenglei <1624952103@qq.com>
Tue, 2 Apr 2024 07:11:09 +0000 (15:11 +0800)
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/application/wstp/at_service/app/app_at_process.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c

index 1114452..648b1cc 100644 (file)
@@ -19,6 +19,9 @@
 #include "hx3695_spo2_agc.h"\r
 #include "hx3695_factory_test.h"\r
 #include "power_display_service.h"\r
+#include "efuse.h"\r
+#include "mag_service.h"\r
+\r
 \r
 #pragma pack(1)\r
 typedef struct factorytest_cmd_header_t\r
@@ -120,6 +123,7 @@ void ble_hrs_check_timer_callback(void)
     if(ble_hrs_flag == 1)\r
     {\r
         ble_hrs_flag = 0;\r
+        osTimerStop(g_ble_hrs_timer);\r
         osTimerDelete(g_ble_hrs_timer);\r
         ppg_send_cmd_to_driver("hrs",0);\r
         return;\r
@@ -153,6 +157,7 @@ void ble_spo2_check_timer_callback(void)
     if(ble_spo2_flag == 1)\r
     {\r
         ble_spo2_flag = 0;\r
+        osTimerStop(g_ble_spo2_timer);\r
         osTimerDelete(g_ble_spo2_timer);\r
         ppg_send_cmd_to_driver("spo2",0);\r
         return;\r
@@ -183,6 +188,7 @@ void ble_graycard_check_timer_callback(void)
     if(graycard_flag == 10)\r
     {\r
         graycard_flag = 0;\r
+        osTimerStop(g_ble_graycard_timer);\r
         osTimerDelete(g_ble_graycard_timer);\r
         return;\r
     }\r
@@ -226,6 +232,7 @@ void ble_leaklight_check_timer_callback(void)
     if(leaklight_flag == 10)\r
     {\r
         leaklight_flag = 0;\r
+        osTimerStop(g_ble_leaklight_timer);\r
         osTimerDelete(g_ble_leaklight_timer);\r
         return;\r
     }\r
@@ -359,14 +366,27 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             if (testitem == 0x02)\r
             {\r
                 //获取蓝牙地址\r
-                uint8_t btaddr[128]={0};\r
-                uint32_t btaddrlen = 0;\r
-                uapi_get_btaddr(&btaddr[1],&btaddrlen);\r
-                PRINT("len : %d \r\n",btaddrlen);\r
+                uint8_t btaddr[64]={0};\r
+                uint32_t len = 64;\r
+                uint8_t send_data[7] = {0};\r
+                uint8_t i = 1;\r
+                char *buf;\r
+\r
+                uapi_get_btaddr((uint8_t*)btaddr,&len);\r
+\r
+                PRINT("btaddr : %s \r\n",btaddr);\r
+                buf=  strtok((char *)btaddr,":");\r
+\r
+                while(buf != NULL)\r
+                {\r
+                    send_data[i++] = strtoul(buf,NULL,16);\r
+                    buf = strtok(NULL,":");\r
+                }\r
+\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_BLE,\r
                         0x02,\r
-                        btaddr,\r
+                        send_data,\r
                         7);\r
             }\r
             //获取蓝牙信号强度(未完成)\r
@@ -417,7 +437,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 \r
                 cycle_time_ms = 200;\r
                 duty = 20;\r
-\r
+                osTimerStop(g_ble_vibrator_timer);\r
                 osTimerDelete(g_ble_vibrator_timer);\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
@@ -447,7 +467,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //关闭周期性马达\r
                 uint8_t send_data = 0x00;\r
-\r
+                osTimerStop(g_ble_vibrator_timer);\r
                 osTimerDelete(g_ble_vibrator_timer);\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
@@ -481,6 +501,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 char send_data[64] = {0};\r
                 get_system_time(&send_data[1]);\r
                 uint16_t datalen = strlen(&send_data[1]);\r
+                for(int i = 0; i < datalen + 1 ; i++)\r
+                    PRINT("timebuf : %s \r\n",send_data[i]);\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_RTC,\r
                         0x02,\r
@@ -517,17 +539,17 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 uint8_t i;\r
                 //获取soc_id\r
-                uint8_t soc_id[21] = {0}; // 20 is soc id length\r
-                uapi_soc_read_id(&soc_id[1], 21);\r
+                uint8_t soc_id[20] = {0}; // 20 is soc id length\r
+                uapi_soc_read_id(soc_id, 20);\r
 \r
-                for(i = 0; i < 21; i++)\r
+                for(i = 0; i < 20; i++)\r
                     PRINT("soc_id[%d] : %2X \r\n",i,soc_id[i]);\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CUSTOM_CMD,\r
                         0x11,\r
                         soc_id,\r
-                        21);\r
+                        20);\r
             }\r
 \r
             break;\r
@@ -639,6 +661,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 tp_id[1] = id >> 8;\r
                 tp_id[2] = id;\r
 \r
+                PRINT("data : %X %X \r\n",tp_id[1],tp_id[2]);\r
+\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP,\r
                         0x01,\r
@@ -668,19 +692,21 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 //获取原始数据\r
                 int16_t x,y;\r
                 get_tp_info(&x,&y);\r
-                uint16_t databuf[3] = {0};\r
+                uint8_t databuf[5] = {0};\r
+\r
+                databuf[1] = (uint8_t)((x & 0XFF00) >> 8);\r
+                databuf[2] = (uint8_t)(x & 0X00FF);\r
 \r
-                databuf[0] = 0;\r
-                databuf[1] = x & 0XFF;\r
-                databuf[2] = y & 0XFF;\r
+                databuf[3] = (uint8_t)((y & 0XFF00) >> 8);\r
+                databuf[4] = (uint8_t)(y & 0X00FF);\r
 \r
-                PRINT("%2X %2X \r\n",databuf[1],databuf[2]);\r
+                PRINT("%2X %2X %2X %2X\r\n",databuf[1],databuf[2],databuf[3],databuf[4]);\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP,\r
                         0x05,\r
                         databuf,\r
-                        3);\r
+                        5);\r
             }\r
 \r
             break;\r
@@ -700,7 +726,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             } else if(testitem == 0x04)\r
             {\r
                 //单次获得acc\r
-                PRINT("333\r\n");\r
                 uint8_t databuf[6];\r
                 get_gsensor_single(databuf);\r
 \r
@@ -713,7 +738,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             } else if(testitem == 0x05)\r
             {\r
                 //连续获得acc\r
-                PRINT("444\r\n");\r
                 g_ble_acc_timer = osTimerNew((osTimerFunc_t)ble_acc_check_timer_callback, osTimerPeriodic, NULL, NULL);\r
                 osTimerStart(g_ble_acc_timer,1000);\r
 \r
@@ -723,7 +747,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 uint8_t send_data = 0x00;\r
 \r
                 osTimerStop(g_ble_acc_timer);\r
-\r
+                osTimerDelete(g_ble_acc_timer);\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                             BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ACC,\r
                             0x06,\r
@@ -800,7 +824,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
 \r
             } else if(testitem == 0x02)\r
             {\r
-                PRINT("555\r\n");\r
                 //地磁sensor测试\r
                 float fAzimuth,fPitch,fRoll;\r
                 mmc5603_getdata(&fAzimuth,&fPitch,&fRoll);\r
@@ -816,7 +839,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 databuf[4] = (uint8_t)(((uint32_t)fRoll & 0xFF00) >> 8);\r
                 databuf[5] = (uint8_t)((uint32_t)fRoll & 0x00FF);\r
 \r
-                PRINT("fAzimuth : %f ,  fPitch : %f , fRoll : %f \r\n",fAzimuth,fPitch,fRoll);\r
                 PRINT("%2X %2X %2X %2X %2X %2X\r\n",databuf[0],databuf[1],databuf[2],databuf[3],databuf[4],databuf[5]);\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
@@ -834,11 +856,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                 //获取充电状态\r
                 bool state;\r
                 state = uapi_get_charger_plug_status();\r
+                uint8_t send_data[2] = {0};\r
+                send_data[1] = state;\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM,\r
                         0x02,\r
-                        &state,\r
-                        sizeof(state));\r
+                        send_data,\r
+                        2);\r
 \r
             } else if(testitem == 0x03)\r
             {\r
@@ -890,20 +914,19 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             {\r
                 //获得flash_id\r
                 uint32_t id;\r
-                uint8_t flash_id[4] = {0};\r
+                uint8_t flash_id[3] = {0};\r
 \r
                 flash_getid(&id);\r
 \r
-                flash_id[0] = id >> 24;\r
-                flash_id[1] = id >> 16;\r
-                flash_id[2] = id >> 8;\r
-                flash_id[3] = id >> 0;\r
+                flash_id[0] = id >> 16;\r
+                flash_id[1] = id >> 8;\r
+                flash_id[2] = id >> 0;\r
 \r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_EXTFLASH,\r
                         0x01,\r
                         flash_id,\r
-                        4);\r
+                        3);\r
 \r
             } else if(testitem == 0x02)\r
             {\r
index 5fbc3e3..a68127b 100755 (executable)
@@ -1928,11 +1928,6 @@ uint32_t at_nand_set_mode(uint8_t *data, uint32_t data_len)
 uint32_t lcd_fill(uint8_t *data, uint32_t data_len)\r
 {\r
     char *ptr = (char *)data;\r
-    for(int i=0;i<4;i++)\r
-    {\r
-        PRINT("prt : %X ",ptr[i]);\r
-    }\r
-    PRINT("\n");\r
     uint32_t color_input = strtoul(ptr, NULL, 16);\r
     wstp_print("color = %x \r\n", color_input);\r
 \r
index 7639e1c..ae950c5 100644 (file)
@@ -768,7 +768,7 @@ void touch_getid(uint16_t *id)
             PRINT("get ic information error2");
         } else
         {
-            PRINT("TOUCH CHIP ID = 0x%02x%02x",  chip_id[0], chip_id[1]);
+            PRINT("TOUCH CHIP ID = 0x%02x%02x \r\n",  chip_id[0], chip_id[1]);
             sprintf(id,"0x%02x%02x",  chip_id[0], chip_id[1]);
         }
     }
@@ -784,6 +784,7 @@ void touch_getstate(void)
 }
 
 #include "MMC5603.h"
+#include "mmc5603_hal.h"
 #include "mag_service.h"
 void mmc5603_getid(unsigned char *id)
 {
@@ -792,9 +793,11 @@ void mmc5603_getid(unsigned char *id)
 
 void mmc5603_getdata(float *fAzimuth,float *fPitch,float *fRoll)
 {
+    mmc5603_check();
     *fAzimuth = mag_service_get_fAzimuth();
     *fPitch = mag_service_get_fPitch();
     *fRoll = mag_service_get_fRoll();
+    PRINT("Azimuth : %f, fPitch : %f , fRoll : %f \r\n",*fAzimuth,*fPitch,*fRoll);
 }
 
 
@@ -828,6 +831,7 @@ void flash_getid(uint32_t *id)
     flash_info_t norflash_id;
     uapi_flash_get_info(0, &norflash_id);
     *id = norflash_id.flash_id;
+    PRINT("flash_id : %X \r\n",*id);
 }
 
 void flash_erase(void)
@@ -840,18 +844,19 @@ void flash_erase(void)
 
 void get_gsensor_single(uint8_t *databuf)
 {
-    gsenson_t *t;
-    get_gsonsen_xyz(t);
+    gsenson_t t;
+    get_gsonsen_xyz(&t);
 
-    databuf[0] = (uint8_t)((t->x & 0xFF00) >> 8);
-    databuf[1] = (uint8_t)(t->x & 0x00FF);
+    databuf[0] = (uint8_t)((t.x & 0xFF00) >> 8);
+    databuf[1] = (uint8_t)(t.x & 0x00FF);
 
-    databuf[2] = (uint8_t)((t->y & 0xFF00) >> 8);
-    databuf[3] = (uint8_t)(t->y & 0x00FF);
+    databuf[2] = (uint8_t)((t.y & 0xFF00) >> 8);
+    databuf[3] = (uint8_t)(t.y & 0x00FF);
 
-    databuf[4] = (uint8_t)((t->z & 0xFF00) >> 8);
-    databuf[5] = (uint8_t)(t->z & 0x00FF);
+    databuf[4] = (uint8_t)((t.z & 0xFF00) >> 8);
+    databuf[5] = (uint8_t)(t.z & 0x00FF);
 
+    PRINT("x : %d, y : %d, z : %d \r\n",t.x,t.y,t.z);
     PRINT("GSENSOR: %2X %2X %2X %2X %2X %2X\r\n",databuf[0],databuf[1],databuf[2],databuf[3],databuf[4],databuf[5]);
 
 }
index 465799f..6422343 100644 (file)
@@ -209,6 +209,18 @@ static uint32_t custom_mmc5603_getid(uint8_t *para, uint32_t paraLen, char *strC
 
     return ERRCODE_SUCC;
 }
+
+static uint32_t custom_mmc5603_getdata(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
+{
+
+    UNUSED(strCommonCmd);
+
+    float fAzimuth,fPitch,fRoll;
+    mmc5603_getdata(&fAzimuth,&fPitch,&fRoll);
+
+    return ERRCODE_SUCC;
+}
+
 #include "battery_hal.h"
 static uint32_t custom_charge_getstate(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 {
@@ -294,7 +306,8 @@ static uint32_t custom_vibrator_off(uint8_t *para, uint32_t paraLen, char *strCo
 static uint32_t custom_gsensor_getdata(uint8_t *para, uint32_t paraLen, char *strCommonCmd)
 {
     // gsenson_t *t;
-    // uint16_t databuf[6];
+    uint8_t databuf[6];
+    get_gsensor_single(databuf);
     UNUSED(strCommonCmd);
 
     return ERRCODE_SUCC;
@@ -330,6 +343,8 @@ static const at_cmd_table_t g_custom_utils_cmd[] = {
 
     { (char *)"AT^MMC5603ID",      custom_mmc5603_getid, (char *)" " },
 
+    { (char *)"AT^MMC5603GETDATA",      custom_mmc5603_getdata, (char *)" " },
+
     { (char *)"AT^CHARGESTATE",      custom_charge_getstate, (char *)" " },
 
     { (char *)"AT^GETPOWER",      custom_battery_getpower, (char *)" " },