Browse Source

RTL271_V06029
* 修改SOFTWARE_BUILD_DATE
* 添加修改设备信息,GNSS,临近设备,上传频率时间的串口配置接口
* 添加接口可以配置是否让GPS处于常开模式还是开关模式(默认开关模式)
* 添加短信配置GPS开启的模式

wangjianlin 2 năm trước cách đây
mục cha
commit
42ae5bd44a
6 tập tin đã thay đổi với 153 bổ sung29 xóa
  1. 2 2
      app/app.h
  2. 120 2
      app/atCmdList.c
  3. 27 24
      app/location.c
  4. 2 0
      app/main.c
  5. 2 1
      app/para.h
  6. BIN
      out/RTL271_V06029.pac

+ 2 - 2
app/app.h

@@ -6,7 +6,7 @@
 
 #define APP_MODULE_TYPE 	"M5700"
 #define APP_NAME 			"RTL271" //不能随便修改,因为这个值对应该服务器差分文件所在的目录文件名
-#define APP_VERSION 		"06028"     //05  SDK_T05   017 LTE version
+#define APP_VERSION 		"06029"     //05  SDK_T05   017 LTE version
 #define APP_TEST    		0        //0 for released version , else for test version
 #define APP_CUSTOMER  		0        //0 for released version , else for customer version
 
@@ -18,7 +18,7 @@
 #define APP_HARDVERSION 	1000
 #define APP_DEVICE_TYPE 	"RTL_RTU"
 #define APP_AKEY 			0x12345678
-#define SOFTWARE_BUILD_DATE 0x210728
+#define SOFTWARE_BUILD_DATE 0x220225
 #define SOFTWARE_BUILD_TIME 0x0001
 #define SENSOR_MODEL 		"UNDEFINE"
 

+ 120 - 2
app/atCmdList.c

