zhao006 6 ay önce
ebeveyn
işleme
a7a6d02670

+ 2 - 0
app/HW/source/netconf.c

@@ -302,6 +302,8 @@ void ETH_link_callback(struct netif *netif)
 */			
 		enet_enable();
 		netif_set_up(&g_mynetif);
+		__set_PRIMASK(1);
+		NVIC_SystemReset();
 	}
 	else 
 	{

BIN
app/MDK/Objects/dtu_simple.axf


+ 24 - 7
app/MDK/dtu_simple.uvoptx

@@ -153,12 +153,29 @@
           <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F30x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F307RC$Flash\GD32F30x_CL.FLM))</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
-      <Breakpoint/>
+      <Breakpoint>
+        <Bp>
+          <Number>0</Number>
+          <Type>0</Type>
+          <LineNumber>904</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134272674</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\mqttclient\mqttclient\mqttclient.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\dtu_simple\../mqttclient/mqttclient/mqttclient.c\904</Expression>
+        </Bp>
+      </Breakpoint>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
           <SubType>8</SubType>
-          <ItemText>dataBuf</ItemText>
+          <ItemText>header.bits.type</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>
@@ -186,7 +203,7 @@
         <aPa1>0</aPa1>
         <AscS4>0</AscS4>
         <aSer4>0</aSer4>
-        <StkLoc>0</StkLoc>
+        <StkLoc>1</StkLoc>
         <TrcWin>0</TrcWin>
         <newCpu>0</newCpu>
         <uProt>0</uProt>
@@ -209,7 +226,7 @@
 
   <Group>
     <GroupName>USR</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -413,7 +430,7 @@
 
   <Group>
     <GroupName>Startup</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -981,7 +998,7 @@
       <GroupNumber>8</GroupNumber>
       <FileNumber>60</FileNumber>
       <FileType>1</FileType>
-      <tvExp>1</tvExp>
+      <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
       <PathWithFileName>..\lwip-1.4.1\src\core\lwip_timers.c</PathWithFileName>
@@ -1753,7 +1770,7 @@
 
   <Group>
     <GroupName>modbus</GroupName>
-    <tvExp>0</tvExp>
+    <tvExp>1</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>

+ 0 - 1
app/MDK/dtu_simple.uvprojx

@@ -10,7 +10,6 @@
       <TargetName>dtu_simple</TargetName>
       <ToolsetNumber>0x4</ToolsetNumber>
       <ToolsetName>ARM-ADS</ToolsetName>
-      <pArmCC>5060960::V5.06 update 7 (build 960)::.\ARMCC</pArmCC>
       <pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
       <uAC6>0</uAC6>
       <TargetOption>

+ 7 - 10
app/System/include/data_task.h

@@ -25,21 +25,18 @@ void write_modbus_data(char* cJSONstring);
 /* 发送至mqtt */
 void send_mqtt(char*buf);
 /* 读取设备数据 */
-int read_device_data(DEVICE_PARAMS *current_device,char* buf, char* string);
+int read_device_data(DEVICE_PARAMS *current_device,char* string);
 ///* 读取设备数据 */
 //int read_device_data1(DEVICE_PARAMS *current_device,char* buf);
 //int read_device_data2(DEVICE_PARAMS *current_device,char* buf);
 
 typedef struct __JSON_CMD{
-	char deviceId[25];
-	short power;
-	short temp;
-	short mode;
-	short fan;
-	uint16_t slaveAddress;
-	uint16_t registerAddress;
-	uint8_t function;
-	uint8_t cmd;
+	uint8_t deviceId[25];
+	uint8_t identifier[20];
+	uint8_t messageId[20];
+	uint8_t parameter;
+	uint8_t action[1];
+	
 }JSON_CMD;
 
 

+ 142 - 195
app/System/source/data_task.c

@@ -11,55 +11,51 @@
 #include "tcp_server.h"
 #include "log.h"
 
-void protocolsModeFunc(GATEWAY_PARAMS* current_device, char* buf, char* string);
+void protocolsModeFunc(GATEWAY_PARAMS* current_device, char* string);
 void transparentModeFunc(DEVICE_PARAMS* current_device);
-
-int ID = 1;
-uint8_t count = 0;
+uint8_t recv_state = 0;
+uint8_t mode = 0;
+uint8_t def = 0;
 uint8_t startFlag = 0;// 读取数据初始标志位
-int time1,time2;
+int time1,time2,size;
 void data_task(void *pdata)
 {			
 		dlt645_init(1);	// 若读不到数据,则延时 参数 秒
 		mmodbus_init(10);// 若读不到数据,则延时 参数 秒
+	
 		GATEWAY_PARAMS *get;
-		// 如果flash有config数据,则解析,进行下一步;若flash无config数据,则等待上位机发送数据
-		do{
-				char *device_config_json=pvPortMalloc( 10 *1024 );
-				memset(device_config_json,0,strlen(device_config_json));
-				portENTER_CRITICAL();
-				read_data_from_flash(device_config_json);		
-				addGatewayParams(device_config_json);
-				vPortFree(device_config_json);
-				portEXIT_CRITICAL();
-				get= get_gateway_config_params();
-				delay_ms(100);
-		}while(get->device_params == NULL);
+
+		char *device_config_json=pvPortMalloc( 10 *1024 );
+		memset(device_config_json,0,strlen(device_config_json));
+		portENTER_CRITICAL();
+		read_data_from_flash(device_config_json);	
+		addGatewayParams(device_config_json);
+		vPortFree(device_config_json);
+		portEXIT_CRITICAL();
+	
+		get= get_gateway_config_params();
 		LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"device params not empty");
 		DEVICE_PARAMS *current_device=get->device_params;
 		
-		char *buf = pvPortMalloc(1024);			// 接收读取的全部数据
-		char *string = pvPortMalloc(1024);	// 接收读取的不同数据
-		if(buf == NULL || string == NULL)
+		char *string = pvPortMalloc(3 * 1024);	// 接收读取数据
+		if(string == NULL)
 		{
 			LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"buf or string malloc fail");
 		}
