haitao пре 10 месеци
родитељ
комит
841e798780

+ 3 - 14
app/MDKProject/lora_gateway.uvprojx

@@ -16,8 +16,8 @@
         <TargetCommonOption>
           <Device>STM32F207ZGTx</Device>
           <Vendor>STMicroelectronics</Vendor>
-          <PackID>Keil.STM32F2xx_DFP.2.10.0</PackID>
-          <PackURL>http://www.keil.com/pack/</PackURL>
+          <PackID>Keil.STM32F2xx_DFP.2.9.0</PackID>
+          <PackURL>http://www.keil.com/pack</PackURL>
           <Cpu>IRAM(0x20000000,0x00020000) IROM(0x08000000,0x00100000) CPUTYPE("Cortex-M3") CLOCK(12000000) ELITTLE</Cpu>
           <FlashUtilSpec></FlashUtilSpec>
           <StartupFile></StartupFile>
@@ -185,8 +185,6 @@
             <uocXRam>0</uocXRam>
             <RvdsVP>0</RvdsVP>
             <RvdsMve>0</RvdsMve>
-            <RvdsCdeCp>0</RvdsCdeCp>
-            <nBranchProt>0</nBranchProt>
             <hadIRAM2>0</hadIRAM2>
             <hadIROM2>0</hadIROM2>
             <StupSel>8</StupSel>
@@ -353,7 +351,7 @@
             <NoWarn>0</NoWarn>
             <uSurpInc>0</uSurpInc>
             <useXO>0</useXO>
-            <ClangAsOpt>4</ClangAsOpt>
+            <uClangAs>0</uClangAs>
             <VariousControls>
               <MiscControls></MiscControls>
               <Define></Define>
@@ -1191,13 +1189,4 @@
     <files/>
   </RTE>
 
-  <LayerInfo>
-    <Layers>
-      <Layer>
-        <LayName>lora_gateway</LayName>
-        <LayPrjMark>1</LayPrjMark>
-      </Layer>
-    </Layers>
-  </LayerInfo>
-
 </Project>

BIN
app/OBJ/lora_gateway.axf


Разлика између датотеке није приказан због своје велике величине
+ 17825 - 18486
app/OBJ/lora_gateway.hex


+ 1 - 1
app/System/includes/json_queue.h

@@ -4,8 +4,8 @@
 #include "string.h"
 void creat_queue(void);
 typedef struct {
-    char *p;
     uint32_t stringLength;
+     char *p;
 } StringInfo;
 
 

+ 5 - 6
app/System/source/sys_mqtt.c

