From: penglei <1624952103@qq.com> Date: Tue, 2 Apr 2024 07:11:09 +0000 (+0800) Subject: 优化蓝牙产测 X-Git-Tag: release_V1.2.70_20241020_135402~1238 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=78f7959cd0b8a0d87d23b901d6597eb10ef77c7c;p=mirrors%2FFD230.git 优化蓝牙产测 --- diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index 111445212..648b1cc06 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -19,6 +19,9 @@ #include "hx3695_spo2_agc.h" #include "hx3695_factory_test.h" #include "power_display_service.h" +#include "efuse.h" +#include "mag_service.h" + #pragma pack(1) typedef struct factorytest_cmd_header_t @@ -120,6 +123,7 @@ void ble_hrs_check_timer_callback(void) if(ble_hrs_flag == 1) { ble_hrs_flag = 0; + osTimerStop(g_ble_hrs_timer); osTimerDelete(g_ble_hrs_timer); ppg_send_cmd_to_driver("hrs",0); return; @@ -153,6 +157,7 @@ void ble_spo2_check_timer_callback(void) if(ble_spo2_flag == 1) { ble_spo2_flag = 0; + osTimerStop(g_ble_spo2_timer); osTimerDelete(g_ble_spo2_timer); ppg_send_cmd_to_driver("spo2",0); return; @@ -183,6 +188,7 @@ void ble_graycard_check_timer_callback(void) if(graycard_flag == 10) { graycard_flag = 0; + osTimerStop(g_ble_graycard_timer); osTimerDelete(g_ble_graycard_timer); return; } @@ -226,6 +232,7 @@ void ble_leaklight_check_timer_callback(void) if(leaklight_flag == 10) { leaklight_flag = 0; + osTimerStop(g_ble_leaklight_timer); osTimerDelete(g_ble_leaklight_timer); return; } @@ -359,14 +366,27 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if (testitem == 0x02) { //获取蓝牙地址 - uint8_t btaddr[128]={0}; - uint32_t btaddrlen = 0; - uapi_get_btaddr(&btaddr[1],&btaddrlen); - PRINT("len : %d \r\n",btaddrlen); + uint8_t btaddr[64]={0}; + uint32_t len = 64; + uint8_t send_data[7] = {0}; + uint8_t i = 1; + char *buf; + + uapi_get_btaddr((uint8_t*)btaddr,&len); + + PRINT("btaddr : %s \r\n",btaddr); + buf= strtok((char *)btaddr,":"); + + while(buf != NULL) + { + send_data[i++] = strtoul(buf,NULL,16); + buf = strtok(NULL,":"); + } + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_BLE, 0x02, - btaddr, + send_data, 7); } //获取蓝牙信号强度(未完成) @@ -417,7 +437,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint cycle_time_ms = 200; duty = 20; - + osTimerStop(g_ble_vibrator_timer); osTimerDelete(g_ble_vibrator_timer); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -447,7 +467,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //关闭周期性马达 uint8_t send_data = 0x00; - + osTimerStop(g_ble_vibrator_timer); osTimerDelete(g_ble_vibrator_timer); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -481,6 +501,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint char send_data[64] = {0}; get_system_time(&send_data[1]); uint16_t datalen = strlen(&send_data[1]); + for(int i = 0; i < datalen + 1 ; i++) + PRINT("timebuf : %s \r\n",send_data[i]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_RTC, 0x02, @@ -517,17 +539,17 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { uint8_t i; //获取soc_id - uint8_t soc_id[21] = {0}; // 20 is soc id length - uapi_soc_read_id(&soc_id[1], 21); + uint8_t soc_id[20] = {0}; // 20 is soc id length + uapi_soc_read_id(soc_id, 20); - for(i = 0; i < 21; i++) + for(i = 0; i < 20; i++) PRINT("soc_id[%d] : %2X \r\n",i,soc_id[i]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CUSTOM_CMD, 0x11, soc_id, - 21); + 20); } break; @@ -639,6 +661,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint tp_id[1] = id >> 8; tp_id[2] = id; + PRINT("data : %X %X \r\n",tp_id[1],tp_id[2]); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP, 0x01, @@ -668,19 +692,21 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取原始数据 int16_t x,y; get_tp_info(&x,&y); - uint16_t databuf[3] = {0}; + uint8_t databuf[5] = {0}; + + databuf[1] = (uint8_t)((x & 0XFF00) >> 8); + databuf[2] = (uint8_t)(x & 0X00FF); - databuf[0] = 0; - databuf[1] = x & 0XFF; - databuf[2] = y & 0XFF; + databuf[3] = (uint8_t)((y & 0XFF00) >> 8); + databuf[4] = (uint8_t)(y & 0X00FF); - PRINT("%2X %2X \r\n",databuf[1],databuf[2]); + PRINT("%2X %2X %2X %2X\r\n",databuf[1],databuf[2],databuf[3],databuf[4]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_TP, 0x05, databuf, - 3); + 5); } break; @@ -700,7 +726,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x04) { //单次获得acc - PRINT("333\r\n"); uint8_t databuf[6]; get_gsensor_single(databuf); @@ -713,7 +738,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x05) { //连续获得acc - PRINT("444\r\n"); g_ble_acc_timer = osTimerNew((osTimerFunc_t)ble_acc_check_timer_callback, osTimerPeriodic, NULL, NULL); osTimerStart(g_ble_acc_timer,1000); @@ -723,7 +747,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint uint8_t send_data = 0x00; osTimerStop(g_ble_acc_timer); - + osTimerDelete(g_ble_acc_timer); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_ACC, 0x06, @@ -800,7 +824,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x02) { - PRINT("555\r\n"); //地磁sensor测试 float fAzimuth,fPitch,fRoll; mmc5603_getdata(&fAzimuth,&fPitch,&fRoll); @@ -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); databuf[5] = (uint8_t)((uint32_t)fRoll & 0x00FF); - PRINT("fAzimuth : %f , fPitch : %f , fRoll : %f \r\n",fAzimuth,fPitch,fRoll); PRINT("%2X %2X %2X %2X %2X %2X\r\n",databuf[0],databuf[1],databuf[2],databuf[3],databuf[4],databuf[5]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -834,11 +856,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取充电状态 bool state; state = uapi_get_charger_plug_status(); + uint8_t send_data[2] = {0}; + send_data[1] = state; factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM, 0x02, - &state, - sizeof(state)); + send_data, + 2); } else if(testitem == 0x03) { @@ -890,20 +914,19 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //获得flash_id uint32_t id; - uint8_t flash_id[4] = {0}; + uint8_t flash_id[3] = {0}; flash_getid(&id); - flash_id[0] = id >> 24; - flash_id[1] = id >> 16; - flash_id[2] = id >> 8; - flash_id[3] = id >> 0; + flash_id[0] = id >> 16; + flash_id[1] = id >> 8; + flash_id[2] = id >> 0; factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_EXTFLASH, 0x01, flash_id, - 4); + 3); } else if(testitem == 0x02) { diff --git a/code/sdk/application/wstp/at_service/app/app_at_process.c b/code/sdk/application/wstp/at_service/app/app_at_process.c index 5fbc3e3f9..a68127b08 100755 --- a/code/sdk/application/wstp/at_service/app/app_at_process.c +++ b/code/sdk/application/wstp/at_service/app/app_at_process.c @@ -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) { char *ptr = (char *)data; - for(int i=0;i<4;i++) - { - PRINT("prt : %X ",ptr[i]); - } - PRINT("\n"); uint32_t color_input = strtoul(ptr, NULL, 16); wstp_print("color = %x \r\n", color_input); diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 7639e1cb9..ae950c5f9 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -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]); } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 465799fc7..6422343e3 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -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 *)" " },