-		memset(buf,0,strlen(buf));
 		memset(string,0,strlen(string));
 		while (current_device!=NULL)
-		{				
+		{					
 			if(ProtocolsModeFlag)
 			{		
-				protocolsModeFunc(get, buf, string);	
+				protocolsModeFunc(get,string);	
 			}
 			else if(TransparentModeFlag)
 			{
 				transparentModeFunc(current_device);
 			}
 			current_device=get->device_params;	
-			vTaskDelay(1000);
+			vTaskDelay(500);
 		}	
-		vPortFree(buf);
 		vPortFree(string);
 		LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"data_task return");
 }
@@ -88,7 +84,7 @@ int compareArrays(uint8_t arr1[], uint8_t arr2[], int size) {
 *	返 回 值: 1: 成功 0:失败
 *********************************************************************************************************
 */
-int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
+int read_device_data(DEVICE_PARAMS *device, char* string)
 {
 		DEVICE_PARAMS *current_device=device;	
 		GATEWAY_READ_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_read_modbus_command;
@@ -98,40 +94,8 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 				gd_eval_led_toggle(LED_485TX);
 				if (current_device->protocol == MODBUS_READ)
 				{
-						uint8_t cmd;	//开关水阀命令
-						uint8_t state;	// 水阀状态
-						uint16_t data[currentModbusParams->registerByteNum /2]; // modbus寄存器长度
-						
+						uint16_t data[currentModbusParams->registerByteNum /2]; // modbus寄存器长度				
 						mmodbus_set16bitOrder(current_device->MDBbigLittleFormat);
-						// 读水阀状态
-						if(currentModbusParams->functionCode == 0x01)
-						{
-							bool success = mmodbus_readCoil(currentModbusParams->slaveAddress,
-																		 currentModbusParams->registerByteNum /2,
-																		 &state);
-							if(success)
-							{
-								if(state == 0)
-								{
-									sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":close},", 
-																									current_device->deviceID, currentModbusParams->keyword);
-								}else{
-									sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":open},", 
-																									current_device->deviceID, currentModbusParams->keyword);
-								}
-							}
-							currentModbusParams = currentModbusParams->nextParams;
-								if (currentModbusParams == NULL)	
-								{
-										current_device = current_device->nextDevice;
-										currentModbusParams = current_device->params->gateway_read_modbus_command;
-										if(current_device == NULL)
-										{
-												sprintf(buf + strlen(buf) - 1, ""); 
-												return 1;
-										}
-								}		
-						}
 						// 读单个寄存器
 						if (currentModbusParams->functionCode == 0x03)
 						{
@@ -151,21 +115,25 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 										{
 												value = data[0];
 										}
-										if((value - currentModbusParams->value) != 0)
+										
+										if(mode == 0)// all
 										{
-												count++;
-												sprintf(string + strlen(string), "{\"deviceId\":\"%s\",\"%s\":%d},", 
+											sprintf(string + strlen(string), "{\"deviceId\":\"%s\",\"%s\":%d},", 
 																									current_device->deviceID, currentModbusParams->keyword, value);
 										}
-										else
-										{									
-												sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":%d},", 
-																									current_device->deviceID, currentModbusParams->keyword, value);
+										else if(mode == 1)// def
+										{
+											if((value - currentModbusParams->value) != 0)
+											{																
+													sprintf(string + strlen(string), "{\"deviceId\":\"%s\",\"%s\":%d},", 
+																										current_device->deviceID, currentModbusParams->keyword, value);
+													def = 1;
+											}
 										}
+										
 										if (currentModbusParams->decimalPoint == 0)
 										{
 												currentModbusParams->value = value;
-
 										}
 										else
 										{ 	
@@ -180,64 +148,11 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 										currentModbusParams = current_device->params->gateway_read_modbus_command;
 										if(current_device == NULL)
 										{
-												sprintf(buf + strlen(buf) - 1, ""); 
 												sprintf(string + strlen(string) - 1, ""); 
 												return 1;
 										}
 								}												
 						}
-						// 开关水阀
-						if(currentModbusParams->functionCode == 0x05)
-						{
-							bool success = mmodbus_writeCoil(currentModbusParams->slaveAddress,
-																							 currentModbusParams->registerByteNum /2,
-																							 cmd);
-							if(success)
-							{
-								
-									sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\": success},", 
-																									current_device->deviceID, currentModbusParams->keyword);
-							}
-							else{
-									sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\": fail},", 
-																									current_device->deviceID, currentModbusParams->keyword);
-							}
-							currentModbusParams = currentModbusParams->nextParams;
-							if (currentModbusParams == NULL)	
-							{
-									current_device = current_device->nextDevice;
-									currentModbusParams = current_device->params->gateway_read_modbus_command;
-									if(current_device == NULL)
-									{
-											sprintf(buf + strlen(buf) - 1, ""); 
-											return 1;
-									}
-							}
-						}
-						// 写单个寄存器
-						if(currentModbusParams->functionCode == 0x06)
-						{
-							bool success = mmodbus_writeHoldingRegisters16i(currentModbusParams->slaveAddress,
-																		 currentModbusParams->registerAddress,
-																		 currentModbusParams->registerByteNum /2,
-																		 data);
-							if(success)
-							{
-								sprintf(buf + strlen(buf), "{\"deviceId\":\"%s\",\"%s\":write success},", 
-																									current_device->deviceID, currentModbusParams->keyword);
-							}
-							currentModbusParams = currentModbusParams->nextParams;
-							if (currentModbusParams == NULL)	
-							{
-									current_device = current_device->nextDevice;
-									currentModbusParams = current_device->params->gateway_read_modbus_command;
-									if(current_device == NULL)
-									{
-											sprintf(buf + strlen(buf) - 1, ""); 
-											return 1;
-									}
-							}							
-						}
 				}
 				else if (current_device->protocol == DLT645_2007 || current_device->protocol == DLT645_97)
 				{
@@ -260,7 +175,7 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 						}
 						if (rs != -1)
 						{
-							if(compareArrays(read_buf,currentDLT645Params->data,10))// 不相同1,相同0
+							if(mode == 0)// all
 								{
 										if (rs <= 4)
 										{
@@ -285,10 +200,11 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 																										currentDLT645Params->deviceID645[1],currentDLT645Params->deviceID645[2],
 																										currentDLT645Params->deviceID645[3],currentDLT645Params->deviceID645[4],
 																										currentDLT645Params->deviceID645[5],currentDLT645Params->Identification,dltValue);
-										count++;
 								}
-								else
+								else if(mode == 1)//def
 								{
+									if(compareArrays(read_buf,currentDLT645Params->data,10))// 不相同1,相同0
+									{
 										if (rs <= 4)
 										{
 												memcpy(currentDLT645Params->data, read_buf, 4);
@@ -307,12 +223,14 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 										dltValue = currentDLT645Params->data[0] << 24 | currentDLT645Params->data[1] << 16|
 																				currentDLT645Params->data[2] << 8  | currentDLT645Params->data[3];
 										
-										sprintf(buf + strlen(buf), "{\"identifier\":\"%s\",\"deviceID645\":\"%02x%02x%02x%02x%02x%02x\",\"identifier645\":%d,\"value\":%X}",
+										sprintf(string + strlen(string), "{\"identifier\":\"%s\",\"deviceID645\":\"%02x%02x%02x%02x%02x%02x\",\"identifier645\":%d,\"value\":%X}",
 																								currentDLT645Params->keyword, currentDLT645Params->deviceID645[0],
 																								currentDLT645Params->deviceID645[1],currentDLT645Params->deviceID645[2],
 																								currentDLT645Params->deviceID645[3],currentDLT645Params->deviceID645[4],
 																								currentDLT645Params->deviceID645[5],currentDLT645Params->Identification,dltValue);
-								}
+										def = 1;
+									}
+							}
 						}
 		
 								currentDLT645Params = currentDLT645Params->nextParams;		
@@ -322,7 +240,7 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 										currentDLT645Params = current_device->params->gateway_read_dlt645_command;
 										if(current_device == NULL)
 										{
-												sprintf(buf + strlen(buf) - 1, ""); 
+												sprintf(string + strlen(string) - 1, ""); 
 												return 1;
 										}
 								}										