@@ -237,17 +237,44 @@ void OutterCmdHandle(T_UINT8 *msg, T_UINT16 len){
 ////////////////////////////////////////////inner////////////////////////////////////////////
 //inner命令表
 const T_INT8 *InnerTable[]={//添加需要处理module吐出来的指令
+  "+RTL271:",
   "\r\n",
   ""
 };
 //inner命令表枚举
 typedef enum{
+  CMD_SMS_CONFIG,
   CMD_INNER_NONE=-1
 }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){
   T_INT16 cmd;
-  T_BOOL needAck=TRUE;
+  T_BOOL needAck=FALSE;
 
   wlog_info("VAT:%d,%s",length,msg);
   if(length<2) return;
@@ -255,7 +282,11 @@ void InnerCmdHandler(T_UINT8 *msg, T_UINT16 length){
   msg[length]=0;
 
   switch(cmd){
-    default:
+	  case CMD_SMS_CONFIG:
+	    msg[length-2]=0;
+	    RTL271_SmsConfig(msg+8);
+		break;
+    default:needAck=TRUE;
       break;
   }
   if(TRUE==needAck){
@@ -289,6 +320,8 @@ const T_INT8 *usbTable[]={
   "RT+ATI",
   "RT+FOTA=",
   "RT+GINFO",
+  "RT+PARA",
+  "RT+GPSMODE",
   "RT+TEST",
   "\r\n",
   ""
@@ -317,6 +350,8 @@ typedef enum{
   USB_ATI,
   USB_FOTA,
   USB_GINFO,
+  USB_PARA,
+  USB_GPSMODE,
   USB_TEST,
   USB_NONE=-1
 }USB_TYPEDEF;
@@ -326,10 +361,23 @@ void testProcess(unsigned char *msg){
   if(msg[0]=='1') TryvFileRePlay(LV_UN_PLAY);
   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){
   T_INT16 cmd,i;
   T_INT32 tmp;
   T_BOOL needSendToInner=FALSE;
+  char needSave=0;
+  T_BOOL recheckInterval=FALSE;
   char buf[50];
   wlog_info("[USB]%d,%s",len,sms);
 
@@ -446,6 +494,74 @@ void usbCmdExe(unsigned char *sms, int len){
     case USB_GINFO://RT+GINFO
       if(len == 10) getTestInfo();
       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
       testProcess(sms+8);
       break;
@@ -454,6 +570,8 @@ void usbCmdExe(unsigned char *sms, int len){
   if(needSendToInner==TRUE){
     msgToInner((T_INT8 *)sms);
   }
+  if(recheckInterval==TRUE) onWorkChecking(TRUE);
+  if(needSave!=0) SaveNewPara();
 }
 
 /*解析USB虚拟口PRTX收到的消息*/

+ 27 - 24
app/location.c

@@ -568,36 +568,39 @@ GPS定位及逻辑控制pt任务
 PT_THREAD (ptLocationTask(pt_timer_t *ptPool, struct pt *pt)){
 	static pt_timer_t ptTimer;
 	static unsigned char lastWorkZone=0xff;
-
+	static unsigned char forceGpsOnOffMode=35;
 	PT_BEGIN(pt);
 	while(1){
 		//检测作业状态变化
-		#if 0
-		gpsOnOffToWork();
-		#else
-		if(lastWorkZone != app.onWorkZone){
-			lastWorkZone=app.onWorkZone;
-			//工作状态发变化,检查GPS状态
-			if(lastWorkZone==0){//从作业状态变为非作业状态
-				wlog_warn("work-->non_work");
-				if(isGpsKeepOnByTime()==TRUE){//采样小于设定值,GPS继续常开工作模式
-					wlog_warn("gps keep on mode");
-				}else{//GPS开关工作模式
-					wlog_warn("gps onOff mode");
-					gps.status=GS_WAIT;
-					gps.waitCnt=0;
+		if(sut_para.forceGpsOnOffMode != forceGpsOnOffMode){
+			forceGpsOnOffMode=sut_para.forceGpsOnOffMode;
+			wlog_warn("gpsForce:%s", (forceGpsOnOffMode!=0)?"keep on":"onOff");
+		}
+		if(forceGpsOnOffMode==0) gpsOnOffToWork();
+		else{
+			if(lastWorkZone != app.onWorkZone){
+				lastWorkZone=app.onWorkZone;
+				//工作状态发变化,检查GPS状态
+				if(lastWorkZone==0){//从作业状态变为非作业状态
+					wlog_warn("work-->non_work");
+					if(isGpsKeepOnByTime()==TRUE){//采样小于设定值,GPS继续常开工作模式
+						wlog_warn("gps keep on mode");
+					}else{//GPS开关工作模式
+						wlog_warn("gps onOff mode");
+						gps.status=GS_WAIT;
+						gps.waitCnt=0;
+					}
+				}else{//从非作业状态变为作业状态
+					wlog_warn("non_work-->work");
+					gps.gpsValid=GPS_INVALID;//消除定位标记
 				}
-			}else{//从非作业状态变为作业状态
-				wlog_warn("non_work-->work");
-				gps.gpsValid=GPS_INVALID;//消除定位标记
+				gps.gpsInterval=0;
+				if(app.gpsPwrStatus==FALSE) gpsStart();
 			}
-			gps.gpsInterval=0;
-			if(app.gpsPwrStatus==FALSE) gpsStart();
+			//定向工作模式
+			if(lastWorkZone==0) gpsOnOffToWork();
+			else gpsKeepOnToWork();
 		}
-		//定向工作模式
-		if(lastWorkZone==0) gpsOnOffToWork();
-		else gpsKeepOnToWork();
-		#endif
 		//apgs工作
 		agpsCtl();
 		PTTimerStart(ptPool, &ptTimer,100);

+ 2 - 0
app/main.c

@@ -63,6 +63,8 @@ static void InitStart(void){
 #endif
 	//先发消息,MCU先把电源锁住
 	setInitMcu();
+	//配置收到手机短信主动上报内容
+	innerInfo("AT+CNMI=0,2,0,0,0\r\n",19);
 	//再振动
 	vibraNow();
 	//检测是否有未播放文件

+ 2 - 1
app/para.h

@@ -59,7 +59,8 @@ typedef struct{
 
 	ARRANGE_DEF arrange;			//排班信息
 	//保留用于扩展
-	T_UINT8 reverse[REVERSED_SIZE];
+	T_UINT8 forceGpsOnOffMode;//是否强制处理于GPS开关的模式 1 常开模式 0 开关模式
+	T_UINT8 reverse[REVERSED_SIZE-1];
 }PARA_DEF;
 #pragma pack(pop)
 extern PARA_DEF sut_para;

BIN
out/RTL271_V06029.pac