From: penglei <1624952103@qq.com> Date: Sun, 7 Apr 2024 13:34:53 +0000 (+0800) Subject: 优化 X-Git-Tag: release_V1.2.70_20241020_135402~1230 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=6116c11d9a80fa6c1d9b36a73821a7d01451ed5f;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 5d0d4dab4..93359d109 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -21,7 +21,8 @@ #include "power_display_service.h" #include "efuse.h" #include "mag_service.h" - +#include "nandflash_config.h" +#include "string.h" #pragma pack(1) typedef struct factorytest_cmd_header_t @@ -32,8 +33,34 @@ typedef struct factorytest_cmd_header_t uint8_t submod; uint8_t testitem; }factorytest_cmd_header_t; + +typedef struct +{ + uint8_t send_data;//填充字节 + uint32_t flag; //老化测试状态 (完成 - 0xfdfd0000, 停止 - 0xfdfd0001, 开始-0xfdfd0002, 结束-0xfdfd0003) + uint32_t executions_num;//执行次数 + uint32_t target_num; //目标次数 + uint32_t fail_num; //失败次数 + uint32_t enter_age_time; //进入老化时间 + uint32_t age_time; //每轮老化结束时间 + uint16_t restart_num; //老化重启次数 + + uint32_t display_error; //屏失败次数 + uint32_t tp_error; //tp失败次数 + uint32_t gsensor_error; //A+G sensor失败次数 + uint32_t ppg_error; //ppg失败次数 + uint32_t mag_error; //magnetic 失败次数 + uint32_t motor_error; //motor失败次数 + uint32_t speaker_error; //speaker失败次数 + uint32_t flash_res_error; //片外资源失败次数 + uint16_t flash_bad_block_num; //老化前后flash的坏块数量差值 +}ble_aging_t; + #pragma pack() + +ble_aging_t aging_t; + static osTimerId_t g_ble_vibrator_timer; static osTimerId_t g_ble_acc_timer; @@ -49,6 +76,8 @@ static uint8_t leaklight_flag = 0; static uint16_t cycle_time_ms = 200; static uint16_t duty = 20; +static uint32_t aging_time = 0; + static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) { int crc = 0x0000; // initial value int polynomial = 0x1021; @@ -270,6 +299,185 @@ void ble_leaklight_check_timer_callback(void) leaklight_flag++; } +void get_rtc(uint32_t *msc) +{ + char time_data[64] = {0}; + uint8_t send_data1[20] = {0}; + uint8_t send_data2[7] = {0}; + + uint8_t i = 0; + get_system_time(time_data); + uint8_t len = strlen(time_data); + //1970-01-01 00:00:26 + PRINT("time_data : %s , len : %d\r\n",time_data,len); + + for (int j = 0; j < len; j ++) + { + if(time_data[j] >= '0' && time_data[j] <= '9' ) + { + send_data1[i++] = (time_data[j] - '0'); + } + } + + i = 0; + for(int j = 0; j < 14 ; j+=2) + { + send_data2[i++] = send_data1[j] * 10 + send_data1[j+1]; + } + + *msc = ((((send_data2[0] * 100 + send_data2[1] - 1970) * 365 + + (send_data2[2] -1)* 30 + (send_data2[3] - 1) ) * 24 + + send_data2[4]) * 60 + send_data2[5]) * 60 + + send_data2[6]; + +} + +void aging_task(void) +{ + //while(aging_t.flag == 0xfdfd0002 && aging_time) + while(aging_t.flag == 0xfdfd0002) + { + msleep(60000); + + uint32_t msc; + get_rtc(&msc); + aging_t.enter_age_time = msc; + PRINT("aging_t.enter_age_time : %d \r\n",aging_t.enter_age_time); + aging_t.executions_num++; + PRINT("aging_t.executions_num : %d \r\n",aging_t.executions_num); + aging_t.target_num = msc/60; + PRINT("aging_t.target_num : %d \r\n",aging_t.target_num); + aging_t.fail_num = 0; + PRINT("aging_t.fail_num : %d \r\n",aging_t.fail_num); + aging_t.restart_num = 0; + PRINT("aging_t.restart_num : %d \r\n",aging_t.restart_num); + + uint16_t before_block_num; + struct nand_driver_struct *nandflash_driver; + nandflash_driver = get_nand_flash(); + for (uint32_t i = 0; i < nandflash_driver->total_block; i++) + { + if (nandflash_driver->check_bad_block(i) == 1) + { + before_block_num++; + } + } + + uint32_t id; + lcd_getid(&id); + if(id != 0x1133) + { + aging_t.display_error++; + aging_t.fail_num++; + } + mcu_pm_lcd_on(0,0); + mcu_pm_lcd_off(0,0); + PRINT("aging_t.display_error : %d \r\n",aging_t.display_error); + + + ppg_send_cmd_to_driver("leaklight",1); + FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); + ppg_send_cmd_to_driver("leaklight",0); + if(ft_result.gr_data_final < 10000 || ft_result.red_data_final < 10000 || ft_result.ir_data_final < 10000) + { + aging_t.ppg_error++; + aging_t.fail_num++; + } + + PRINT("aging_t.ppg_error : %d \r\n",aging_t.ppg_error); + + uint16_t tp_id; + touch_getid(&tp_id); + if(tp_id != 0x6456) + { + aging_t.tp_error++; + aging_t.fail_num++; + } + PRINT("aging_t.tp_error : %d \r\n",aging_t.tp_error); + + gsenson_t g; + get_gsonsen_xyz(&g); + if(g.x == 0 && g.y == 0 && g.z == 0) + { + aging_t.gsensor_error++; + aging_t.fail_num++; + } + PRINT("aging_t.gsensor_error : %d \r\n",aging_t.gsensor_error); + + float fAzimuth,fPitch,fRoll; + mmc5603_getdata(&fAzimuth,&fPitch,&fRoll); + if(fAzimuth < 0) + { + aging_t.mag_error++; + aging_t.fail_num++; + } + PRINT("aging_t.mag_error : %d \r\n",aging_t.mag_error); + + vibrator_cyclicity(20,200,2000); + aging_t.motor_error = 0; + PRINT("aging_t.motor_error : %d \r\n",aging_t.motor_error); + + aging_t.speaker_error = 0; + PRINT("aging_t.speaker_error : %d \r\n",aging_t.speaker_error); + + uint32_t flash_id; + flash_getid(&flash_id); + if(flash_id == 0) + { + aging_t.flash_res_error++; + aging_t.fail_num++; + } + PRINT("aging_t.flash_res_error : %d \r\n",aging_t.flash_res_error); + + uint16_t after_block_num; + nandflash_driver = get_nand_flash(); + for (uint32_t i = 0; i < nandflash_driver->total_block; i++) + { + if (nandflash_driver->check_bad_block(i) == 1) + { + after_block_num++; + } + } + + aging_t.flash_bad_block_num = after_block_num - before_block_num; + + get_rtc(&msc); + aging_t.age_time = msc; + PRINT("aging_t.age_time : %d \r\n",aging_t.age_time); + aging_time -= (aging_t.age_time - aging_t.enter_age_time); + PRINT("aging_time : %d \r\n",aging_time); + if(aging_time == 0) + { + aging_t.flag = 0xfdfd0000; + return; + } + } +} + +errcode_t aging_test_init(void) +{ + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = NULL; + taskcfg.attr.name="aging_test_service"; + taskcfg.attr.priority = TASK_PRIORITY_CMD; + taskcfg.attr.stack_size = 1024*8; + taskcfg.func = aging_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + PRINT("create ppg_service failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + memset(&aging_t, 0, sizeof(ble_aging_t)); + aging_t.flag = 0xfdfd0002; + + return ERRCODE_SUCC; +} + + /** * BLE_TEST_CMD_MODE_COMMON * factorytest_protocol_common_decode @@ -498,37 +706,9 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x02) { //获取RTC - char time_data[64] = {0}; - uint8_t send_data1[20] = {0}; - uint8_t send_data2[7] = {0}; uint8_t time_stamp[5] = {0}; - uint32_t msc = 0; - - uint8_t i = 0; - get_system_time(time_data); - uint8_t len = strlen(time_data); - //1970-01-01 00:00:26 - PRINT("time_data : %s , len : %d\r\n",time_data,len); - - for (int j = 0; j < len; j ++) - { - if(time_data[j] >= '0' && time_data[j] <= '9' ) - { - send_data1[i++] = (time_data[j] - '0'); - } - } - - i = 0; - for(int j = 0; j < 14 ; j+=2) - { - send_data2[i++] = send_data1[j] * 10 + send_data1[j+1]; - } - - msc = ((((send_data2[0] * 100 + send_data2[1] - 1970) * 365 - + (send_data2[2] -1)* 30 + (send_data2[3] - 1) ) * 24 - + send_data2[4]) * 60 + send_data2[5]) * 60 - + send_data2[6]; + get_rtc(&msc); time_stamp[1] = (uint8_t)((msc & 0XFF000000) >> 24); time_stamp[2] = (uint8_t)((msc & 0X00FF0000) >> 16); @@ -557,8 +737,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //进入老化命令 uint8_t send_data = 0x00; - - set_system_time((char *)data); + aging_time = (*data) * 60 * 60; + aging_test_init(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x01, @@ -569,7 +749,9 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //停止老化 uint8_t send_data = 0x00; - set_system_time((char *)data); + aging_t.flag = 0xfdfd0001; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x02, @@ -579,33 +761,35 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x03) { //查询老化标志 - uint8_t send_data = 0x00; + uint8_t send_data[3] = {0}; - set_system_time((char *)data); + if(aging_t.fail_num != 0) + { + send_data[1] = 0xff; + send_data[2] = 0x01; + } factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x03, - &send_data, - 1); + send_data, + 3); } else if(testitem == 0x04) { //查询老化结果 - uint8_t send_data = 0x00; - set_system_time((char *)data); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x04, - &send_data, - 1); + &aging_t, + sizeof(aging_t)); } else if(testitem == 0x05) { //清除老化结果 uint8_t send_data = 0x00; - set_system_time((char *)data); + memset(&aging_t, 0, sizeof(ble_aging_t)); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x05, @@ -685,7 +869,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x02) { //LCD 上电 - mcu_pm_lcd_on(0,0); uint8_t send_data = 0x00; mcu_pm_lcd_on(0,0); @@ -1096,41 +1279,89 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x02, &send_data, 1); - - } else if(testitem == 0x03) { - //查看sim卡插入状态(未完成) - // uint8_t send_data = 0x00; - // uint16_t len = sizeof(send_data); - - // factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - // BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, - // 0x03, - // &send_data, - // len); + PRINT("111\r\n"); + //查看sim卡插入状态 + uint8_t send_data[2] = {0}; + uint16_t len = sizeof(send_data); + + cat1_getsignal(); + char *tokbuf=NULL; + tokbuf=strtok(networkmsg,":"); + if(strcmp(tokbuf,"imei")==0) + { + tokbuf=strtok(NULL,","); + tokbuf=strtok(NULL,":"); + tokbuf=strtok(NULL,","); + send_data[1]=atoi(tokbuf); + PRINT("sim status : %d \r\n",send_data[1]); + } + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, + 0x03, + send_data, + 2); } else if(testitem == 0x04) { - //查看信号强度(未完成) - // uint8_t send_data = 0x00; - // uint16_t len = sizeof(send_data); - - // factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - // BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, - // 0x04, - // &send_data, - // len); + //查看信号强度 + uint8_t send_data[2] = {0}; + + cat1_getsignal(); + char *tokbuf=NULL; + tokbuf=strtok(networkmsg,":"); + if(strcmp(tokbuf,"imei")==0) + { + tokbuf=strtok(NULL,","); + tokbuf=strtok(NULL,":"); + tokbuf=strtok(NULL,","); + tokbuf=strtok(NULL,"("); + tokbuf=strtok(NULL,")"); + tokbuf=strtok(NULL,":"); + tokbuf=strtok(NULL,","); + send_data[1]=atoi(tokbuf); + PRINT("signal : %d \r\n",send_data[1]); + } + + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, + 0x04, + send_data, + 2); } else if(testitem == 0x05) { - //查看网络类型(未完成) - // uint8_t send_data = 0x00; - // uint16_t len = sizeof(send_data); - - // factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - // BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, - // 0x05, - // &send_data, - // len); + //查看网络类型 + uint8_t send_data = 0x00; + + cat1_getsignal(); + char *tokbuf=NULL; + char *buf1=NULL; + char *buf2=NULL; + + tokbuf=strtok(networkmsg,":"); + if(strcmp(tokbuf,"imei")==0) + { + //'CHN-CT', 'CT', '460', '11' + tokbuf=strtok(NULL,","); + tokbuf=strtok(NULL,":"); + tokbuf=strtok(NULL,","); + tokbuf=strtok(NULL,"("); + tokbuf=strtok(NULL,")"); + + buf1=strtok(tokbuf+1,"-"); + buf2=strtok(NULL,"'"); + + strcat(buf1,buf2); + PRINT("send_buf : %s \r\n",buf1); + } + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, + 0x05, + (uint8_t *)buf1, + 5); } else if(testitem == 0x06) { //拨打电话 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 a68127b08..136ea7faa 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 @@ -2359,7 +2359,7 @@ static uint32_t mcu_get_time(uint8_t *para, uint32_t para_len) { unused(para); unused(para_len); - uint32_t timebuf; + char timebuf[64]; return get_system_time(&timebuf); } diff --git a/code/sdk/application/wstp/at_service/app/app_common_api.c b/code/sdk/application/wstp/at_service/app/app_common_api.c index 9bf572023..597d1ff11 100755 --- a/code/sdk/application/wstp/at_service/app/app_common_api.c +++ b/code/sdk/application/wstp/at_service/app/app_common_api.c @@ -197,20 +197,20 @@ uint32_t get_system_time(char *timedata) wstp_print("%s", timebuf); } - //sprintf(timedata,"%s",timebuf); + sprintf(timedata,"%s",timebuf); uint32_t millisec = tv.tv_usec / USEC_TO_MILLI; wstp_print(":%03d\n", millisec); - char millisecdata[5] = {0}; - millisecdata[0] = (char)((millisec & 0XFF000000)>> 24); - millisecdata[1] = (char)((millisec & 0X00FF0000)>> 16); - millisecdata[2] = (char)((millisec & 0X0000FF00)>> 8); - millisecdata[3] = (char)((millisec & 0X000000FF)>> 0); + // char millisecdata[4] = {0}; + // millisecdata[0] = (char)((millisec & 0XFF000000)>> 24); + // millisecdata[1] = (char)((millisec & 0X00FF0000)>> 16); + // millisecdata[2] = (char)((millisec & 0X0000FF00)>> 8); + // millisecdata[3] = (char)((millisec & 0X000000FF)>> 0); - PRINT("mil %d %d %d %d \r\n",millisecdata[0],millisecdata[1],millisecdata[2],millisecdata[3]); + // PRINT("mil %d %d %d %d \r\n",millisecdata[0],millisecdata[1],millisecdata[2],millisecdata[3]); - sprintf(timedata,"%s%s",timebuf,millisecdata); + // sprintf(timedata,"%s%s",timebuf,millisecdata); return ERRCODE_SUCC; } diff --git a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h index 3032a0b32..f672f39e4 100644 --- a/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h +++ b/code/sdk/drivers/peripheral/slip/cat1Service/cat1_server.h @@ -30,6 +30,8 @@ void cat1_reset_network(void); errcode_t cat1_server_init(void); +extern char networkmsg[124]; + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index ae950c5f9..9548c9c51 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -769,7 +769,8 @@ void touch_getid(uint16_t *id) } else { 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]); + *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); + //sprintf(id,"0x%02x%02x", chip_id[0], chip_id[1]); } } }