@@ -340,15 +258,21 @@ int read_device_data(DEVICE_PARAMS *device, char* buf, char* string)
 *	返 回 值: 无
 *********************************************************************************************************
 */
-void send_mqtt(char*buf){
-		LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"send to mqtt");
-		GATEWAY_PARAMS *get;
-		get= get_gateway_config_params();
-		char *pubJsonString = pvPortMalloc(700);
-	  sprintf(pubJsonString,"ID: %d {\"DEVICEID\":\"%s\",\"data\":[%s]}",ID, get->deviceId, buf);	// 组成要发送的json语句	
-		mqtt_publish_data(pubJsonString, QOS0, strlen(pubJsonString), (char*)&get->messageTopic);	
-		vPortFree(pubJsonString);
-}
+//int size;
+//void send_mqtt(char*buf){
+//		LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"send to mqtt");
+//		GATEWAY_PARAMS *get;
+//		get= get_gateway_config_params();
+//	size = xPortGetFreeHeapSize();
+//		char *pubJsonString = pvPortMalloc(5 * 1024);
+//		if(pubJsonString == NULL)
+//		{
+//			LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"mqtt_data malloc fail");
+//		}
+//	  sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]}",get->deviceId, buf);	// 组成要发送的json语句	
+//		mqtt_publish_data(pubJsonString, QOS0, strlen(pubJsonString), (char*)&get->messageTopic);	
+//		vPortFree(pubJsonString);
+//}
 
 /*
 *********************************************************************************************************
@@ -364,62 +288,83 @@ void write_modbus_data(char* JSON_STRING)
 		GATEWAY_PARAMS* get;
 		get = get_gateway_config_params();
 		DEVICE_PARAMS* current_device = get->device_params;
-	
-		parseStringField(JSON_STRING, "\"deviceId\":\"", jsonMsg.deviceId);
-    jsonMsg.function = parseIntField(JSON_STRING, "\"function\":");
-		jsonMsg.cmd = parseIntField(JSON_STRING, "\"cmd\":");
-		jsonMsg.power = parseIntField(JSON_STRING, "\"power\":");
-		jsonMsg.temp = parseIntField(JSON_STRING, "\"temp\":");
-		jsonMsg.mode = parseIntField(JSON_STRING, "\"mode\":");
-		jsonMsg.fan = parseIntField(JSON_STRING, "\"fan\":");
-		
-		while(current_device)
+
+		jsonMsg.parameter =parseIntField(JSON_STRING, "\"parameter\":");
+		parseStringField(JSON_STRING, "\"deviceId\":\"", (char*)&jsonMsg.deviceId);
+		parseStringField(JSON_STRING, "\"identifier\":\"", (char*)&jsonMsg.identifier);
+		parseStringField(JSON_STRING, "\"messageId\":\"", (char*)&jsonMsg.messageId);
+		parseStringField(JSON_STRING, "\"action\":\"", (char*)&jsonMsg.action);
+
+	LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"write to mqtt");
+	while(current_device)
 		{
-				char* device_ID = (char*)current_device->deviceID;
-				GATEWAY_WRITE_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_write_modbus_command;
-				if(!strcmp(device_ID,jsonMsg.deviceId)) //匹配ID
-				{
-					portENTER_CRITICAL();
-					delay_ms(50);
-					if(jsonMsg.function == 5)
-					// 开关阀门
-					{			
-						mmodbus_writeCoil(jsonMsg.slaveAddress,jsonMsg.registerAddress,jsonMsg.cmd);
-					}
-					if(jsonMsg.function == 6)
+			char* device_ID = (char*)current_device->deviceID;
+			GATEWAY_WRITE_MODBUS_COMMAND *currentModbusWriteParams = current_device->params->gateway_write_modbus_command;
+			GATEWAY_READ_MODBUS_COMMAND *currentModbusReadParams = current_device->params->gateway_read_modbus_command;
+			char* pubJsonString = pvPortMalloc(150);
+			switch(atoi((char*)&jsonMsg.action))
+			{
+				case 0:/* write */
+					if(!strcmp(device_ID,(char*)&jsonMsg.deviceId))
 					{
-					/* 写入寄存器操作 */
-						if(jsonMsg.power)
-						{
-								mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress, 
-																								currentModbusParams->registerAddress, jsonMsg.power);
-						}
-						delay_ms(10);
-						if(jsonMsg.temp)
-						{
-								currentModbusParams = currentModbusParams->nextParams;							
-								mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress, 
-																								currentModbusParams->registerAddress, jsonMsg.temp);	
-						}
-						delay_ms(10);
-						if(jsonMsg.mode)
+						while(currentModbusWriteParams != NULL)
 						{
-								currentModbusParams = currentModbusParams->nextParams;
-								mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress, 
-																								currentModbusParams->registerAddress, jsonMsg.mode);
+							if(!strcmp((char*)&currentModbusWriteParams->keyword,(char*)&jsonMsg.identifier)) //匹配ID和属性
+							{
+								recv_state = 0;
+								delay_ms(100);
+								mmodbus_writeHoldingRegister16i(currentModbusWriteParams->slaveAddress, currentModbusWriteParams->registerAddress, jsonMsg.parameter);
+//								sprintf(pubJsonString,"{\"action\":\"%s\",\"identifier\":\"%s\",\"deviceId\":\"%s\",\"messageId\":\"%s\",\"state\":%d}",
+//													jsonMsg.action,jsonMsg.identifier,jsonMsg.deviceId,jsonMsg.messageId,recv_state);	// 组成要发送的json语句
+//								mqtt_publish_data(pubJsonString, QOS0, strlen(pubJsonString), (char*)&get->messageTopic);	
+								delay_ms(100);
+							}
+							currentModbusWriteParams = currentModbusWriteParams->nextParams;
 						}
