From: hcj <1224667075@qq.com> Date: Thu, 11 Jul 2024 11:32:40 +0000 (+0800) Subject: 修复AI解析数据bug X-Git-Tag: release_V1.2.70_20241020_135402~828^2~1 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=9ec8e5299c7942378b6165f2d0ffa8275b7f1f34;p=mirrors%2FFD230.git 修复AI解析数据bug --- diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c index 485b2d695..7a0795424 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleEvent.c @@ -1995,7 +1995,7 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 { uint8_t flag = 0; // printf("jsonCheck_weather:len: json:%f jsonlen:%d\r\n",0.011,strlen((char *)json)); - #if 0 + #if 1 FILE *fp=fopen("user/AI.txt","wb+"); printf("binCheck_AI len %d\r\n",len); fwrite((void*)buf,1,len,fp); @@ -2019,26 +2019,34 @@ uint8_t binCheck_AI(uint8_t *buf,uint8_t *check,uint16_t len)//json 格式解析 printf("binCheck_AI txtbuf:%s %d\r\n",txt_buf,txt_len); ble_set_ai_Question_str(txt_buf); offset+=txt_len; - offset+=1; + //offset+=1; } - else if(buf[offset]==2) + if(buf[offset]==2) { offset++; - uint16_t txt_len=buf[offset]+buf[offset+1]*256; + uint16_t txt_len; + memcpy_s(&txt_len,2,&buf[offset],2); + offset+=2; char txt_buf[128]={0}; memcpy_s(txt_buf,128,&buf[offset],txt_len); - printf("%s %d\r\n",txt_buf,txt_len); + printf("binCheck_AI txtbuf %s %d\r\n",txt_buf,txt_len); ble_set_ai_Answer_str(txt_buf); offset+=txt_len; - offset+=1; + //offset+=1; + } + if(offset>=len) + { + break; } - else if(buf[offset]==0) + if(buf[offset]==0) { printf("AI 解析失败\r\n"); offset++; + break; } + offset++; } *check = 1; @@ -5101,7 +5109,7 @@ void* message_data(int uid,int appid,char *title,char *msg,int hasCode) data->appid=appid; memcpy_s(data->title,TITLE_BUF_LEN+1,title,strlen(title)); - memcpy_s(data->msg,TITLE_BUF_LEN+1,title,strlen(msg)); + memcpy_s(data->msg,MSG_BUF_LEN+1,msg,strlen(msg)); data->uid=uid; data->time=timeBuf; data->read=0;