@@ -71,13 +71,13 @@ void mqtt_outputMsg(MQTTString *name, uint8_t *msgbuf, int msglen, uint16_t id,
 {
 	int lenght=msglen;
 	MQTT_PRINTF("receive a msg: id=%d qos=%d topic=%s msg=%s \r\n", id, qos, name->lenstring.data, msgbuf);
-	StringInfo message;
-	message.stringLength=msglen;
-	message.p=mymalloc(SRAMIN ,msglen+1);
-	memcpy(message.p,msgbuf,msglen);
+	StringInfo *message=mymalloc(SRAMIN ,sizeof(StringInfo));
+	message->stringLength=msglen;
+	message->p=mymalloc(SRAMIN ,msglen+1);
+	memcpy(message->p,msgbuf,msglen);
 	uint8_t err;
 	OSTimeDly(1500);
-	err=OSQPost(JsonQ,(void *)&message);
+	err=OSQPost(JsonQ,message);
 	commd = 0;
 	switch(err)
 	{
@@ -171,7 +171,6 @@ int mqtt_userReceiveMessage(int sock, int type, uint8_t *pbuf, int len)
 *        -2: 组建发送数据时发送错误
 *************************************************************/
 char pubJsonString[jsonMaxSize];
-char pubJsonStringCopy[jsonMaxSize];
 int mqtt_userSendMessage(int sock, int boxMsg)
 {
 	GATEWAY_PARAMS* get;

+ 66 - 56
app/System/source/task.c

@@ -57,68 +57,78 @@ void data_task(void *pdata)
 	get= get_gateway_config_params();
 	int deviceIndex=0;
 	DEVICE_PARAMS *current_device=get->device_params;
-	
 //	Config_485_Port(get->baudrate, get->dataBits, get->stopBit, get->parity, get->flowControl);
-	 
 	while (current_device!=NULL)
 	{
 		uint8_t err;
-		StringInfo *message=NULL; //���ն�����Ϣ�ṹ��
-		message=(StringInfo *)OSQPend(JsonQ,1000,&err);
-		if(commd)
-		{			
-			READ_DATA(current_device, buf);		
-			if(current_device->nextDevice!=NULL) 
-			{
-				current_device=current_device->nextDevice;		
-			}
-			else
-			{		 
-				sprintf(buf + strlen(buf) - 1, "}");
-					time1 = OSTimeGet();
-					if( jsoncunt || time2  <= time1 - 20000)
-					{
-						memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
-						memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//������һ�ε�����
-						sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);									
-						int msg = MBOX_USER_PUBLISHQOS2;	
-						if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
-						current_device=get->device_params;
-						jsoncunt = 0;
-						time2 = OSTimeGet();
-					}//20s����һ��
-					
-					else
-					{
-						if(strcmp(buf,pubJsonStringCopy))
-						{
-							memset(string, 0 , strlen(string));
-							findDifference(buf, pubJsonStringCopy, string);	
-							memset(pubJsonString,0, strlen(pubJsonString));
-							sprintf(pubJsonString,"{\"deviceId\":\"%s\",\"data\":[{%s}]}",get->deviceId, string);
-							memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
-							sprintf(pubJsonStringCopy, buf, strlen(buf));
-						
-							int msg = MBOX_USER_PUBLISHQOS2;	
-							if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);	
-						}
-				}	
-				memset(buf,0,strlen(buf));	
-				current_device=get->device_params;
-			}			
+		StringInfo *message=NULL;
+		message=OSQPend(JsonQ,1000,&err);
+		if(message==NULL)//没有消息
+		{
+			OSTimeDly(1000);
+		}
+		else							//包含消息
+		{
+			myfree(SRAMIN ,message->p);//释放内部数据
+			myfree(SRAMIN,message);
+			OSTimeDly(1000);
 		}
-		else
-		{			
-			if(message != NULL)
-			{
-				WRITE_MODBUS_DATA(message->p);
-			}
-			printf("sx1278_task_recv : %s",message->p);
-			myfree(SRAMIN ,message->p);
 			
-			commd = 1;	 
-		}	
-				OSTimeDly(1000); 
+//		uint8_t err;
+//		StringInfo *message=NULL; //���ն�����Ϣ�ṹ��
+//		message=OSQPend(JsonQ,1000,&err);
+//		if(message==NULL)
+//		{			
+//			READ_DATA(current_device, buf);		
+//			if(current_device->nextDevice!=NULL) 
+//			{
+//				current_device=current_device->nextDevice;		
+//			}
+//			else
+//			{		 
+//				sprintf(buf + strlen(buf) - 1, "}");
+//					time1 = OSTimeGet();
+//					if( jsoncunt || time2  <= time1 - 20000)
+//					{
+//						memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
+//						memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//������һ�ε�����
+//						sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);									
+//						int msg = MBOX_USER_PUBLISHQOS2;	
+//						if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
+//						current_device=get->device_params;
+//						jsoncunt = 0;
+//						time2 = OSTimeGet();
+//					}//20s����һ��
+//					
+//					else
+//					{
+//						if(strcmp(buf,pubJsonStringCopy))
+//						{
+//							memset(string, 0 , strlen(string));
+//							findDifference(buf, pubJsonStringCopy, string);	
+//							memset(pubJsonString,0, strlen(pubJsonString));
+//							sprintf(pubJsonString,"{\"deviceId\":\"%s\",\"data\":[{%s}]}",get->deviceId, string);
+//							memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
+//							sprintf(pubJsonStringCopy, buf, strlen(buf));
+//						
+//							int msg = MBOX_USER_PUBLISHQOS2;	
+//							if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);	
+//						}
+//				}	
+//				memset(buf,0,strlen(buf));	
+//				current_device=get->device_params;
+//			}			
+//		}
+//		else
+//		{			
+//			WRITE_MODBUS_DATA(message->p);
+//			printf("sx1278_task_recv : %s",message->p);
+//			myfree(SRAMIN ,message->p);
+//			myfree(SRAMIN,message);
+//			
+//			commd = 1;	 
+//		}	
+//				OSTimeDly(1000); 
 	}
 }