-						delay_ms(10);
-					  if(jsonMsg.fan)
+					}
+					break;
+				case 1:/* read  */
+					if(!strcmp(device_ID,(char*)&jsonMsg.deviceId)) 
+					{
+						while(currentModbusReadParams != NULL)
 						{
-								currentModbusParams = currentModbusParams->nextParams;
-								mmodbus_writeHoldingRegister16i(currentModbusParams->slaveAddress, 
-																								currentModbusParams->registerAddress, jsonMsg.fan);	
+							if(!strcmp((char*)&currentModbusReadParams->keyword,(char*)&jsonMsg.identifier)) //匹配ID和属性
+							{
+								delay_ms(100);
+								recv_state = 0;
+								uint16_t data[currentModbusReadParams->registerByteNum /2]; // modbus寄存器长度
+								bool success = mmodbus_readHoldingRegisters16i(currentModbusReadParams->slaveAddress,currentModbusReadParams->registerAddress,
+																																	currentModbusReadParams->registerByteNum /2,data);
+
+									if (success)
+									{
+											recv_state = 1;
+											uint32_t value;
+											if (currentModbusReadParams->registerByteNum == 4)
+											{
+													value = (uint32_t)data[0] | data[1];
+											}
+											else if (currentModbusReadParams->registerByteNum == 2)
+											{
+													value = data[0];
+											}
+											sprintf(pubJsonString,"{\"action\":\"%s\",\"identifier\":\"%s\",\"deviceId\":\"%s\",\"messageId\":\"%s\",\"state\":%d,\"parameter\":%d}",
+														jsonMsg.action,jsonMsg.identifier,jsonMsg.deviceId,jsonMsg.messageId,recv_state,value);	// 组成要发送的json语句
+											mqtt_publish_data(pubJsonString, QOS0, strlen(pubJsonString), (char*)&get->messageTopic);	
+											delay_ms(100);
+									}
+								}
+							currentModbusReadParams = currentModbusReadParams->nextParams;
 						}
-					}	
-					delay_ms(10);
-					portEXIT_CRITICAL();
-				}
+					}
+					break;
+				case 3:/* reboot */
+					__set_PRIMASK(1);
+					NVIC_SystemReset();
+					break;
+			}
 				current_device = current_device->nextDevice;
+				vPortFree(pubJsonString);
 		}
 }
 // 重定义pow函数
@@ -431,32 +376,35 @@ uint32_t my_pow(int base, int exponent) {
     return result;
 }
 
-void protocolsModeFunc(GATEWAY_PARAMS* get, char* buf, char* string)
+void protocolsModeFunc(GATEWAY_PARAMS* get, char* string)
 {
 		if(mqtt_connectFlag)
 		{
 				time1 = GetCurrentTime();
-
+				sprintf(string,"{\"deviceId\":\"%s\",\"data\":[",get->deviceId);	// 组成要发送的json语句	
 				if(startFlag && time2  <= time1 - ( 10 * 1000))// 60s进行一次全数据发送
 				{
+						mode = 0;//all
 						LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"protocolsMode:All data");
-						read_device_data(get->device_params, buf, string);
-						send_mqtt(buf);				
+						read_device_data(get->device_params,string);
+						sprintf(string + strlen(string),"]}");
+						mqtt_publish_data(string, QOS0, strlen(string), (char*)&get->messageTopic);					
 						time2 = GetCurrentTime();
 				}
 				else
 				{
-						read_device_data(get->device_params, buf, string);
-						if(count > 0)// count检测string是否含有数据
+						mode = 1;// def
+						read_device_data(get->device_params, string);
+						if(def)// 检测string是否含有数据
 						{
+							def = 0;
 							LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"protocolsMode:Different data");
-							count = 0;
-							send_mqtt(string);	
+							sprintf(string + strlen(string),"]}");
+							mqtt_publish_data(string, QOS0, strlen(string), (char*)&get->messageTopic);			
 							time2 = GetCurrentTime();		
 						}					
 				}
-				startFlag = 1;	
-				memset(buf,0,strlen(buf));				
+				startFlag = 1;				
 				memset(string,0,strlen(string));	
 				
 		}				
