From: penglei <1624952103@qq.com> Date: Tue, 2 Apr 2024 12:26:58 +0000 (+0800) Subject: 优化蓝牙产测,修改读取RTC,读取SN, X-Git-Tag: release_V1.2.70_20241020_135402~1236 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=ba9ef25472ac015ad50a83e9b566e76b4e366b45;p=mirrors%2FFD230.git 优化蓝牙产测,修改读取RTC,读取SN, --- 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 648b1cc06..658ff9416 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -498,18 +498,52 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x02) { //获取RTC - 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]); + 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]; + + time_stamp[1] = (uint8_t)((msc & 0XFF000000) >> 24); + time_stamp[2] = (uint8_t)((msc & 0X00FF0000) >> 16); + time_stamp[3] = (uint8_t)((msc & 0X0000FF00) >> 8); + time_stamp[4] = (uint8_t)((msc & 0X000000FF) >> 0); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_RTC, 0x02, - &send_data, - datalen+1); + time_stamp, + 5); } + break; + case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CUSTOM_CMD: if(testitem == 0x01) { @@ -527,14 +561,16 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //读SN uint8_t send_data[64] = {0}; - uint32_t datalen; + uint32_t datalen = 63; zh_get_sn(&send_data[1],&datalen); - + PRINT("len : %d \r\n",datalen); + for(int i = 0; i < datalen; i++) + PRINT("send_data[%d] : %X \r\n",i,send_data[i]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CUSTOM_CMD, 0x02, send_data, - datalen+1); + datalen); } else if(testitem == 0x11) { uint8_t i; @@ -1118,7 +1154,6 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) // 主模式ID 生产软件 0x02 case BLE_TEST_CMD_MODE_SOFT_TEST: - PRINT("111\r\n"); factorytest_protocol_soft_test_decode(header.submod,header.testitem, buf+1+2+1+1+1, header.len); 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 626ab26b0..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,12 +197,20 @@ uint32_t get_system_time(char *timedata) wstp_print("%s", timebuf); } - memcmp(timedata,&timebuf,strlen(&timebuf)); + sprintf(timedata,"%s",timebuf); uint32_t millisec = tv.tv_usec / USEC_TO_MILLI; wstp_print(":%03d\n", millisec); - timedata = strcat(timedata,&millisec); + // 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]); + + // sprintf(timedata,"%s%s",timebuf,millisecdata); return ERRCODE_SUCC; }