zhao006 10 月之前
父节点
当前提交
7b45d95e71
共有 5 个文件被更改,包括 17950 次插入15 次删除
  1. 3 14
      app/MDKProject/lora_gateway.uvprojx
  2. 17832 0
      app/OBJ/lora_gateway.hex
  3. 4 0
      app/System/includes/json_queue.h
  4. 21 1
      app/System/source/sys_mqtt.c
  5. 90 0
      app/System/source/task.c

+ 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>

文件差异内容过多而无法显示
+ 17832 - 0
app/OBJ/lora_gateway.hex


+ 4 - 0
app/System/includes/json_queue.h

@@ -5,7 +5,11 @@
 void creat_queue(void);
 typedef struct {
     uint32_t stringLength;
+<<<<<<< HEAD
     char *p;
+=======
+     char *p;
+>>>>>>> 841e7987800910a57cf5275c331a8acbfec24198
 } StringInfo;
 
 

+ 21 - 1
app/System/source/sys_mqtt.c

@@ -71,10 +71,31 @@ 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);
+<<<<<<< HEAD
 	StringInfo message;
 	message.p=mymalloc(SRAMEX ,msglen);
 	memcpy(message.p,msgbuf,msglen);
 	OSMboxPost(mqtt_recvMseeageMbox,(void*)&message);
+=======
+	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,message);
+	commd = 0;
+	switch(err)
+	{
+		case OS_ERR_NONE: 
+			break;
+		case OS_ERR_Q_FULL: 
+			MQTT_PRINTF("receive a msg queue is full \r\n");
+			break;
+		default:
+			break;
+	}
+>>>>>>> 841e7987800910a57cf5275c331a8acbfec24198
 }	
 
 /************************************************************
@@ -157,7 +178,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;

+ 90 - 0
app/System/source/task.c

@@ -32,6 +32,7 @@ char string[512];
 */
 void data_task(void *pdata)
 {
+<<<<<<< HEAD
 		OS_CPU_SR cpu_sr;
 		pdata = pdata;
 		dlt645_init(100);
@@ -79,6 +80,95 @@ void mqtt_to_device(){
 				myfree(SRAMEX ,message->p);//�ͷ��ڲ�����
 				//OSTimeDly(1000);
 		}	
+=======
+	OS_CPU_SR cpu_sr;
+	pdata = pdata;
+	mmodbus_init(1);
+	char buf[1000];	// ����modbus��ȡ������	
+	
+	char *device_config_json = mymalloc(SRAMEX, 9 * 1024);
+	read_file("device.txt", device_config_json);
+	addGatewayParams(device_config_json);
+	myfree(SRAMEX, device_config_json);
+	
+	GATEWAY_PARAMS *get;
+	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=OSQPend(JsonQ,1000,&err);
+		if(message==NULL)//没有消息
+		{
+			OSTimeDly(1000);
+		}
+		else							//包含消息
+		{
+			myfree(SRAMIN ,message->p);//释放内部数据
+			myfree(SRAMIN,message);
+			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); 
+	}
+>>>>>>> 841e7987800910a57cf5275c331a8acbfec24198
 }
 
 /*