@@ -496,7 +444,6 @@ int transparent_data(DEVICE_PARAMS *device)
 												mmodbus.rxBuf[i + 3 + 1] = H;
 											}
 											gd_com_485_send(mmodbus.rxBuf,mmodbus.rxIndex);
-											count++;
 											vTaskDelay(100);
 										}									
 								}					

+ 2 - 2
app/System/source/gateway_message.c

@@ -23,9 +23,9 @@ void addCommandListParams(char *paramString, DEVICE_PARAMS *device);
  * @param  char *gatewayString ÊäÈë×Ö·û´®µÄÊý¾Ý
  * @retval ÎÞ
  */
-	void addGatewayParams(char *gatewayString)
+void addGatewayParams(char *gatewayString)
 {
-		//gateway_config_params.device_params = NULL;
+		gateway_config_params.device_params = NULL;
 		gateway_config_params.port = parseIntField(gatewayString, "\"port\":");
 		gateway_config_params.stopBit = parseIntField(gatewayString, "\"stopBit\":");
 		gateway_config_params.dataBits = parseIntField(gatewayString, "\"dataBit\":");

+ 31 - 15
app/System/source/sys_mqtt.c

@@ -24,7 +24,6 @@ static void topic1_handler(void *client, message_data_t *msg)
 {
 	(void)client;
 	MQTT_LOG_I("topic: %s\nmessage:%s", msg->topic_name, (char *)msg->message->payload);
-	LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"Write Modbus Data");
 	// json 解析数据
 	write_modbus_data((char*)msg->message->payload);
 }
@@ -48,7 +47,7 @@ void mqtt_task_creat()
 {
 	mqtt_client_t *client = NULL; // 创建一个客户端
 	mqtt_log_init();
-	client = mqtt_lease();
+	client = mqtt_lease();	// 申请一个mqtt客户端
 	printf("\nwelcome to mqttclient test...\n");
 	xQueue1 = xQueueCreate(10, sizeof(struct Pub_Queue *)); // 创建一个mqtt上传的队列
 	xTaskCreate(mqtt_publish_task, "mqtt_publish_task", 512, client, 4, NULL);
@@ -56,22 +55,22 @@ void mqtt_task_creat()
 
 static void mqtt_publish_task(void *arg)
 {
+	int rc;
+	char port[6]; 
+	GATEWAY_PARAMS *get;
+	get= get_gateway_config_params();	
 		// 确保dhcp配置完成
-	while(dhcp_done != 1)
+	while(dhcp_done != 1 || get->device_params == NULL)
 	{
 		vTaskDelay(100);
 	}
-
-	GATEWAY_PARAMS *get;
-	get= get_gateway_config_params();	
-	int rc;
-	int msgId = 0;
-	char port[6];  
+	
 	mqtt_client_t *client;
 	
+
 __MQTT_START:
-	rc = -1;
 	client = (mqtt_client_t *)arg;
+	rc = -1;
 	while (rc < 0)
 	{
 		vTaskDelay(1000);
@@ -80,12 +79,14 @@ __MQTT_START:
 	}
 	LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"MQTT Connect success");
 	mqtt_connectFlag = 1;
+	// 订阅主题并设置回调函数topic1_handler
 	if(mqtt_subscribe(client, (char*)&get->commandTopic, QOS0, topic1_handler) != 0)
 	{
 		LogPrint(LOG_WARN,__FILE__,__FUNCTION__,__LINE__,"MQTT Subscribe fail");
 	}
 	mqtt_message_t msg;
 	memset(&msg, 0, sizeof(msg));
+	// 列出客户端已订阅的主题
 	mqtt_list_subscribe_topic(client);
 	struct Pub_Queue *pxMessage;
 	while (1)
@@ -101,16 +102,28 @@ __MQTT_START:
 				if(mqtt_publish(client, pxMessage->pub_topic, &msg) != 0)// 0:成功
 				{
 					LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"MQTT Publish Failed");
-					mqtt_disconnect(client);// 关闭mqtt连接
+//					mqtt_unsubscribe(client, (char*)&get->commandTopic);// 取消订阅
+//					mqtt_disconnect(client);// 关闭mqtt连接
+					vPortFree(pxMessage->pub_topic);
+					vPortFree(pxMessage->message);
+					vPortFree(pxMessage);
 					goto __MQTT_START;
 				}
-				LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"MQTT Publish Message No:%d",ID++);
+				
+//				char* writeBuf = pvPortMalloc(1024);
+//				printf("--------------- heap: ---------------------\r\n");
+//				vTaskList(writeBuf);
+//				printf("%s", writeBuf);
+//				printf("----------------------------------------------\r\n");
+//				vPortFree(writeBuf);
+				
+				LogPrint(LOG_INFO,__FILE__,__FUNCTION__,__LINE__,"MQTT Publish Message");
 				vPortFree(pxMessage->pub_topic);
 				vPortFree(pxMessage->message);
 				vPortFree(pxMessage);
 			}
 		}
-		vTaskDelay(1000);
+		vTaskDelay(500);
 	}
 }
 /*
@@ -121,15 +134,18 @@ __MQTT_START:
  *  函数作用:向队列中写入mqtt上传的消息
  *  TODO:队列满无法写入的情况处理
  */
