|
@@ -237,17 +237,44 @@ void OutterCmdHandle(T_UINT8 *msg, T_UINT16 len){
|
|
////////////////////////////////////////////inner////////////////////////////////////////////
|
|
////////////////////////////////////////////inner////////////////////////////////////////////
|
|
//inner命令表
|
|
//inner命令表
|
|
const T_INT8 *InnerTable[]={//添加需要处理module吐出来的指令
|
|
const T_INT8 *InnerTable[]={//添加需要处理module吐出来的指令
|
|
|
|
+ "+RTL271:",
|
|
"\r\n",
|
|
"\r\n",
|
|
""
|
|
""
|
|
};
|
|
};
|
|
//inner命令表枚举
|
|
//inner命令表枚举
|
|
typedef enum{
|
|
typedef enum{
|
|
|
|
+ CMD_SMS_CONFIG,
|
|
CMD_INNER_NONE=-1
|
|
CMD_INNER_NONE=-1
|
|
}CMD_INNER_TYPEDEF;
|
|
}CMD_INNER_TYPEDEF;
|
|
|
|
|
|
|
|
+/*
|
|
|
|
++RTL271:GPSMODE=0/1
|
|
|
|
+*/
|
|
|
|
+static void RTL271_SmsConfig(char *msg){
|
|
|
|
+ T_BOOL needsave=FALSE;
|
|
|
|
+ T_BOOL showUnknow=FALSE;
|
|
|
|
+ if(strcmp(msg, "GPSMODE=")){
|
|
|
|
+ if(msg[8]=='0'){
|
|
|
|
+ if(sut_para.forceGpsOnOffMode != 0){
|
|
|
|
+ sut_para.forceGpsOnOffMode=0;
|
|
|
|
+ needsave=TRUE;
|
|
|
|
+ }
|
|
|
|
+ }else if(msg[8]=='1'){
|
|
|
|
+ if(sut_para.forceGpsOnOffMode == 0){
|
|
|
|
+ sut_para.forceGpsOnOffMode=1;
|
|
|
|
+ needsave=TRUE;
|
|
|
|
+ }
|
|
|
|
+ }else showUnknow=TRUE;
|
|
|
|
+ if(showUnknow==FALSE) wlog_info("gps mode:%s", (sut_para.forceGpsOnOffMode!=0)?"keepOn":"onoff");
|
|
|
|
+ }else showUnknow=TRUE;
|
|
|
|
+
|
|
|
|
+ if(needsave==TRUE) SaveNewPara();
|
|
|
|
+ if(showUnknow==TRUE) wlog_warn("Unknow sms");
|
|
|
|
+}
|
|
|
|
+
|
|
void InnerCmdHandler(T_UINT8 *msg, T_UINT16 length){
|
|
void InnerCmdHandler(T_UINT8 *msg, T_UINT16 length){
|
|
T_INT16 cmd;
|
|
T_INT16 cmd;
|
|
- T_BOOL needAck=TRUE;
|
|
|
|
|
|
+ T_BOOL needAck=FALSE;
|
|
|
|
|
|
wlog_info("VAT:%d,%s",length,msg);
|
|
wlog_info("VAT:%d,%s",length,msg);
|
|
if(length<2) return;
|
|
if(length<2) return;
|
|
@@ -255,7 +282,11 @@ void InnerCmdHandler(T_UINT8 *msg, T_UINT16 length){
|
|
msg[length]=0;
|
|
msg[length]=0;
|
|
|
|
|
|
switch(cmd){
|
|
switch(cmd){
|
|
- default:
|
|
|
|
|
|
+ case CMD_SMS_CONFIG:
|
|
|
|
+ msg[length-2]=0;
|
|
|
|
+ RTL271_SmsConfig(msg+8);
|
|
|
|
+ break;
|
|
|
|
+ default:needAck=TRUE;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
if(TRUE==needAck){
|
|
if(TRUE==needAck){
|
|
@@ -289,6 +320,8 @@ const T_INT8 *usbTable[]={
|
|
"RT+ATI",
|
|
"RT+ATI",
|
|
"RT+FOTA=",
|
|
"RT+FOTA=",
|
|
"RT+GINFO",
|
|
"RT+GINFO",
|
|
|
|
+ "RT+PARA",
|
|
|
|
+ "RT+GPSMODE",
|
|
"RT+TEST",
|
|
"RT+TEST",
|
|
"\r\n",
|
|
"\r\n",
|
|
""
|
|
""
|
|
@@ -317,6 +350,8 @@ typedef enum{
|
|
USB_ATI,
|
|
USB_ATI,
|
|
USB_FOTA,
|
|
USB_FOTA,
|
|
USB_GINFO,
|
|
USB_GINFO,
|
|
|
|
+ USB_PARA,
|
|
|
|
+ USB_GPSMODE,
|
|
USB_TEST,
|
|
USB_TEST,
|
|
USB_NONE=-1
|
|
USB_NONE=-1
|
|
}USB_TYPEDEF;
|
|
}USB_TYPEDEF;
|
|
@@ -326,10 +361,23 @@ void testProcess(unsigned char *msg){
|
|
if(msg[0]=='1') TryvFileRePlay(LV_UN_PLAY);
|
|
if(msg[0]=='1') TryvFileRePlay(LV_UN_PLAY);
|
|
else if(msg[0]=='2') TryvFileRePlay(LV_PLAYED);
|
|
else if(msg[0]=='2') TryvFileRePlay(LV_PLAYED);
|
|
}
|
|
}
|
|
|
|
+//格式判定,必须有3个逗号,其它必须为’1‘到’9‘之间的数值
|
|
|
|
+char para_format_check(unsigned char *msg, int len){
|
|
|
|
+ int i;
|
|
|
|
+ unsigned char num=0;
|
|
|
|
+ for(i=0;i<len;i++){
|
|
|
|
+ if(msg[i]==','){
|
|
|
|
+ if(++num>3) return 1;
|
|
|
|
+ }else if(msg[i]<'0' || msg[i]>'9') return 2;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
void usbCmdExe(unsigned char *sms, int len){
|
|
void usbCmdExe(unsigned char *sms, int len){
|
|
T_INT16 cmd,i;
|
|
T_INT16 cmd,i;
|
|
T_INT32 tmp;
|
|
T_INT32 tmp;
|
|
T_BOOL needSendToInner=FALSE;
|
|
T_BOOL needSendToInner=FALSE;
|
|
|
|
+ char needSave=0;
|
|
|
|
+ T_BOOL recheckInterval=FALSE;
|
|
char buf[50];
|
|
char buf[50];
|
|
wlog_info("[USB]%d,%s",len,sms);
|
|
wlog_info("[USB]%d,%s",len,sms);
|
|
|
|
|
|
@@ -446,6 +494,74 @@ void usbCmdExe(unsigned char *sms, int len){
|
|
case USB_GINFO://RT+GINFO
|
|
case USB_GINFO://RT+GINFO
|
|
if(len == 10) getTestInfo();
|
|
if(len == 10) getTestInfo();
|
|
break;
|
|
break;
|
|
|
|
+ case USB_PARA://RT+PARA? RT+PARA=device_time,gnss_time,near_time,upload_time
|
|
|
|
+ if(len == 10 && sms[7]=='?'){
|
|
|
|
+ snprintf(buf, sizeof(buf),"+PARA:%d,%d,%d,%d\r\n", sut_para.devSampleInterval,sut_para.gnssSampleInterval,sut_para.nearSampleInterval,sut_para.dataUploadInterval);
|
|
|
|
+ msgToOutter(buf);
|
|
|
|
+ }else if(len >=13 && sms[7]=='='){
|
|
|
|
+ if(0!=para_format_check(sms+8, len-8-2)) {needSendToInner=TRUE;break;}
|
|
|
|
+ //device_time
|
|
|
|
+ if(sms[8]!=','){
|
|
|
|
+ tmp=atoi(sms+8);
|
|
|
|
+ wlog_info(">>device_time:%d",tmp);
|
|
|
|
+ if(tmp != sut_para.devSampleInterval && tmp >=ALL_MIN_SAMPLE_TIME){
|
|
|
|
+ #ifndef NOT_USE_SERVER_INTERVAL
|
|
|
|
+ sut_para.devSampleInterval=tmp;needSave=1;
|
|
|
|
+ recheckInterval=TRUE;
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //gnss_time
|
|
|
|
+ tmp = findByteFromStr(sms, len,',',1);
|
|
|
|
+ if(tmp>=0 && sms[tmp]!=','){
|
|
|
|
+ tmp=atoi(sms+tmp);
|
|
|
|
+ wlog_info(">>gnss_time:%d",tmp);
|
|
|
|
+ if(tmp != sut_para.gnssSampleInterval && tmp >=ALL_MIN_SAMPLE_TIME){
|
|
|
|
+ #ifndef NOT_USE_SERVER_INTERVAL
|
|
|
|
+ sut_para.gnssSampleInterval=tmp;needSave=1;
|
|
|
|
+ recheckInterval=TRUE;
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //near_time
|
|
|
|
+ tmp = findByteFromStr(sms, len,',',2);
|
|
|
|
+ if(tmp>=0 && sms[tmp]!=','){
|
|
|
|
+ tmp=atoi(sms+tmp);
|
|
|
|
+ wlog_info(">>near_time:%d",tmp);
|
|
|
|
+ if(tmp != sut_para.nearSampleInterval && tmp >=ALL_MIN_SAMPLE_TIME){
|
|
|
|
+ #ifndef NOT_USE_SERVER_INTERVAL
|
|
|
|
+ sut_para.nearSampleInterval=tmp;needSave=1;
|
|
|
|
+ recheckInterval=TRUE;
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //upload_time
|
|
|
|
+ tmp = findByteFromStr(sms, len,',',3);
|
|
|
|
+ if(tmp>=0 && sms[tmp]!='\r'){
|
|
|
|
+ tmp=atoi(sms+tmp);
|
|
|
|
+ wlog_info(">>upload_time:%d",tmp);
|
|
|
|
+ if(tmp != sut_para.dataUploadInterval && tmp >=ALL_MIN_SAMPLE_TIME){
|
|
|
|
+ #ifndef NOT_USE_SERVER_INTERVAL
|
|
|
|
+ sut_para.dataUploadInterval=tmp;needSave=1;
|
|
|
|
+ recheckInterval=TRUE;
|
|
|
|
+ #endif
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }else {needSendToInner=TRUE;break;}
|
|
|
|
+ break;
|
|
|
|
+ case USB_GPSMODE://RT+GPSMODE? RT+GPSMODE=0/1
|
|
|
|
+ if(len==13 && sms[10]=='?'){
|
|
|
|
+ snprintf(buf, sizeof(buf), "+GPSMODE:%d\r\n", sut_para.forceGpsOnOffMode);
|
|
|
|
+ msgToOutter(buf);
|
|
|
|
+ }else if(len == 14 && sms[10]=='=' && (sms[11]=='0' || sms[11]=='1')){
|
|
|
|
+ sms[11] -= 0x30;
|
|
|
|
+ if(sut_para.forceGpsOnOffMode != sms[11]){
|
|
|
|
+ sut_para.forceGpsOnOffMode=sms[11];
|
|
|
|
+ needSave=1;
|
|
|
|
+ wlog_info("gpsForceChange:%d", sut_para.forceGpsOnOffMode);
|
|
|
|
+ }
|
|
|
|
+ }else {needSendToInner=TRUE;break;}
|
|
|
|
+ break;
|
|
case USB_TEST://RT+TEST=0/1
|
|
case USB_TEST://RT+TEST=0/1
|
|
testProcess(sms+8);
|
|
testProcess(sms+8);
|
|
break;
|
|
break;
|
|
@@ -454,6 +570,8 @@ void usbCmdExe(unsigned char *sms, int len){
|
|
if(needSendToInner==TRUE){
|
|
if(needSendToInner==TRUE){
|
|
msgToInner((T_INT8 *)sms);
|
|
msgToInner((T_INT8 *)sms);
|
|
}
|
|
}
|
|
|
|
+ if(recheckInterval==TRUE) onWorkChecking(TRUE);
|
|
|
|
+ if(needSave!=0) SaveNewPara();
|
|
}
|
|
}
|
|
|
|
|
|
/*解析USB虚拟口PRTX收到的消息*/
|
|
/*解析USB虚拟口PRTX收到的消息*/
|