-
+int size_mqtt;
 void mqtt_publish_data(char *payload, mqtt_qos_t qos, uint16_t pub_length, char *topic)
 {
+	size_mqtt = xPortGetFreeHeapSize();
 	struct Pub_Queue *pxMessage = pvPortMalloc(sizeof(struct Pub_Queue));
+	size_mqtt = xPortGetFreeHeapSize();
 	pxMessage->message = pvPortMalloc(pub_length + 1);
+	size_mqtt = xPortGetFreeHeapSize();
 	memset(pxMessage->message, 0, (pub_length + 1));
 	memcpy(pxMessage->message, payload, pub_length);
-
 	pxMessage->pub_topic = pvPortMalloc(strlen(topic) + 1);
+	size_mqtt = xPortGetFreeHeapSize();
 	memset(pxMessage->pub_topic, 0, (strlen(topic) + 1));
 	strcpy(pxMessage->pub_topic, topic);
 	

+ 63 - 28
app/System/source/tcp_server.c

@@ -36,8 +36,8 @@ void get_device_params(char* device_params)
 	GATEWAY_PARAMS *get;
 	get= get_gateway_config_params();
 	DEVICE_PARAMS *current_device=get->device_params;
-	sprintf(device_params, "{\"read_config\":\"success\",\"baudrate\":%d,\"checkBit\":%d,\"commandTopic\":%s,\"dataBit\":%d,\
-\"deviceId\": \"%s\",\"host\":\"%s\",\"inboundTime\":%d,\"messageTopic\":\"%s\",\"port\":%d,\"stopBit\":%d,\"deviceList\":[",get->baudrate,
+	sprintf(device_params, "{\"read_config\":\"success\",\"baudrate\":%d,\"checkBit\":%d,\"commandTopic\":\"%s\",\"dataBit\":%d,\
+\"deviceId\":\"%s\",\"host\":\"%s\",\"inboundTime\":%d,\"messageTopic\":\"%s\",\"port\":%d,\"stopBit\":%d,\"deviceList\":[",get->baudrate,
 			get->checkBit,get->commandTopic,get->dataBits,get->deviceId,get->host,get->inboundTime,get->messageTopic,get->port,get->stopBit);
 	while(current_device != NULL)
 	{	
@@ -58,7 +58,7 @@ void get_device_params(char* device_params)
 			// modbus read
 			while(read_modbus_command != NULL)
 			{
-				sprintf(device_params + strlen(device_params),"{\"rFunctionCode\":%d,\"registerAddress\":%d,\"slaveAddress\":%d,\"registerByteNum\":%d\"identifier\":\"%s\",\"precise\":%d},",
+				sprintf(device_params + strlen(device_params),"{\"rFunctionCode\":%d,\"registerAddress\":%d,\"slaveAddress\":%d,\"registerByteNum\":%d,\"identifier\":\"%s\",\"precise\":%d},",
 																											read_modbus_command->functionCode, read_modbus_command->registerAddress,read_modbus_command->slaveAddress,
 																											read_modbus_command->registerByteNum,read_modbus_command->keyword,read_modbus_command->decimalPoint);
 				read_modbus_command = read_modbus_command->nextParams;
@@ -72,21 +72,58 @@ void get_device_params(char* device_params)
 								write_modbus_command->registerAddress,write_modbus_command->slaveAddress,write_modbus_command->functionCode,write_modbus_command->registerByteNum);
 				write_modbus_command = write_modbus_command->nextParams;
 			}		
-			sprintf(device_params + strlen(device_params)-1,"]}");// commandData:[
+			sprintf(device_params + strlen(device_params)-1,"]},");// commandData:[
 			current_device = current_device->nextDevice;	
 	}
-	sprintf(device_params + strlen(device_params),"]}");
+	sprintf(device_params + strlen(device_params) -1 ,"]}");
 }
+
+int siee;
 // 储存上位机发送的config数据,并返回上位机操作结果
-void save_config(int client_socket,char* dataBuf)
+void save_config(int client_socket,char* buf)
 {
-		save_config_params(dataBuf);// 储存到flash 不用判断失败
-		char* retMsg = pvPortMalloc(32);
-		memset(retMsg, 0, strlen(retMsg));
-		retMsg = "{\"write_config\":\"success\"}";
-		send(client_socket, retMsg, strlen(retMsg), 0);	
-		vPortFree(retMsg);
-		tcp_config	= 1;
+		GATEWAY_PARAMS *get;
+		get= get_gateway_config_params();
+		char* saveData = pvPortMalloc(7* 1024);//(RECV_BUF_SIZE);// 存储config数据			最大20K,暂定3K
+		if(saveData == NULL) 
+		{		
+				char* retMsg = pvPortMalloc(32);
+				memset(retMsg, 0, strlen(retMsg));
+				retMsg = "{\"write_config\":\"error_full\"}";
+				send(client_socket, retMsg, strlen(retMsg), 0);	
+				vPortFree(retMsg);
+				tcp_config	= 0;
+				LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"recv buf malloc fail");
+		}	
+		else
+		{
+				memset(saveData,0,strlen(saveData));	
+				sprintf(saveData,"%s",buf);
+				// 	获取上位机发送的数据
+				do{
+						memset(buf, 0, strlen(buf));
+						recv(client_socket,buf,1460,0);	
+						memcpy(saveData + strlen(saveData), buf, strlen(buf));
+					}while(buf[1] != 0 && buf[1459] != 0);
+				// 插入tcp_config标志位,后续不通过http获取默认配置数据
+				sprintf(saveData + strlen(saveData),"tcp_config");
+				portENTER_CRITICAL();
+				save_config_params(saveData);// 储存到flash 不用判断失败
+//				vPortFree(get->device_params->params->gateway_read_modbus_command);
+//				vPortFree(get->device_params->params->gateway_write_modbus_command);
+//				vPortFree(get->device_params->params->gateway_read_dlt645_command);
+//				vPortFree(get->device_params->params);
+//				vPortFree(get->device_params);
+				addGatewayParams(saveData);
+				vPortFree(saveData);
+				portEXIT_CRITICAL();
+				char* retMsg = pvPortMalloc(32);
+				memset(retMsg, 0, strlen(retMsg));
+				retMsg = "{\"write_config\":\"success\"}";
+				send(client_socket, retMsg, strlen(retMsg), 0);	
+				vPortFree(retMsg);
+				tcp_config	= 1;
+		}
 }
 // 储存上位机发送的config_add数据,并返回上位机操作结果
 void add_config(int client_socket, char* dataBuf)
@@ -133,13 +170,14 @@ void find_device(int client_socket)
 	memset(deviceId, 0, 50);
 }
 
+int sie;
 // 发送设备当前的config数据
 void send_config(int client_socket)
 {
 	GATEWAY_PARAMS *get;
 	get= get_gateway_config_params();
-	char* device_params = pvPortMalloc(3 * 1024);
-	memset(device_params,0,3 * 1024);
+	char* device_params = pvPortMalloc(8 * 1024);// 目前最大分配8K
+	memset(device_params,0,8 * 1024);
 	if(get->device_params == NULL)
 	{
 		sprintf(device_params, "{\"read_config\":\"error\"}");
@@ -148,7 +186,10 @@ void send_config(int client_socket)
 	else
 	{
 		get_device_params(device_params);
-		send(client_socket, device_params, strlen(device_params), 0);
+		for(uint8_t i = 0; i < 8; i++)
+		{
+			send(client_socket, device_params + (i*1024),1024, 0);
+		}
 	}
 	vPortFree(device_params);
 }
@@ -217,8 +258,7 @@ void tcp_server_task(void *pvParameters)
 		char* recv_cmd[] = {"\"cmd\":\"write_config\"","\"cmd\":\"write_config_add\"",
 												"\"cmd\":\"read_config\"","\"cmd\":\"find_device\"",
 												"\"cmd\":\"ip_config\"","\"cmd\":\"toggle_work_mode\"",
-												"\"cmd\":\"software_update\"","\"cmd\":\"reboot\"",
-												"\"cmd\":\"error_cmd\""};// cmd:error_cmd 仅为了判断错误的命令
+												"\"cmd\":\"software_update\"","\"cmd\":\"reboot\""};// cmd:error_cmd 仅为了判断错误的命令
 		while(dhcp_done!=1)
 		{
 			vTaskDelay(100);
@@ -259,14 +299,12 @@ tcp_server_begin:
     {		
 				vTaskDelay(100);
 
-				char* dataBuf = pvPortMalloc(RECV_BUF_SIZE);// 存储config数据			最大20K,暂定3K
+				char* dataBuf = pvPortMalloc(RECV_BUF_SIZE);// 存储上位机数据
 				if(dataBuf == NULL) 
-					LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"recv buf malloc fail");	
+					LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__,"recv buf malloc fail");
 				memset(dataBuf,0,strlen(dataBuf));
 				// 	获取上位机发送的数据
 				recv_size=recv(client_socket,dataBuf,RECV_BUF_SIZE,0);
-				// 插入tcp_config标志位,后续不通过http获取默认配置数据
-				sprintf(dataBuf + strlen(dataBuf),"tcp_config");
 
 					// 接收到消息
 					// 解析上位机发送的CMD命令	
@@ -288,6 +326,8 @@ tcp_server_begin:
 											save_config(client_socket, dataBuf);
 											vPortFree(dataBuf);
 											LogPrint(LOG_INFO, __FILE__, __FUNCTION__, __LINE__, "write config");
+											__set_PRIMASK(1);
+											NVIC_SystemReset();
 											break;
 									case WRITE_CONFIG_ADD:
 											add_config(client_socket, dataBuf);
@@ -332,9 +372,6 @@ tcp_server_begin:
 											__set_PRIMASK(1);
 											NVIC_SystemReset();
 											break;
-									default:
-											send(client_socket,"{\"cmd:error\"}", 15, 0);
-											LogPrint(LOG_INFO, __FILE__, __FUNCTION__, __LINE__, "Command error");
 								}
 							} else {
 								switch (j) {
@@ -371,9 +408,6 @@ tcp_server_begin:
 											__set_PRIMASK(1);
 											NVIC_SystemReset();	
 											break;
-									default:
-											send(client_socket,"{\"cmd:error\"}", 15, 0);
-											LogPrint(LOG_INFO, __FILE__, __FUNCTION__, __LINE__, "Command error");
 							}
 						}
 					}
@@ -382,6 +416,7 @@ tcp_server_begin:
 					{
 						lwip_close(client_socket);
 						LOG_PRINT(LOG_ERROR,"PC disconnect,wait reconnect");
+						vPortFree(dataBuf);
 						client_socket= accept(sockfd, (struct sockaddr*)&client_sock,&len);
 					}
 					vPortFree(dataBuf);

+ 1 - 1
app/System/source/udp.c

@@ -161,7 +161,7 @@ static void udp_task(void *arg)
 volatile int8_t sockfd=-1;
 #define UDP_LOCAL_PORT 12345
 #define UDP_REMOTE_PORT 54321
-#define SERCER_IP_ADDRESS "192.168.0.102"       //½ÓÊÕ·þÎñÆ÷ip
+#define SERCER_IP_ADDRESS "192.168.0.101"       //½ÓÊÕ·þÎñÆ÷ip
 struct sockaddr_in remote_addr;
 int udp_log_start()
 {

+ 1 - 0
app/System/source/updata.c

@@ -118,6 +118,7 @@ __start:
 			// 对数据包进行操作
 			/*                */
 			memset(databuf, 0, sizeof(databuf));
+			
 			// 准备接收下一包数据
 			send(client_socket, &ack, 1, 0);
 			packId += 1;

+ 3 - 3
app/USR/include/FreeRTOSConfig.h

@@ -82,7 +82,7 @@ extern uint32_t SystemCoreClock;
 #define configTICK_RATE_HZ                            ( ( TickType_t ) 1000 )
 #define configMAX_PRIORITIES                          ( 6 )
 #define configMINIMAL_STACK_SIZE                      ( ( unsigned short ) 128 )
-#define configTOTAL_HEAP_SIZE                         ( ( size_t ) ( 40 * 1024 ) )
+#define configTOTAL_HEAP_SIZE                         ( ( size_t ) ( 47 * 1024 ) )
 #define configMAX_TASK_NAME_LEN                       ( 16 )
 #define configUSE_16_BIT_TICKS                        0
 #define configIDLE_SHOULD_YIELD                       1
@@ -96,8 +96,8 @@ extern uint32_t SystemCoreClock;
 /* hook function related definitions */
 #define configUSE_IDLE_HOOK                           0
 #define configUSE_TICK_HOOK                           0
-#define configCHECK_FOR_STACK_OVERFLOW                1
-#define configUSE_MALLOC_FAILED_HOOK                  1
+#define configCHECK_FOR_STACK_OVERFLOW                0
+#define configUSE_MALLOC_FAILED_HOOK                  0
 
 /* run time and task stats gathering related definitions */
 #define configGENERATE_RUN_TIME_STATS                 0

+ 3 - 3
app/USR/include/lwipopts.h

@@ -30,7 +30,7 @@
                                                             is compiled. 4 byte alignment -> define MEM_ALIGNMENT 
                                                             to 4, 2 byte alignment -> define MEM_ALIGNMENT to 2 */
 
-#define MEM_SIZE                (5*1024)                /* the size of the heap memory, if the application will 
+#define MEM_SIZE                (2*1024)                /* the size of the heap memory, if the application will 
                                                             send a lot of data that needs to be copied, this should
                                                             be set high */
 
@@ -38,10 +38,10 @@
                                                             sends a lot of data out of ROM (or other static memory),
                                                             this should be set high */
 
-#define MEMP_NUM_UDP_PCB        6                        /* the number of UDP protocol control blocks, one
+#define MEMP_NUM_UDP_PCB        3                        /* the number of UDP protocol control blocks, one
                                                             per active UDP "connection" */
 
-#define MEMP_NUM_TCP_PCB        10                       /* the number of simulatenously active TCP connections */
+#define MEMP_NUM_TCP_PCB        5                        /* the number of simulatenously active TCP connections */
 
 #define MEMP_NUM_TCP_PCB_LISTEN 5                        /* the number of listening TCP connections */
 

+ 4 - 3
app/USR/source/main.c

@@ -92,7 +92,6 @@ int main(void)
 		/* remap PB3  PB4 */
 		rcu_periph_clock_enable(RCU_AF);// 使能映射功能的时钟	
 		gpio_pin_remap_config(GPIO_SWJ_SWDPENABLE_REMAP, ENABLE);// 重映射PB3、PB4
-		gpio_bit_set(GPIOC,GPIO_PIN_9);
 	
 		/* LED init */
 		gd_eval_led_init(LED_DEV);			// 状态灯
@@ -116,7 +115,7 @@ int main(void)
 		
 		/* LED_DEV open */
 		gd_eval_led_on(LED_DEV);
-
+		
 		/* init task */
     xTaskCreate(init_task, "INIT",256, NULL, INIT_TASK_PRIO, NULL);
 		
@@ -154,7 +153,9 @@ void init_task(void * pvParameters)
 		
     /* start toogle LED task every 250ms */
 //    xTaskCreate(led_task, "LED", 512, NULL, LED_TASK_PRIO, NULL);
-
+		char* buf = pvPortMalloc(10);
+		while(read_data_from_flash(buf)){};
+		vPortFree(buf);
 		http_getDemo();
 
 		xTaskCreate(data_task, "DATA",512, NULL, DATA_TASK_PRIO, NULL);

+ 2 - 0
app/dlt/port/dlt645_port.c

@@ -14,6 +14,7 @@
 #include "delay.h"
 #include "usart.h"
 #include "string.h"
+#include "led.h"
 
 
 dlt645_port_t dlt645_port;
@@ -40,6 +41,7 @@ void dlt_callback()
 	{                           
 		usart_interrupt_disable(DLT645_USART, USART_INT_IDLE);
 		dlt645_port.done = 1;
+		gd_eval_led_toggle(LED_485RX);
 	}
 }
 /**

BIN
app/lwip-1.4.1/lwip.IAB


BIN
app/lwip-1.4.1/lwip.IAD


BIN
app/lwip-1.4.1/lwip.IMB


BIN
app/lwip-1.4.1/lwip.IMD


BIN
app/lwip-1.4.1/lwip.PFI


BIN
app/lwip-1.4.1/lwip.PO


BIN
app/lwip-1.4.1/lwip.PR


BIN
app/lwip-1.4.1/lwip.PRI


BIN
app/lwip-1.4.1/lwip.PS


+ 5 - 0
app/lwip-1.4.1/lwip.SearchResults

@@ -0,0 +1,5 @@
+----  lwip_comm_init() Matches (0 in 0 files) ----
+----  lwip_comm_init() Search Errors Encountered (2) ----
+The following 2 files could not be processed:
+C:\Users\IBM\Desktop\dtu_simple1\app\lwip-1.4.1\lwip.IAB : File could not be opened.
+C:\Users\IBM\Desktop\dtu_simple1\app\lwip-1.4.1\lwip.IMB : File could not be opened.

BIN
app/lwip-1.4.1/lwip.WK3


+ 1 - 2
app/modbus/mmodbus.h

@@ -84,8 +84,7 @@ typedef enum
 typedef enum
 {
   MModBus_16bitOrder_AB=1,
-  MModBus_16bitOrder_BA=2,
-  
+  MModBus_16bitOrder_BA=2, 
 }MModBus_16bitOrder_t;
 
 typedef enum

+ 2 - 0
app/mqttclient/mqttclient/mqttclient.c

@@ -6,6 +6,7 @@
  * @Description: the code belongs to jiejie, please keep the author information and source code according to the license.
  */
 #include "mqttclient.h"
+#include "log.h"
 
 #define     MQTT_MIN_PAYLOAD_SIZE   2               
 #define     MQTT_MAX_PAYLOAD_SIZE   268435455       // MQTT imposes a maximum payload size of 268435455 bytes.
@@ -946,6 +947,7 @@ static void mqtt_yield_thread(void *arg)
             MQTT_LOG_W("%s:%d %s()..., mqtt clean session....", __FILE__, __LINE__, __FUNCTION__);
             network_disconnect(c->mqtt_network);
             mqtt_clean_session(c);
+						LogPrint(LOG_ERROR,__FILE__,__FUNCTION__,__LINE__," mqtt clean session.");
             goto exit;
         } else if (MQTT_RECONNECT_TIMEOUT_ERROR == rc) {
             MQTT_LOG_W("%s:%d %s()..., mqtt reconnect timeout....", __FILE__, __LINE__, __FUNCTION__);