浏览代码

gateway_message ¸ÄΪÁ´±í

haitao 1 年之前
父节点
当前提交
6817df468b
共有 49 个文件被更改,包括 4822 次插入7682 次删除
  1. 27 26
      app/App/PC.c
  2. 204 71
      app/App/device_message.c
  3. 87 84
      app/App/device_message.h
  4. 101 366
      app/App/ec800m.c
  5. 2 2
      app/App/ec800m.h
  6. 1 1
      app/App/gd32f10x_it.c
  7. 29 56
      app/App/main.c
  8. 1 1
      app/App/main.h
  9. 1 1
      app/App/mmodbus.h
  10. 387 502
      app/App/parseDeviceMessage.c
  11. 6 6
      app/App/parseDeviceMessage.h
  12. 451 3083
      app/Proj/JLinkLog.txt
  13. 1053 1111
      app/Proj/Listings/Ringzle.map
  14. 12 12
      app/Proj/Listings/startup_gd32f10x_xd.lst
  15. 二进制
      app/Proj/Objects/Ringzle.axf
  16. 二进制
      app/Proj/Objects/Ringzle.bin
  17. 4 318
      app/Proj/Objects/Ringzle.build_log.htm
  18. 1151 1288
      app/Proj/Objects/Ringzle.htm
  19. 94 90
      app/Proj/Objects/Ringzle_GD32F103C8T6.dep
  20. 二进制
      app/Proj/Objects/device_message.crf
  21. 1 1
      app/Proj/Objects/device_message.d
  22. 二进制
      app/Proj/Objects/dlt645_port.crf
  23. 二进制
      app/Proj/Objects/ec800m.crf
  24. 二进制
      app/Proj/Objects/gd32f10x_it.crf
  25. 3 0
      app/Proj/Objects/gd32f10x_it.d
  26. 二进制
      app/Proj/Objects/key.crf
  27. 二进制
      app/Proj/Objects/log.crf
  28. 二进制
      app/Proj/Objects/main.crf
  29. 二进制
      app/Proj/Objects/mmodbus.crf
  30. 二进制
      app/Proj/Objects/mqttrecv.crf
  31. 二进制
      app/Proj/Objects/otaevent.crf
  32. 二进制
      app/Proj/Objects/parsedevicemessage.crf
  33. 二进制
      app/Proj/Objects/pc.crf
  34. 二进制
      app/Proj/Objects/ring_buffer.crf
  35. 二进制
      app/Proj/Objects/usart.crf
  36. 111 84
      app/Proj/Ringzle.uvguix.16936
  37. 53 17
      app/Proj/Ringzle.uvoptx
  38. 11 1
      app/Proj/Ringzle.uvprojx
  39. 1 1
      app/Startup/startup_gd32f10x_xd.s
  40. 1 1
      app/bsp/key.c
  41. 1 1
      app/bsp/usart.c
  42. 1 1
      app/bsp/usart.h
  43. 0 1
      app/dlt/port/dlt645_port.c
  44. 471 0
      app/jsmn/jsmn.h
  45. 1 1
      bootloader/OBJ/bootloader.build_log.htm
  46. 517 529
      bootloader/USER/JLinkLog.txt
  47. 34 25
      bootloader/USER/bootloader.uvguix.16936
  48. 1 1
      bootloader/USER/bootloader.uvoptx
  49. 4 0
      版本信息.txt

+ 27 - 26
app/App/PC.c

@@ -122,16 +122,16 @@ void USART2_IRQHandler(void)
 			switch (RxPacket.data[1])
 			{
 				case READ_ID:
-				readGatewayMessage();
+//				readGatewayMessage();
 				break;
 			case READ_GATEWAY_MESSAGE:
-				readSIMCARD();
+//				readSIMCARD();
 				break;
 			case READ_GATEWAY_JSON_CONFIG:
-				read_json_config();
+//				read_json_config();
 				break;
 			case WIRTE_GATEWAY_JSON_CONFIG:
-				write_json_config(writeJSON);
+//				write_json_config(writeJSON);
 				break;
 			case SET_GATEWAY_PLATFORM:
 				break;
@@ -161,26 +161,26 @@ void USART2_IRQHandler(void)
  */
 void readGatewayMessage(void)
 {
-	CONFIG_PARAMS *gateway;
-	gateway = get_config_params();
+	GATEWAY_PARAMS *gateway;
+	gateway = get_gateway_config_params();
 	uint8_t *gatewayMessageData=malloc(100);
 	memset(gatewayMessageData,0,100);
 	gatewayMessageData[0]=Top;
 	gatewayMessageData[1]=READ_ID;
-	uint8_t deviceIdLen=strlen(gateway->deviceId);
-	uint8_t versionLen=strlen(gateway->version);
+	uint8_t deviceIdLen=strlen((char *)&gateway->deviceId);
+	uint8_t versionLen=strlen((char *)&gateway->version);
 	memcpy(gatewayMessageData+2,gateway->deviceId,deviceIdLen);
 	gatewayMessageData[deviceIdLen+2]=0x3B;
 	
 	memcpy(gatewayMessageData+2+1+deviceIdLen,gateway->version,versionLen);
-	uint16_t CRC16=mmodbus_crc16(gatewayMessageData+1,strlen(gatewayMessageData)-1);
+	uint16_t CRC16=mmodbus_crc16(gatewayMessageData+1,strlen((char *)&gatewayMessageData)-1);
 
 	gatewayMessageData[deviceIdLen+2+1+versionLen+1] = (uint8_t) (CRC16 & 0x00FF);
 	gatewayMessageData[deviceIdLen+2+1+versionLen] = (uint8_t) ((CRC16 & 0xFF00)>>8);
 	
 	gatewayMessageData[deviceIdLen+2+1+versionLen+2]=END;
 	gatewayMessageData[deviceIdLen+2+1+versionLen+2+1]='\0';
-	gd_com_232_send(gatewayMessageData,strlen(gatewayMessageData));
+	gd_com_232_send(gatewayMessageData,strlen((char* )&gatewayMessageData));
 	free(gatewayMessageData);
 }
 /*
@@ -192,13 +192,13 @@ void readGatewayMessage(void)
  */
 void readSIMCARD()
 {
-	CONFIG_PARAMS *gateway;
-	gateway = get_config_params();
+	GATEWAY_PARAMS *gateway;
+	gateway = get_gateway_config_params();
 	
-	uint8_t *gatewayConfigData=malloc(1024);
+	char *gatewayConfigData=malloc(1024);
 	memset(gatewayConfigData,0,1024);
 	uint8_t Operators[16];
-	bool Networkstatu;
+	int Networkstatu;
 	uint8_t SIMCard=0;                          //状态0 正常 状态1异常
 	uint8_t ICCID[20];												
 	uint8_t IMMIE[15];
@@ -208,11 +208,11 @@ void readSIMCARD()
 	EC800MSendCmd(CMD_SERVICE_Operatortyp, strlen(CMD_SERVICE_Operatortyp)); 
 	if(WaitField("+COPS: 0,0,",100))																						//+COPS:0,0,"%s"为运营商,+COPS:0为无sim卡
 	{
-		sscanf(UART0_RX_BUF, "AT+COPS?\r\r\n+COPS: 0,0,\"%[^\"]\",%s", Operators, &Networktyp);
+		sscanf((char *)&UART0_RX_BUF, "AT+COPS?\r\r\n+COPS: 0,0,\"%[^\"]\",%s", Operators, &Networktyp);
 	}
 	else
 	{
-		strcpy(Operators,"");																											//未读取到sim卡信息
+		strcpy((char *)&Operators,"");																											//未读取到sim卡信息
 		Networktyp=NULL;
 	}
 	Clear_DMA_Buffer();
@@ -220,7 +220,7 @@ void readSIMCARD()
 	EC800MSendCmd(CMD_SERVICE_Networktyp,strlen(CMD_SERVICE_Networktyp));
 	WaitField("OK",100);
 	
-	char* status_str=strstr(UART0_RX_BUF, "+CREG:");
+	char* status_str=strstr((char *)&UART0_RX_BUF, "+CREG:");
 	if(status_str != NULL)																											//不为NULL则为有信号
 	{
 		sscanf(status_str, "+CREG: %*d,%d", &Networkstatu);																							//原先0未注册 1注册,取反后1未注册0注册
@@ -228,15 +228,15 @@ void readSIMCARD()
 	//查询sim卡iccid
 	EC800MSendCmd(CMD_SERVICE_SIMcardICCID,strlen(CMD_SERVICE_SIMcardICCID));
 	WaitField("OK",100);
-	char* ICCID_str=strstr(UART0_RX_BUF,"+QCCID:");
+	char* ICCID_str=strstr((char *)&UART0_RX_BUF,"+QCCID:");
 	if(ICCID_str != NULL)
 	{
 		sscanf(ICCID_str,"+QCCID: %s",ICCID);
 		//查询信号强度
 		EC800MSendCmd(CMD_SERVICE_Signalstrength,strlen(CMD_SERVICE_Signalstrength));
 		WaitField("OK",100);
-		uint8_t rssi;
-		sscanf(UART0_RX_BUF,"AT+CSQ\r\r\n+CSQ: %d",&rssi);
+		int rssi;
+		sscanf((char *)&UART0_RX_BUF,"AT+CSQ\r\r\n+CSQ: %d",&rssi);
 		Signal_strength=(int)(((float)rssi/31)*100);            //算出来的百分比不准确log函数的斜率不断降低,此方法算出来的斜线的信号强度,实际信号为log函数,后续修正
 		Clear_DMA_Buffer();
 	}
@@ -250,7 +250,7 @@ void readSIMCARD()
 	//查询IMMIE号
 	EC800MSendCmd(CMD_SERVICE_IMEInumber,strlen(CMD_SERVICE_IMEInumber));
 	WaitField("OK",100);
-	sscanf(UART0_RX_BUF,"AT+GSN\r\r\n%s",IMMIE);
+	sscanf((char *)&UART0_RX_BUF,"AT+GSN\r\r\n%s",IMMIE);
 	Clear_DMA_Buffer();
 	
 	//查询结束,开始组装json
@@ -269,6 +269,7 @@ void readSIMCARD()
 	gd_com_232_send(gatewayConfigData,strlen(gatewayConfigData));
 	free(gatewayConfigData);
 }
+#if 0
 /*
  *  函数名:void readSIMCARD()
  *  输入参数:无
@@ -278,10 +279,10 @@ void readSIMCARD()
  */
 void	read_json_config()
 {
-	uint8_t *json_config=malloc(11*1024);//暂时最大空间只能解析10K数据
+	char *json_config=malloc(11*1024);//暂时最大空间只能解析10K数据
 	memset(json_config,0,11*1024);
-	CONFIG_PARAMS *gateway;
-	gateway = get_config_params();
+	GATEWAY_PARAMS *gateway;
+	gateway = get_gateway_config_params();
 	//帧头
 	json_config[0]=Top;
 	json_config[1]=READ_GATEWAY_JSON_CONFIG;
@@ -295,7 +296,7 @@ void	read_json_config()
 				gateway->dataBits,
 				gateway->stopBit,
 				gateway->checkBit,
-				gateway->flowControl,
+				0,
 				gateway->deviceId,
 				gateway->dataSource,
 
@@ -402,7 +403,7 @@ void ec800m_4G_Data_read(uint8_t *str,uint16_t len)
 }
 
 
-
+#endif
 
 
 

+ 204 - 71
app/App/device_message.c

@@ -1,89 +1,222 @@
 #include "device_message.h"
 #include "gd32f10x.h"
-#include "w25q32.h"
+#include "string.h"
+int parseIntField(const char *data, const char *field);
+void parseStringField(const char *data, const char *field, char *value);
+void addDevice(char *deviceString);
+void addSensorListParams(char *paramString, DEVICE_PARAMS *device);
+void addCommandListParams(char *paramString, DEVICE_PARAMS *device);
+GATEWAY_PARAMS gateway_config_params = {0};
 
-static CONFIG_PARAMS g_config_params = {0};
-
-
-void write_struct_to_flash(uint32_t *data, int size);
-
-/*
- *  函数名:save_config_params(CONFIG_PARAMS *params)
- *  输入参数:无
- *  输出参数:无
- *  返回值:无
- *  函数作用:加载http或者上位机配置参数
- */
-int save_config_params(CONFIG_PARAMS *params)
+GATEWAY_PARAMS *get_gateway_config_params()
+{
+    return &gateway_config_params;
+}
+/***
+***其主要分为了三层结构来做的最外层网关层,设备层,属性层
+***其不用json解析,json消耗量太大,用关键字匹配去解析json数据用'}'和后一位']'去做结束判断依次从最内层往外层一层一层解析,解析完最内层的数据将'}'变为'A'防止外层去找结束符号时找到了内层
+***/
+//解析网关最外层的相关信息
+int addGatewayParams(char *gatewayString)
 {
-		if(params == NULL)
-				return -1;
+	  parseStringField(gatewayString, "\"commandTopic\":\"", (char *)&gateway_config_params.commandTopic);
+		parseStringField(gatewayString, "\"messageTopic\":\"", (char *)&gateway_config_params.messageTopic);
+
+    parseStringField(gatewayString, "\"deviceId\":\"", (char *)&gateway_config_params.deviceId);
+    parseStringField(gatewayString, "\"host\":\"", (char *)&gateway_config_params.host);
+    gateway_config_params.port = parseIntField(gatewayString, "\"port\":");
 		
-		CONFIG_PARAMS_UNION config_params_union;
-		memset(&config_params_union, 0, sizeof(CONFIG_PARAMS_UNION));	
-		memcpy(&config_params_union.config_params, params, sizeof(CONFIG_PARAMS)); 
-		clear_gateway_config_block();
-		write_struct_to_flash((uint32_t *)&config_params_union, sizeof(CONFIG_PARAMS_UNION));
-		return 0;
+    gateway_config_params.pollTime = parseIntField(gatewayString, "\"pollTime\":");
+		gateway_config_params.baudrate=parseIntField(gatewayString, "\"baudrate\":");
+		gateway_config_params.checkBit=parseIntField(gatewayString, "\"checkBit\":");
+		gateway_config_params.dataBits=parseIntField(gatewayString, "\"dataBit\":");
+		gateway_config_params.stopBit=parseIntField(gatewayString, "\"stopBit\":");
+		gateway_config_params.inboundTime=parseIntField(gatewayString, "\"inboundTime\":");
+		char *deviceString = strstr(gatewayString, "deviceList");//找到设备数组所处位置
+    while (1)
+    {
+				addDevice(deviceString); // 往此节点下挂载设备信息
+				deviceString=deviceString;//deviceString内容被内部数据改写了进行一次数据重加载
+				deviceString = strstr(deviceString, "}");          // 移动到下一条属性
+				deviceString[0]='A';
+				deviceString++;
+			  if(deviceString[0]==']')
+				{
+						break;
+				}
+    }
 }
-/*
- *  函数名:load_config_params()
- *  输入参数:无
- *  输出参数:无
- *  返回值:无
- *  函数作用:加载http或者上位机配置参数
- */
-int load_config_params()
-{	
-		CONFIG_PARAMS_UNION config_params_union;
-		memset(&config_params_union, 0, sizeof(CONFIG_PARAMS_UNION));//清空原先数据
-		//读出w25q32内部的结构体信息
-		W25Q32_Read((uint8_t *)&config_params_union, 0, sizeof(CONFIG_PARAMS_UNION)); //从W25Q32中读取结构体数据
-		memcpy(&g_config_params, &config_params_union.config_params, sizeof(CONFIG_PARAMS));
-		uint8_t *ptr=(uint8_t *)&g_config_params;
-	  //判断第一位数据是否有效	
-		if(*ptr == 0xF1)
+void addGatewayParamsJson(char *gatewayString)
+{
+	
+}
+//添加新的设备
+//应其为多层嵌套结构所以其找到最内部对象{}后将其值改写,这样可以避免外部的结构再去寻找
+void addDevice(char *deviceString)
+{
+	char *paramString = (char *)deviceString; // 属性指针
+  DEVICE_PARAMS *newDevicePage = (DEVICE_PARAMS *)malloc(sizeof(DEVICE_PARAMS));
+	newDevicePage->nextDevice = NULL;
+	parseStringField(deviceString, "\"deviceId\":\"", (char *)&newDevicePage->deviceID);
+  newDevicePage->protocol = parseIntField(deviceString, "\"protocol\":");
+  newDevicePage->params = (PARAMS_PROTOCOL_COMMAND *)malloc(sizeof(PARAMS_PROTOCOL_COMMAND));	
+	paramString = strstr(paramString, "\"sensorData\":["); // 找到该节点的轮询上发属性
+	if(paramString!=NULL)
+	{
+		while(1)
 		{
-				return 0;
+			 addSensorListParams(paramString, newDevicePage); // 解析一个属性并挂载该属性于该属性下
+			 paramString = strstr(paramString, "}");          // 移动到下一条属性
+			 paramString[0]='A';
+			 paramString++;
+			 if (paramString[0] == ']')
+			 {
+				 paramString = (char *)deviceString;//找完了设备层内的属性,将指针指向设备层一开始的位置,防止json导致的sensorList和commandData乱序问题
+				 break;
+			 }
 		}
-		return -1;
+	}
+		if(newDevicePage->protocol==MODBUS)  //如果为modbus的话解析写指令
+		{
+		paramString=deviceString;                                //移动到最开始的地方
+		newDevicePage->MDBbigLittleFormat = parseIntField(paramString, "\"bigLittleFormat\":");
+    newDevicePage->MDBdataType= parseIntField(paramString, "\"dataType\":");
+		paramString = strstr(paramString, "\"commandData\":["); // 找到其轮询的写命令
+		if(paramString!=NULL)//可能不存在commandData
+		{
+			while(1)
+			{
+				addCommandListParams(paramString, newDevicePage);
+				paramString = strstr(paramString, "}");
+				paramString[0]='A';
+				paramString++;
+				if (paramString[0] == ']')
+				{
+					paramString = (char *)deviceString;
+					break;
+				}
+			}
+		}
+	}
+	if(gateway_config_params.device_params==NULL)
+	{
+		gateway_config_params.device_params=newDevicePage;
+	}else
+	{
+		DEVICE_PARAMS *current=gateway_config_params.device_params;
+    while (current->nextDevice != NULL)
+    {
+      current = current->nextDevice;
+    }
+      current->nextDevice = newDevicePage;		
+	}
 }
-/*
- *  函数名:CONFIG_PARAMS *get_config_params()
- *  输入参数:无
- *  输出参数:无
- *  返回值:无
- *  函数作用:获取配置参数
+/**
+ * @brief  解析输入字符串的paramString数据,将数据保存到至该设备结构体下,此处解析sensorList
+ * @param  uint8_t *paramString输入的字符串数据,DEVICE_PARAMS *device节点信息
+ * @retval 无
  */
-CONFIG_PARAMS *get_config_params()
+void addSensorListParams(char *paramString, DEVICE_PARAMS *device)
 {
-		return &g_config_params;
+    switch (device->protocol)
+    {
+    case DLT645_97:
+    case DLT645_07:
+		{
+        READ_DLT645_COMMAND *read_dlt645_command = malloc(sizeof(READ_DLT645_COMMAND));
+				READ_MODBUS_COMMAND *read_modbus_command =NULL;
+        read_dlt645_command->Identification = parseIntField(paramString, "\"identifier645\":");
+        parseStringField(paramString, "\"identifier\":\"", (char *)&read_dlt645_command->keyword);
+        char *string = malloc(13);
+        parseStringField(paramString, "\"deviceID645\":\"", string);
+        for (int j = 0; j < 6; j++)
+        {
+          uint8_t byte;
+          sscanf((const char *)&string[j * 2], "%2hhx", &byte);
+          read_dlt645_command->deviceID645[j]=byte;
+        }
+        free(string);
+        if (device->params->node_read_dlt645_command == NULL)
+        {
+            device->params->node_read_dlt645_command = read_dlt645_command;
+        }
+        else
+        {
+            READ_DLT645_COMMAND *current = device->params->node_read_dlt645_command;
+            while (current->nextParams != NULL)
+            {
+                current = current->nextParams;
+            }
+            current->nextParams = read_dlt645_command;
+        }
+			}
+        break;
+    case MODBUS:
+		{
+        READ_MODBUS_COMMAND *read_modbus_command = malloc(sizeof(READ_MODBUS_COMMAND));
+				READ_DLT645_COMMAND *read_dlt645_command = NULL;
+				parseStringField(paramString,"\"identifier\":\"",(char *)&read_modbus_command->keyword);
+        read_modbus_command->decimalPoint = parseIntField(paramString, "\"precise\":");
+        read_modbus_command->functionCode = parseIntField(paramString, "\"rFunctionCode\":");
+        read_modbus_command->slaveAddress = parseIntField(paramString, "\"slaveAddress\":");
+        read_modbus_command->registerAddress = parseIntField(paramString, "\"registerAddress\":");
+        read_modbus_command->registerByteNum = parseIntField(paramString, "\"registerByteNum\":");
+        if (device->params->node_read_modbus_command == NULL)
+        {
+            device->params->node_read_modbus_command = read_modbus_command;
+        }
+        else
+        {
+            READ_MODBUS_COMMAND *current = device->params->node_read_modbus_command;
+            while (current->nextParams != NULL)
+            {
+                current = current->nextParams;
+            }
+            current->nextParams = read_modbus_command;
+        }
+			}
+        break;
+    default:
+        break;
+    }
 }
-/*
- *  函数名:void write_struct_to_flash(uint32_t *data, int size)
- *  输入参数:*data,size、data为往w25q32内写入的数据、size为写入数据大小
- *  输出参数:无
- *  返回值:无
- *  函数作用:往w25q32内写入的数据、一次最多写入一页数据、长度超过时要切换页
- */
-void write_struct_to_flash(uint32_t *data, int size)
+void addCommandListParams(char *paramString, DEVICE_PARAMS *device)
 {
-		uint8_t *pdata = (uint8_t *)data;  
-		//将数据按页写入一次写入256个字节
-    for (int i = 0; i <= size / 256; i++) {
-        W25Q32_PageWrite(pdata + i * 256, i); 
+	
+ 	WRITE_MODBUS_COMMAND *write_modbus_command=malloc(sizeof(WRITE_MODBUS_COMMAND));
+	parseStringField(paramString,"\"identifier\":\"",(char *)&write_modbus_command->keyword);
+	write_modbus_command->registerByteNum = parseIntField(paramString, "\"registerByteNum\":");
+	write_modbus_command->functionCode=parseIntField(paramString, "\"wFunctionCode\":");
+	write_modbus_command->slaveAddress=parseIntField(paramString, "\"slaveAddress\":");
+	write_modbus_command->registerAddress = parseIntField(paramString, "\"registerAddress\":");
+	if(device->params->node_write_modbus_command == NULL)
+	{
+		device->params->node_write_modbus_command=write_modbus_command;
+	}
+	else
+	{
+		WRITE_MODBUS_COMMAND *current=device->params->node_write_modbus_command;
+    while (current->nextParams != NULL)
+    {
+      current = current->nextParams;
     }
+    current->nextParams = write_modbus_command;		
+	}
 }
-/*
- *  函数名:clear_gateway_config_block(void)
- *  输入参数:无
- *  输出参数:无
- *  返回值:无
- *  函数作用:清除http获取的参数配置
- */
-void clear_gateway_config_block(void)
+// 提取int数据如果没有提取到数据则返回-1;提取到返回正确的值
+int parseIntField(const char *data, const char *field)
 {
-	W25Q32_Erase64K(0);//擦除一块区域的大小
+    char *ptr = strstr(data, field) + strlen(field);
+    int value;
+    value = strtol(ptr, &ptr, 10);
+    return value;
 }
+/*
 
-
+*/
+// 提取string字符串
+void parseStringField(const char *data, const char *field, char *value)
+{
+    char *ptr = strstr(data, field) + strlen(field);
+    sscanf(ptr, "%[^\"],", value);
+}

+ 87 - 84
app/App/device_message.h

@@ -5,93 +5,96 @@
 #include <stdint.h>
  
 
+#define	MODBUS  3
+#define	DLT645_97 2
+#define	DLT645_07 1
 
 
-typedef struct _DEVICE_READ_DATA_INFO{
-			
-      uint8_t decimalPoint;
-        uint8_t keyword[20];                                         
-        uint8_t deviceId[20];               
-        uint8_t mdbSlave;                   
-        uint8_t mdbFunctionCode;            
-        uint16_t registerLength;                
-        uint16_t mdbRegister;                  
-        uint8_t deviceID645[6];
-        uint16_t datalength;
-        uint32_t dataType645;
-        uint8_t bigLittleFormat;              
-				uint8_t data[9];        //从机应答的值,前四个字节存储浮点数数据、后面五个字节存储645 DATE内容
-				uint8_t rxLen;          //从机应答值的长度
-}device_read_data;                //70字节
-
-typedef struct _DEVICE_WRITE_DATA_INFO{
-       uint8_t decimalPoint;
-        uint8_t keyword[20];                                         
-        uint8_t deviceId[20];               
-        uint8_t mdbSlave;                   
-        uint8_t mdbFunctionCode;            
-        uint16_t registerLength;                
-        uint16_t mdbRegister;                  
-        uint32_t deviceID645;
-        uint8_t bigLittleFormat; 
-        uint16_t data;                     //只支持写入一个16位寄存器的值
-        uint8_t flag;                      //写是否成功标志位   0失败 1成功
-}device_write_data;                         //50字节
-
-
-
-typedef struct _CONFIG_PARAMS
+// 节点所存储的modbus写命令
+typedef struct _WRITE_MODBUS_COMMAND
 {
-	  uint8_t data_valid_flag;                 //数据有效标志  0xF1:有效  其它:无效
-    uint8_t host[20];                        //MQTT服务器地址
-    uint16_t port;                           //MQTT服务器端口号
-    uint8_t messageTopic[50];                //MQTT消息主题
-    uint8_t commandTopic[50];                //MQTT指令主题
-    uint32_t  baudrate;                      //波特率
-    uint8_t dataBits;                        //数据位
-    uint8_t checkBit;                        //校验位
-    uint8_t stopBit;                         //停止位
-    uint8_t flowControl;                		 //流控制
-    uint8_t deviceId[20];                     //设备ID
-		uint8_t dataSource;                     //协议类型                 0 保留 1 表示645协议 2表示modbus协议
-    uint8_t dataType645;                     //645协议数据类型          0保留  1 表示07版本  2表示97版本
-    uint32_t pollTime;                       //轮询时间
-		uint32_t inboundTime;
-	  uint8_t device_read_data_num;
-	  uint8_t device_write_data_num;                    
-		device_read_data device_read_data[180];
-		device_write_data device_write_data[120];
-		
-		uint8_t state;                 //检测是否上位机配置过当上位机配置过该状态位,则以后均不走http获取相应配置 置位值为0xF1
-		uint8_t version[10];						//用于版本检测升级
-		uint8_t gatewayId[10];					//固化信息
-		uint8_t gatewayMode[10];				//工作模式、后续版本迭代使用
-		//网关相关信息
-		uint8_t gateName[10];
-}CONFIG_PARAMS;                               //168+180*70+120*50+41=19000字节/4=4750
-
-
-
-
-
-
- 
-typedef union _CONFIG_PARAMS_UNION
+	uint8_t slaveAddress;
+	uint16_t registerByteNum;
+	uint8_t functionCode;
+	uint8_t keyword[20]; // 所写属性的名称
+	uint16_t registerAddress;	// 寄存器地址
+	uint8_t write_command_flag; // 是否成功写入的标志
+	struct _WRITE_MODBUS_COMMAND *nextParams;
+} WRITE_MODBUS_COMMAND;
+
+// 节点所存储的modbus读命令
+typedef struct _READ_MODBUS_COMMAND
 {
-		CONFIG_PARAMS config_params; 
-		uint32_t data[4750];			
-}CONFIG_PARAMS_UNION;
- 
-
-extern int load_config_params(void);
- 
-extern CONFIG_PARAMS *get_config_params(void);
-
- 
- 
-extern int save_config_params(CONFIG_PARAMS *params);
-
-extern void clear_gateway_config_block(void);
- 
+	uint8_t slaveAddress;
+	uint8_t functionCode;
+	uint8_t keyword[20]; // 所读属性的名称
+	
+	uint16_t registerAddress;  // 寄存器地址
+	uint8_t read_command_flag; // 是否成功读取到的标志
+	uint8_t value[4];          //读取到的数据值
+	uint8_t rxLen;
+	uint16_t registerByteNum;
+	uint8_t decimalPoint;
+	struct _READ_MODBUS_COMMAND *nextParams;
+} READ_MODBUS_COMMAND;
+
+// 节点所存储都DLT645读指令
+typedef struct _READ_DLT645_COMMAND
+{
+	uint8_t deviceID645[6];
+	uint8_t keyword[20];   // 所读属性的名称
+	uint32_t Identification; // 645数据标识
+	uint8_t data[9];	   // 读到的数据
+	uint8_t rxLen;		   // 从机应答值的长度
+	struct _READ_DLT645_COMMAND *nextParams;
+} READ_DLT645_COMMAND;
+
+typedef struct _PARAMS_PROTOCOL_COMMAND
+{
+	READ_MODBUS_COMMAND   *node_read_modbus_command;
+	WRITE_MODBUS_COMMAND  *node_write_modbus_command;
+	READ_DLT645_COMMAND   *node_read_dlt645_command;
+}PARAMS_PROTOCOL_COMMAND;
 
+// 节点包含的设备信息
+typedef struct _DEVICE_PARAMS
+{
+	uint8_t aliveflag; // 存活证明(由轮询来进行保证,当有轮询回应是确定其存活,当链路变化时立即上报设备已经死去,当轮询有相应的相应值时去上报已经存活)
+	uint8_t deviceID[20];
+	uint8_t protocol;  // 所属协议类型                  1:modbus read 2:modbus write     3:dlt97  4:dlt07            一个设备只能存在一个协议
+	PARAMS_PROTOCOL_COMMAND	*params;
+	//当为modbus协议时设备层还包含大小端,和底层数据类型
+	uint8_t MDBbigLittleFormat;
+	uint8_t MDBdataType;
+	struct _DEVICE_PARAMS *nextDevice; // 指向下一个设备地址
+} DEVICE_PARAMS;
+
+typedef struct _GATEWAY_PARAMS
+{
+	uint8_t data_valid_flag;  // 数据有效标志  0xF1:有效  其它:无效
+	uint8_t host[20];		  // MQTT服务器地址
+	uint16_t port;			  // MQTT服务器端口号
+	uint8_t messageTopic[50]; // MQTT消息主题
+	uint8_t commandTopic[50]; // MQTT指令主题
+	uint8_t deviceId[25];	  // 设备ID
+	uint32_t pollTime;		  // 轮询时间
+	uint32_t inboundTime;
+	uint8_t state;			 // 检测是否上位机配置过当上位机配置过该状态位,则以后均不走http获取相应配置 置位值为0xF1
+	
+	uint32_t baudrate;
+	uint8_t dataBits;
+	uint8_t stopBit;
+	uint8_t checkBit;
+	
+	uint8_t gatewayId[10];	 // 固化信息
+	uint8_t gatewayMode[10]; // 工作模式、后续版本迭代使用
+	uint8_t version[10];
+	// 网关相关信息
+	uint8_t gateName[10];
+
+	// 附属设备相关信息
+	DEVICE_PARAMS *device_params;
+} GATEWAY_PARAMS;
+int addGatewayParams(char *gatewayString);
+GATEWAY_PARAMS *get_gateway_config_params();
 #endif

+ 101 - 366
app/App/ec800m.c

@@ -80,117 +80,6 @@ bool WaitResponse(char *expectStr, int timeout)
 }
 
 
-//bool WaitResponseserver(CONFIG_PARAMS *gateway,int timeout)
-//{
-//	bool timeoutFlag = false;
-//	if (timeout >= 0)
-//	{
-//		timeoutFlag = true;
-//	}
-//	// gd_485_send((char *)&UART0_RX_BUF, strlen(UART0_RX_BUF)); 不清楚此处调用485意义
-
-//	while (1)
-//	{
-//		char *p=NULL;
-//		char *Q=NULL;
-//		uint8_t seg1;
-//		uint8_t seg2;
-//		char seg3[20];
-//		char seg6[10];
-//		uint8_t seg4;
-//		char seg5[25];
-//		char buf[20];
-//		char *token;
-//		delay_1ms(50);
-//		if (UART0_RX_STAT > 0)
-//		{
-
-//				UART0_RX_STAT = 0;
-////			char *p = strstr((char *)&UART0_RX_BUF, expectStr);
-//			
-
-//			
-//			
-//			if(strstr((char *)&UART0_RX_BUF, "+COPS:"))
-//			{
-//				Q=strstr((char *)&UART0_RX_BUF, "+COPS:");
-//			
-//				sscanf(Q, "+COPS:%d,%d,%s", &seg1,&seg2,seg3);
-//				sscanf(Q, "+COPS:%d,%d,%*s%s ", &seg1,&seg2,seg6);
-//				
-//				if(strstr((char *)&seg3, "CHN-CT"))
-//				{
-//					strcpy((char *)gateway->Operatortyp,"CHN-CT");
-//					p=strchr((char *)&seg3,',')+1;	
-//					strcpy((char *)gateway->Networktyp,p);
-//					strcpy(gateway->Networkstatu,"1");//注册到网络
-//					
-//				
-//				}else if(strstr((char *)&seg3, "CHN-UNICOM"))
-//				{
-//					strcpy((char *)gateway->Operatortyp,"CHN-UNICOM");
-//					p=strchr((char *)&seg3,',')+1;	
-//					strcpy((char *)gateway->Networktyp,p);
-//					strcpy(gateway->Networkstatu,"1");//注册到网络
-//					
-//				}else if(strstr((char *)&seg3, "CHINA"))
-//				{
-//					strcpy((char *)gateway->Operatortyp,"CHINA MOBILE");
-//					p=strchr((char *)&seg6,',')+1;	
-//					strcpy((char *)gateway->Networktyp,p);
-//					strcpy(gateway->Networkstatu,"1");//注册到网络
-//					
-//				}else 
-//				{
-//					strcpy((char *)gateway->Operatortyp,"");
-//					strcpy((char *)gateway->Networktyp,"");
-//					strcpy(gateway->Networkstatu,"0");//注册到网络
-//				}
-//					
-//			}else if(strstr((char *)&UART0_RX_BUF, "+CLCK:"))
-//			{
-//				Q=strstr((char *)&UART0_RX_BUF, "+CLCK:");
-//				sscanf(Q, "+CLCK:%d", &seg1);
-//				sprintf(buf,"%d",seg1);
-//				memcpy(gateway->SIMcardstatus,buf,sizeof(buf));
-//				memset(buf,0,sizeof(buf));
-//			
-//				}else if(strstr((char *)&UART0_RX_BUF, "+QCCID:"))
-//			{
-
-//				p = strchr((char *)&UART0_RX_BUF,':')+2;
-//				sscanf(p, "%20s", seg5); 
-//				strcpy((char *)gateway->SIMcardICCID,seg5);
-
-//				}else if(strstr((char *)&UART0_RX_BUF, "+GSN"))
-//			{
-//				p = strchr((char *)&UART0_RX_BUF,'N')+4;
-//				sscanf(p, "%15s", seg5); 
-//				strcpy((char *)gateway->IMEInumber,seg5);		
-//			
-//			}else if(strstr((char *)&UART0_RX_BUF, "+CSQ:"))
-//			{
-//				Q=strstr((char *)&UART0_RX_BUF, "+CSQ:");
-//				sscanf(Q, "+CSQ:%d,%d", &seg1,&seg2);
-//				sprintf(buf,"%d",(int)(((float)seg1/31)*100));
-//				memcpy(gateway->Signalstrength,buf,sizeof(buf));
-//				memset(buf,0,sizeof(buf));				
-//			}
-//		}else if(strstr((char *)&UART0_RX_BUF, "+CME ERROR:"))//QCCID没有的情况出现+CME ERROR:
-//			{
-//			strcpy((char *)gateway->SIMcardICCID,"");
-//			
-//			}
-//		timeout -= 50;
-//		if (timeoutFlag == true && timeout <= 0)
-//		{
-//			Clear_DMA_Buffer();
-//			return false;
-//		}
-//	};
-//}
-
-
 
 
 
@@ -212,41 +101,10 @@ void EC800MSetPDP()
 	EC800MSendCmd(CMD_SET_ACTIVE, strlen(CMD_SET_ACTIVE));
 	WaitResponse(RSP_OK, 1000);
 	delay_1ms(200);
-	//	//测试代码查看ip
-	//	char *test="AT+QIACT?\r\n";
-	//	EC800MSendCmd(test,strlen(test));
-	//	WaitResponse(RSP_OK, 1000);
+	
 }
 
 
-//void ec800m_information_service(CONFIG_PARAMS *gateway)
-//{
-////delay_1ms(200);
-//		EC800MSendCmd(CMD_SERVICE_Operatortyp, strlen(CMD_SERVICE_Operatortyp)); // 	
-//		WaitResponseserver(gateway, 200);
-
-////	delay_1ms(200);
-//		EC800MSendCmd(CMD_SERVICE_SIMcardstatus, strlen(CMD_SERVICE_SIMcardstatus)); // 输入URL
-//		WaitResponseserver(gateway, 200);
-
-////	delay_1ms(200);
-//	
-//		EC800MSendCmd(CMD_SERVICE_SIMcardICCID, strlen(CMD_SERVICE_SIMcardICCID)); // 输入URL
-//		WaitResponseserver(gateway, 200);
-
-////delay_1ms(200);
-//		EC800MSendCmd(CMD_SERVICE_IMEInumber, strlen(CMD_SERVICE_IMEInumber)); // 输入URL
-//		WaitResponseserver(gateway, 200);
-////delay_1ms(200);
-//		EC800MSendCmd(CMD_SERVICE_Signalstrength, strlen(CMD_SERVICE_Signalstrength)); // 输入URL
-//		WaitResponseserver(gateway, 200);
-
-//}
-
-
-
-
-
 
 
 /*
@@ -286,6 +144,7 @@ bool EC800MGetUrl(char *url,char *dmaBuffer,uint32_t bufferSize)
 	delay_1ms(1000);
 
 	dma_config_change(dmaBuffer,bufferSize);
+	delay_1ms(1000);
 	EC800MSendCmd(CMD_READ_FILE, strlen(CMD_READ_FILE)); //"AT+QFDWL=http.txt\r\n"
 	delay_1ms(6000);
 
@@ -338,156 +197,7 @@ void ConnectMQTTSever(uint8_t *host, uint16_t port, uint8_t keepalive, uint8_t *
 	}
 }
 
-///*
-// *  函数名:void MQTTPublish(CONFIG_PARAMS *gateway)
-// *  输入参数:CONFIG_PARAMS *gateway 网关内存储信息
-// *  输出参数:无
-// *  返回值:无
-// *  函数作用:读出采集到的数据进行上报,若未采集到数据则不进行任何处理 23/4/4添加testId测试丢包情况
-// */
-//void MQTTPublish(CONFIG_PARAMS *gateway)
-//{
-//	char payload_out[200];
-//	char mqtt_publish[200];
-//	if (gateway->dataSource == 1) // 645协议查询到的值进行上报
-//	{
-//		for (int i = 0; i < gateway->device_read_data_num; i++)
-//		{
-//			if (gateway->device_read_data[i].rxLen!= 0)
-//			{
-//				float value;
-//			
-//				uint8_t minute,hour,day,month,year;
-//				switch (gateway->device_read_data[i].rxLen)
-//				{
-//					case 0:
-//					case 1:
-//					case 2:
-//					case 3:
-//					case 4:		
-//							memcpy(&value, gateway->device_read_data[i].data, 4); // 取出相应的值给value
-//							sprintf((char *)payload_out,
-//								"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\": %.2f}]}",
-//									gateway->deviceId,
-//									gateway->device_read_data[i].deviceId,
-//									gateway->device_read_data[i].keyword,
-//									value);
-//						break;
-//					case 5:
-//						memcpy(&value, gateway->device_read_data[i].data, 4);
-//						year =gateway->device_read_data[i].data[4];
-//						month = gateway->device_read_data[i].data[3];
-//						day = gateway->device_read_data[i].data[2];
-//						hour = gateway->device_read_data[i].data[1];
-//						minute = gateway->device_read_data[i].data[0];
-//						sprintf((char *)payload_out,
-//								"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\": \"%02X%02X%02X%02X%02X\"}]}",
-//								gateway->deviceId,gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,year,month,day,hour,minute);
-//						break;
-//					case 6:
-//					case 7:
-//					case 8:
-//					case 9:
-//						memcpy(&value, gateway->device_read_data[i].data, 4);
-//						year =gateway->device_read_data[i].data[8];
-//						month = gateway->device_read_data[i].data[7];
-//						day = gateway->device_read_data[i].data[6];
-//						hour = gateway->device_read_data[i].data[5];
-//						minute = gateway->device_read_data[i].data[4];
-//						sprintf((char *)payload_out,
-//								"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\":\"%02X%02X%02X%02X%02X%.2f\"}]}",
-//								gateway->deviceId,gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,year,month,day,hour,minute,value);
-//						break;
-//						default:
-//							//不在此区域要清空上一次sprintf
-//						break;
-//					}
-//					sprintf((char *)mqtt_publish, "AT+QMTPUBEX=0,0,0,0,\"%s\",%d\r\n", gateway->messageTopic, strlen(payload_out));
-//					EC800MSendCmd(mqtt_publish, strlen(mqtt_publish));
-//					WaitResponse("QMTPUBEX", 1000);
-//					delay_1ms(50);
-//					EC800MSendCmd(payload_out, strlen(payload_out));
-//					//WaitResponse(RSP_OK, 1000);
-//					//特殊处理2023、6、28日添加publish失败重新订阅MQTT平台
-//					if(WaitResponse("QMTPUBEX", 1000)==false)
-//					{
-//						ConnectMQTTSever(gateway->host, gateway->port, 60, gateway->deviceId);
-//						MQTTSubTopic(gateway->commandTopic);
-//					}
-//						
-//			}
-//		}
-//	}
-//	else if (gateway->dataSource == 2) // modbus协议处理
-//	{
-//		for (int i = 0; i < gateway->device_read_data_num; i++)
-//		{
-//			if (gateway->device_read_data[i].rxLen!= 0)
-//			{
-//				// 功能码03、01需要分开,因功能码01查询到的值为开关转台
-//				if (gateway->device_read_data[i].mdbFunctionCode == 0x03)
-//				{
-//					if(gateway->device_read_data[i].decimalPoint!=0)
-//					{
-//					float value;
-//					memcpy(&value, gateway->device_read_data[i].data, 4); // 取出相应的值给value
-//					sprintf((char *)payload_out,
-//							"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\": %.2f\r\n}]}",
-//							gateway->deviceId,
-//							gateway->device_read_data[i].deviceId,
-//							gateway->device_read_data[i].keyword,
-//							value);
-//					}
-//					else if(gateway->device_read_data[i].decimalPoint==0)
-//					{
-//						uint32_t value;
-//						value=gateway->device_read_data[i].data[0]+(gateway->device_read_data[i].data[1]>>8)+(gateway->device_read_data[i].data[2]>>16)+(gateway->device_read_data[i].data[3]>>24);
-//						sprintf((char *)payload_out,
-//							"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\": %d\r\n}]}",
-//							gateway->deviceId,
-//							gateway->device_read_data[i].deviceId,
-//							gateway->device_read_data[i].keyword,
-//							value);
-//					}
-//					
-//				}
-//				else if (gateway->device_read_data[i].mdbFunctionCode == 0x01)
-//				{
-//					uint8_t value[4];
-//					uint8_t state;
-//					memcpy(&value, gateway->device_read_data[i].data, 4);
-//					if (value[2] == 0xFF)
-//					{
-//						state = 1;
-//					}
-//					else
-//					{
-//						state = 0;
-//					}
-//					sprintf((char *)payload_out,
-//							"{\"deviceId\":\"%s\",\"data\":[{\"deviceId\":\"%s\",\"%s\": %d}]}",
-//							gateway->deviceId,
-//							gateway->device_read_data[i].deviceId,
-//							gateway->device_read_data[i].keyword,
-//							state);
-//				}
-//				sprintf((char *)mqtt_publish, "AT+QMTPUBEX=0,0,0,0,\"%s\",%d\r\n", gateway->messageTopic, strlen(payload_out));
-//				EC800MSendCmd(mqtt_publish, strlen(mqtt_publish));
-//				WaitResponse("QMTPUBEX", 1000);
-//					delay_1ms(50);
-//					EC800MSendCmd(payload_out, strlen(payload_out));
-//					//WaitResponse(RSP_OK, 1000);
-//					//特殊处理2023、6、28日添加publish失败重新订阅MQTT平台
-//					if(WaitResponse("QMTPUBEX", 1000)==false)
-//					{
-//						NVIC_SystemReset();
-//					}
-//						
-//			}
-//		}
-//		
-//	}
-//}
+
 /*
  *  函数名:void MQTTPublish(CONFIG_PARAMS *gateway)
  *  输入参数:CONFIG_PARAMS *gateway 网关内存储信息
@@ -495,96 +205,121 @@ void ConnectMQTTSever(uint8_t *host, uint16_t port, uint8_t keepalive, uint8_t *
  *  返回值:无
  *  函数作用:读出采集到的数据进行上报,若未采集到数据则不进行任何处理 23/4/4添加testId测试丢包情况7/18日重写此方法
  */
-void MQTTPublish(CONFIG_PARAMS *gateway)
+void MQTTPublish(void)
 {
+	GATEWAY_PARAMS *gateway;
+	gateway=get_gateway_config_params();
 	char *payload_out=malloc(25*1024);         //要发送的字符串
 	char mqtt_publish[200];        //发送字符串的指令
 	sprintf((char *)payload_out,"{\"deviceId\":\"%s\",\"data\":[",gateway->deviceId);//组成json头部
-	for (int i = 0; i < gateway->device_read_data_num; i++)
+	
+	DEVICE_PARAMS *currentDevice=gateway->device_params;
+	READ_MODBUS_COMMAND *read_modbus_command=NULL;
+	READ_DLT645_COMMAND *read_dlt645_command=NULL;
+	switch(currentDevice->protocol)
 	{
-		if (gateway->dataSource == 1)
-		{
-			if (gateway->device_read_data[i].rxLen!= 0) //dlt645
-			{
-				float value;
-			
-				uint8_t minute,hour,day,month,year;
-				switch (gateway->device_read_data[i].rxLen)
-				{
-					case 0:
-					case 1:
-					case 2:
-					case 3:
-					case 4:		
-							memcpy(&value, gateway->device_read_data[i].data, 4); // 取出相应的值给value
-							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %.2f},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,value);
-						break;
-					case 5:
-						memcpy(&value, gateway->device_read_data[i].data, 4);
-						year =gateway->device_read_data[i].data[4];
-						month = gateway->device_read_data[i].data[3];
-						day = gateway->device_read_data[i].data[2];
-						hour = gateway->device_read_data[i].data[1];
-						minute = gateway->device_read_data[i].data[0];
-						sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": \"%02X%02X%02X%02X%02X\"},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,year,month,day,hour,minute);
-						break;
-					case 6:
-					case 7:
-					case 8:
-					case 9:
-						memcpy(&value, gateway->device_read_data[i].data, 4);
-						year =gateway->device_read_data[i].data[8];
-						month = gateway->device_read_data[i].data[7];
-						day = gateway->device_read_data[i].data[6];
-						hour = gateway->device_read_data[i].data[5];
-						minute = gateway->device_read_data[i].data[4];
-						sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\":\"%02X%02X%02X%02X%02X%.2f\"},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,year,month,day,hour,minute,value);
-						break;
-						default:
-							//不在此区域要清空上一次sprintf
-						break;
-					}
-			}
-		}
-		else if(gateway->dataSource == 2)  //modbus
+		case DLT645_07:
+		case DLT645_97:
+			read_dlt645_command=currentDevice->params->node_read_dlt645_command;
+		break;
+		case MODBUS:
+			read_modbus_command=currentDevice->params->node_read_modbus_command;
+		break;
+	}
+	while(1)
+	{
+		__START__WHILE:
+		switch(currentDevice->protocol)
 		{
-			if (gateway->device_read_data[i].rxLen!= 0)
-			{
-				// 功能码03、01需要分开,因功能码01查询到的值为开关转台
-				if (gateway->device_read_data[i].mdbFunctionCode == 0x03)
+			case DLT645_07:
+			case DLT645_97:
+				if(read_dlt645_command->rxLen!=0)
 				{
-					if(gateway->device_read_data[i].decimalPoint!=0)
+					float value;
+					switch(read_dlt645_command->rxLen)
 					{
-						float value;
-						memcpy(&value, gateway->device_read_data[i].data, 4); // 取出相应的值给value
-						sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %.2f},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,value);
-					}
-					else if(gateway->device_read_data[i].decimalPoint==0)
-					{
-						uint32_t value;
-						value=gateway->device_read_data[i].data[0]+(gateway->device_read_data[i].data[1]>>8)+(gateway->device_read_data[i].data[2]>>16)+(gateway->device_read_data[i].data[3]>>24);
-						sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %d},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,value);
+							case 4:
+							memcpy(&value, read_dlt645_command->data, 4);
+							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %.2f},",currentDevice->deviceID,read_dlt645_command->keyword,value);
+							break;
+							case 5:
+							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": \"%02X%02X%02X%02X%02X\"},",currentDevice->deviceID,read_dlt645_command->keyword,read_dlt645_command->data[4],
+																																																								read_dlt645_command->data[3],read_dlt645_command->data[2],read_dlt645_command->data[1],read_dlt645_command->data[0]);
+							break;
+								break;
+							case 9:
+							memcpy(&value, read_dlt645_command->data, 4);
+							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\":\"%02X%02X%02X%02X%02X%.2f\"},",currentDevice->deviceID,read_dlt645_command->keyword,read_dlt645_command->data[8],
+																																																										read_dlt645_command->data[7],read_dlt645_command->data[6],read_dlt645_command->data[5],read_dlt645_command->data[4],value);
+								break;
 					}
 				}
-				else if (gateway->device_read_data[i].mdbFunctionCode == 0x01)
+				break;
+			case MODBUS:
+			{
+				if(read_modbus_command->rxLen!=0)
 				{
-					uint8_t value[4];
-					uint8_t state;
-					memcpy(&value, gateway->device_read_data[i].data, 4);
-					if (value[2] == 0xFF)
+					if(read_modbus_command->functionCode==0x03)
 					{
-						state = 1;
+						if(read_modbus_command->decimalPoint!=0)
+						{
+							float value;
+							memcpy(&value, read_modbus_command->value, 4); // 取出相应的值给value
+							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %.2f},",currentDevice->deviceID,read_modbus_command->keyword,value);
+						}
+						else 
+						{
+							uint32_t value;
+							memcpy(&value, read_modbus_command->value, 4);
+							sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %d},",currentDevice->deviceID,read_modbus_command->keyword,value);
+						}
 					}
-					else
+					else if(read_modbus_command->functionCode==0x01)
 					{
-						state = 0;
+						uint8_t value[4];
+						uint8_t state;
+						memcpy(&value, read_modbus_command->value, 4);
+					 if (value[2] == 0xFF)
+						{
+							state = 1;
+						}
+						else
+						{
+							state = 0;
+						}
+					sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %d},",currentDevice->deviceID,read_modbus_command->keyword,state);
 					}
-					sprintf(payload_out+strlen(payload_out),"{\"deviceId\":\"%s\",\"%s\": %d},",gateway->device_read_data[i].deviceId,gateway->device_read_data[i].keyword,state);
 				}
+			}
+				break;
 		}
-	}
-}
-	if(strlen(payload_out)>30)//小于这个值组成的字符串证明没有数据采集到、就不进行发布
+				switch(currentDevice->protocol)
+		{
+		  case DLT645_07:
+  		case DLT645_97:
+				read_dlt645_command=read_dlt645_command->nextParams;
+				break;
+			case MODBUS:
+				read_modbus_command=read_modbus_command->nextParams;
+				break;
+		}
+		if(read_dlt645_command==NULL&&read_modbus_command==NULL)
+		{
+			currentDevice=currentDevice->nextDevice;
+			if(currentDevice==NULL)
+			{
+				goto __END__WHILE;
+			}
+			else
+			{
+				read_dlt645_command=currentDevice->params->node_read_dlt645_command;
+				read_modbus_command=currentDevice->params->node_read_modbus_command;
+			}
+		}
+		goto __START__WHILE;
+	}		
+__END__WHILE:
+	if(strlen(payload_out)>40)//小于这个值组成的字符串证明没有数据采集到、就不进行发布
 	{
 		sprintf(payload_out+strlen(payload_out)-1,"]}");
 		sprintf((char *)mqtt_publish, "AT+QMTPUBEX=0,0,0,0,\"%s\",%d\r\n", gateway->messageTopic, strlen(payload_out));

+ 2 - 2
app/App/ec800m.h

@@ -64,8 +64,8 @@ void ConnectMQTTSever(uint8_t *host,uint16_t port,uint8_t keepalive,uint8_t *cli
 void EC800MSetPDP(void);
 
 bool EC800MGetUrl(char *url,char *dmaBuffer,uint32_t bufferSize);
-void MQTTPublish(CONFIG_PARAMS *device);
+void MQTTPublish(void);
 void MQTTSubTopic(uint8_t *commandTopic);
-void ec800m_information_service(CONFIG_PARAMS *gateway);
+void ec800m_information_service(GATEWAY_PARAMS *gateway);
 
 #endif

+ 1 - 1
app/App/gd32f10x_it.c

@@ -42,7 +42,7 @@ OF SUCH DAMAGE.
 #include "mqttRecv.h"
 #include "systick.h"
 #include "dlt645_port.h"
-
+#include "parseDeviceMessage.h"
 
 
 /*!

+ 29 - 56
app/App/main.c

@@ -54,21 +54,22 @@ OF SUCH DAMAGE.
 #define UNIQUE_ID 0x1FFFF7E8
 
 
-#define VERSION "V1.0.0" // 版本号写死、通过人工手动控制
+#define VERSION "V1.0.1" // 版本号写死、通过人工手动控制
+
 #define GATEWAYNAME "DTU"
 #define GATEWAYMODE "4G" // 后续此mode可以切换4g
 
 
-void MQTT_Alarm_clock(uint32_t time, CONFIG_PARAMS *gateway);
+void MQTT_Alarm_clock(uint32_t time, GATEWAY_PARAMS *gateway);
 void readID(char *strId);
 void http_load_config(uint8_t *httpURL);
 void fwdgt_init();
 void task_fwdgt_reload();
 
-uint8_t protocol;
+
 
 int main(void)
- {
+  {
 	/* configure systick */
 	rcu_osci_on(RCU_HXTAL);
 	systick_config();
@@ -89,64 +90,42 @@ int main(void)
 	
 	readID(strID);
 	//加载网关信息
-	CONFIG_PARAMS *gateway;
-	gateway = get_config_params();
+	GATEWAY_PARAMS *gateway;
+	gateway = get_gateway_config_params();
 	
-	strcpy(gateway->deviceId, strID);
-	strcpy(gateway->version, VERSION);
-	strcpy(gateway->gatewayMode, GATEWAYMODE);
-	strcpy(gateway->gateName,GATEWAYNAME);
+	strcpy((char *)&gateway->gatewayId, strID);
+	strcpy((char *)&gateway->gatewayMode, GATEWAYMODE);
+	strcpy((char *)&gateway->gateName,GATEWAYNAME);
 	
 	
 	char *httpURL = malloc(100);
 	memset(httpURL, 0, 100);
-	sprintf(httpURL, "http://gpu.ringzle.com:8082/iot/transmit/getTransmitConfig?deviceId=%s",strID);
+	sprintf(httpURL, "http://gpu.ringzle.com:8082/iot/transmit/getTransmitConfig/%s",strID);
  	http_load_config(httpURL);
 	free(httpURL);
+	httpURL=NULL;
 	
-	
-//	if (load_config_params() == -1)
-//	{
-//		check_ota_event();
-//		strcpy(gateway->deviceId, strID);
-//		strcpy(gateway->version, VERSION);
-//		strcpy(gateway->gatewayMode, GATEWAYMODE);
-//		strcpy(gateway->gateName,GATEWAYNAME);
-//		LogPrint(LOG_ERROR, __func__, __LINE__, "No information in flash");
-//		while (1) // flash中不含信息则会等待看门狗
-//			;
-//	}
-	//跳出获取信息循环后重新加载一下网关配置
-	gateway = get_config_params();
-	strcpy(gateway->deviceId, strID);
-	strcpy(gateway->version, VERSION);
-	strcpy(gateway->gatewayMode, GATEWAYMODE);
-	strcpy(gateway->gateName,GATEWAYNAME);
+
+	gateway = get_gateway_config_params();
+ 	strcpy((char *)&gateway->gatewayId, strID);
+	strcpy((char *)&gateway->gatewayMode, GATEWAYMODE);
+	strcpy((char *)&gateway->gateName,GATEWAYNAME);
 	
 	free(strID);
-	protocol = gateway->dataSource;
-	config_485_port(COM_485, gateway->baudrate, gateway->dataBits, gateway->stopBit, gateway->checkBit, gateway->flowControl);
+	
+	config_485_port(COM_485, gateway->baudrate, gateway->dataBits, gateway->stopBit, gateway->checkBit);
 	gd_485_DE_pin_init();
 	gd_485_DE_tx();
+
 	ConnectMQTTSever(gateway->host, gateway->port, 60, gateway->deviceId);
 	MQTTSubTopic(gateway->commandTopic);
 
 	ring_buffer_init(&mqttRecv);
+	mmodbus_init(1);
+	dlt645_init(1);
 
-	switch (gateway->dataSource)
-	{
-		case MODBUS:
-			mmodbus_init(1);
-			break;
-		case DLT645:
-			dlt645_init(1);
-			break;
-		default:
-			LogPrint(LOG_ERROR, __func__, __LINE__, "protocol modbus is 2,dlt645 is 1 ;please check protocol setting");
-			break;
-	}
 	//开启看门狗
-	fwdgt_init();
+//	fwdgt_init();
 	while (1)
 	{
 		check_ota_event();                              //检测是否有ota事件产生
@@ -161,22 +140,14 @@ int main(void)
  *  函数作用:按照设定好时间进行执行,在未到达指定时间之前重复做led反转、MQTT订阅的主题是否有下发主题信息判断
  * 	当time为0时进行数据采集和数据上传
  */
-void MQTT_Alarm_clock(uint32_t time, CONFIG_PARAMS *gateway)
+void MQTT_Alarm_clock(uint32_t time, GATEWAY_PARAMS *gateway)
 {
 	while (1)
 	{
 		if (time <= 0)
 		{
-			switch (gateway->dataSource)
-			{
-			case MODBUS:
-				modbusRead(gateway);
-				break;
-			case DLT645:
-				dlt645_read(gateway);
-				break;
-			}
-			MQTTPublish(gateway);
+			Read_Data();
+			MQTTPublish();
 			break; // 跳出while循环
 		}
 		else
@@ -241,13 +212,15 @@ void http_load_config(uint8_t *httpURL)
 {
 	uint32_t BufferSize=46*1024;//最大获取的数据空间
 	char *dmabuffer=malloc(BufferSize);
+	__LOAD_CONFIG:
 	if (EC800MGetUrl(httpURL,dmabuffer,BufferSize) == true) // 从http获取信息,获取成功则保存到本地
 	{
-		WaitForUpData(dmabuffer);
+		if(WaitForUpData(dmabuffer)==false) goto __LOAD_CONFIG;
 	}
 	else//如果没有从http拉取到配置则直接读取文件系统内的json数据
 	{
 			dma_config_change(dmabuffer,BufferSize);
+			delay_1ms(1000);
 			EC800MSendCmd(CMD_READ_FILE, strlen(CMD_READ_FILE)); //"AT+QFDWL=http.txt\r\n"
 			delay_1ms(3000);
 			WaitForUpData(dmabuffer);

+ 1 - 1
app/App/main.h

@@ -44,7 +44,7 @@ OF SUCH DAMAGE.
 #define GD32_B_PAGE_NUM 24
 #define GD32_A_PAGE_NUM GD32_PAGE_NUM-GD32_B_PAGE_NUM
 
-extern uint8_t protocol; 
+
 void task_fwdgt_reload(void);
 
 

+ 1 - 1
app/App/mmodbus.h

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

文件差异内容过多而无法显示
+ 387 - 502
app/App/parseDeviceMessage.c


+ 6 - 6
app/App/parseDeviceMessage.h

@@ -7,14 +7,14 @@
 #include "dlt645_port.h"
 
 
-#define  MODBUS  2
-#define DLT645   1
+
 
 bool WaitForUpData(char *dmaBuffer);
-void modbusRead(CONFIG_PARAMS * gateway);
+void Read_Data();
 extern ring_buffer mqttRecv;
-void parseMQTTData(CONFIG_PARAMS *gateway);
-void dlt645_read(CONFIG_PARAMS *gateway);
-void MQTTPublish(CONFIG_PARAMS *gateway);
+extern uint8_t protocol;
+void parseMQTTData(GATEWAY_PARAMS *gateway);
+void dlt645_read(GATEWAY_PARAMS *gateway);
+
 //void WaitForUpData232(void);
 #endif /* MAIN_H */

文件差异内容过多而无法显示
+ 451 - 3083
app/Proj/JLinkLog.txt


文件差异内容过多而无法显示
+ 1053 - 1111
app/Proj/Listings/Ringzle.map


+ 12 - 12
app/Proj/Listings/startup_gd32f10x_xd.lst

@@ -85,24 +85,24 @@ ARM Macro Assembler    Page 2
    51 00002000         ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
    52 00002000         ; </h>
    53 00002000         
-   54 00002000 0000C000 
+   54 00002000 00010000 
                        Heap_Size
-                               EQU              0x0000C000
+                               EQU              0x00010000
    55 00002000         
    56 00002000                 AREA             HEAP, NOINIT, READWRITE, ALIGN 
 = 3
    57 00000000         __heap_base
    58 00000000         Heap_Mem
                                SPACE            Heap_Size
-   59 0000C000         __heap_limit
-   60 0000C000         
-   61 0000C000         
-   62 0000C000                 PRESERVE8
-   63 0000C000                 THUMB
-   64 0000C000         
-   65 0000C000         ;                   /* reset Vector Mapped to at Address
+   59 00010000         __heap_limit
+   60 00010000         
+   61 00010000         
+   62 00010000                 PRESERVE8
+   63 00010000                 THUMB
+   64 00010000         
+   65 00010000         ;                   /* reset Vector Mapped to at Address
                         0 */
-   66 0000C000                 AREA             RESET, DATA, READONLY
+   66 00010000                 AREA             RESET, DATA, READONLY
    67 00000000                 EXPORT           __Vectors
    68 00000000                 EXPORT           __Vectors_End
    69 00000000                 EXPORT           __Vectors_Size
@@ -676,7 +676,7 @@ Symbol: __heap_base
    Uses
       At line 351 in file ..\Startup\startup_gd32f10x_xd.s
 Comment: __heap_base used once
-__heap_limit 0000C000
+__heap_limit 00010000
 
 Symbol: __heap_limit
    Definitions
@@ -1437,7 +1437,7 @@ Symbol: WWDGT_IRQHandler
 ARM Macro Assembler    Page 1 Alphabetic symbol ordering
 Absolute symbols
 
-Heap_Size 0000C000
+Heap_Size 00010000
 
 Symbol: Heap_Size
    Definitions

二进制
app/Proj/Objects/Ringzle.axf


二进制
app/Proj/Objects/Ringzle.bin


+ 4 - 318
app/Proj/Objects/Ringzle.build_log.htm

@@ -22,327 +22,13 @@ Dialog DLL:      TCM.DLL V1.36.5.0
  
 <h2>Project:</h2>
 D:\Project\dtu_gateway\app\Proj\Ringzle.uvprojx
-Project File Date:  08/15/2023
+Project File Date:  09/20/2023
 
 <h2>Output:</h2>
 *** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin'
-Rebuild target 'GD32F103C8T6'
-assembling startup_gd32f10x_xd.s...
-compiling gd32f10x_it.c...
-compiling log.c...
-compiling device_message.c...
-..\App\device_message.c(23): warning:  #223-D: function "memset" declared implicitly
-  		memset(&config_params_union, 0, sizeof(CONFIG_PARAMS_UNION));	
-..\App\device_message.c(24): warning:  #223-D: function "memcpy" declared implicitly
-  		memcpy(&config_params_union.config_params, params, sizeof(CONFIG_PARAMS)); 
-..\App\device_message.c(39): warning:  #223-D: function "memset" declared implicitly
-  		memset(&config_params_union, 0, sizeof(CONFIG_PARAMS_UNION));//清空原先数据
-..\App\device_message.c(42): warning:  #223-D: function "memcpy" declared implicitly
-  		memcpy(&g_config_params, &config_params_union.config_params, sizeof(CONFIG_PARAMS));
-..\App\device_message.c: 4 warnings, 0 errors
-compiling main.c...
-..\App\otaEvent.h(26): warning:  #1295-D: Deprecated declaration check_ota_event - give arg types
-  int8_t check_ota_event();
-..\App\main.c(65): warning:  #1295-D: Deprecated declaration fwdgt_init - give arg types
-  void fwdgt_init();
-..\App\main.c(66): warning:  #1295-D: Deprecated declaration task_fwdgt_reload - give arg types
-  void task_fwdgt_reload();
-..\App\main.c(95): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->deviceId, strID);
-..\App\main.c(96): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->version, VERSION);
-..\App\main.c(97): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->gatewayMode, GATEWAYMODE);
-..\App\main.c(98): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->gateName,GATEWAYNAME);
-..\App\main.c(104): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "uint8_t *"
-   	http_load_config(httpURL);
-..\App\main.c(121): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->deviceId, strID);
-..\App\main.c(122): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->version, VERSION);
-..\App\main.c(123): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->gatewayMode, GATEWAYMODE);
-..\App\main.c(124): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	strcpy(gateway->gateName,GATEWAYNAME);
-..\App\main.c(244): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *"
-  	if (EC800MGetUrl(httpURL,dmabuffer,BufferSize) == true) // 从http获取信息,获取成功则保存到本地
-..\App\main.c: 13 warnings, 0 errors
-compiling mmodbus.c...
-compiling system_gd32f10x.c...
-compiling systick.c...
-compiling otaEvent.c...
-..\App\otaEvent.h(26): warning:  #1295-D: Deprecated declaration check_ota_event - give arg types
-  int8_t check_ota_event();
-..\App\otaEvent.c(45): warning:  #940-D: missing return statement at end of non-void function "check_ota_event" 
-  }
-..\App\otaEvent.c(78): warning:  #223-D: function "memcpy" declared implicitly
-  						memcpy(w25q32_data+128,ota_data.data + 3,128);
-..\App\otaEvent.c(80): warning:  #223-D: function "memset" declared implicitly
-  						memset(w25q32_data,0,256);
-..\App\otaEvent.c(84): warning:  #223-D: function "memcpy" declared implicitly
-  						memcpy(w25q32_data,ota_data.data + 3,128);
-..\App\otaEvent.c(88): warning:  #223-D: function "memset" declared implicitly
-  					memset(ota_data.data, 0, 133);
-..\App\otaEvent.c(96): warning:  #223-D: function "memset" declared implicitly
-  					memset(ota_data.data, 0, 133);
-..\App\otaEvent.c(127): warning:  #223-D: function "memset" declared implicitly
-  				memset(ota_data.data, 0, 133);
-..\App\otaEvent.c: 8 warnings, 0 errors
-compiling mqttRecv.c...
-..\App\mqttRecv.c(25): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-          for (; i < strlen(UART0_RX_BUF); i++)
-..\App\mqttRecv.c(71): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-                  strcpy(json, (char *)json_buf); // 将JSON数据拷贝到输出缓冲区中
-..\App\mqttRecv.c: 2 warnings, 0 errors
-compiling gd32f10x_adc.c...
-compiling gd32f10x_bkp.c...
-compiling ec800m.c...
-..\App\ec800m.c(53): warning:  #188-D: enumerated type mixed with another type
-  	bool timeoutFlag = false;
-..\App\ec800m.c(56): warning:  #188-D: enumerated type mixed with another type
-  		timeoutFlag = true;
-..\App\ec800m.c(70): warning:  #188-D: enumerated type mixed with another type
-  				return true;
-..\App\ec800m.c(77): warning:  #188-D: enumerated type mixed with another type
-  			return false;
-..\App\ec800m.c(263): warning:  #223-D: function "sprintf" declared implicitly
-  	sprintf(command, CMD_SET_URL, strlen(url)); // CMD_SET_URL "%d\r\n"
-..\App\ec800m.c(270): warning:  #188-D: enumerated type mixed with another type
-  		return false;
-..\App\ec800m.c(276): warning:  #188-D: enumerated type mixed with another type
-  		return false;
-..\App\ec800m.c(283): warning:  #188-D: enumerated type mixed with another type
-  		return false;
-..\App\ec800m.c(292): warning:  #188-D: enumerated type mixed with another type
-  	return true;
-..\App\ec800m.c(304): warning:  #188-D: enumerated type mixed with another type
-  	bool success = false;
-..\App\ec800m.c(314): warning:  #223-D: function "sprintf" declared implicitly
-  	sprintf(cmd, "AT+QMTCFG=\"qmtping\",0,%d\r\n", keepalive);
-..\App\ec800m.c(502): warning:  #223-D: function "sprintf" declared implicitly
-  	sprintf((char *)payload_out,"{\"deviceId\":\"%s\",\"data\":[",gateway->deviceId);//缁勬垚json澶撮儴
-..\App\ec800m.c(609): warning:  #223-D: function "sprintf" declared implicitly
-  	sprintf(AT_SUB, "AT+QMTSUB=0,1,\"%s\",0\r\n", commandTopic);
-..\App\ec800m.c(610): warning:  #188-D: enumerated type mixed with another type
-  	bool success = false;
-..\App\ec800m.c: 14 warnings, 0 errors
-compiling PC.c...
-..\App\otaEvent.h(26): warning:  #1295-D: Deprecated declaration check_ota_event - give arg types
-  int8_t check_ota_event();
-..\App\PC.c(25): warning:  #1295-D: Deprecated declaration read_json_config - give arg types
-  void read_json_config();
-..\App\PC.c(170): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	uint8_t deviceIdLen=strlen(gateway->deviceId);
-..\App\PC.c(171): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	uint8_t versionLen=strlen(gateway->version);
-..\App\PC.c(176): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	uint16_t CRC16=mmodbus_crc16(gatewayMessageData+1,strlen(gatewayMessageData)-1);
-..\App\PC.c(183): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gd_com_232_send(gatewayMessageData,strlen(gatewayMessageData));
-..\App\PC.c(211): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *restrict"
-  		sscanf(UART0_RX_BUF, "AT+COPS?\r\r\n+COPS: 0,0,\"%[^\"]\",%s", Operators, &Networktyp);
-..\App\PC.c(215): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  		strcpy(Operators,"");																											//鏈��鍙栧埌sim鍗′俊鎭?
-..\App\PC.c(223): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	char* status_str=strstr(UART0_RX_BUF, "+CREG:");
-..\App\PC.c(226): warning:  #181-D: argument is incompatible with corresponding format string conversion
-  		sscanf(status_str, "+CREG: %*d,%d", &Networkstatu);																							//鍘熷厛0鏈�敞鍐? 1娉ㄥ唽锛屽彇鍙嶅悗1鏈�敞鍐?0娉ㄥ唽
-..\App\PC.c(231): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	char* ICCID_str=strstr(UART0_RX_BUF,"+QCCID:");
-..\App\PC.c(239): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *restrict"
-  		sscanf(UART0_RX_BUF,"AT+CSQ\r\r\n+CSQ: %d",&rssi);
-..\App\PC.c(239): warning:  #181-D: argument is incompatible with corresponding format string conversion
-  		sscanf(UART0_RX_BUF,"AT+CSQ\r\r\n+CSQ: %d",&rssi);
-..\App\PC.c(253): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *restrict"
-  	sscanf(UART0_RX_BUF,"AT+GSN\r\r\n%s",IMMIE);
-..\App\PC.c(259): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	sprintf(gatewayConfigData+2,
-..\App\PC.c(264): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	uint16_t CRC16=mmodbus_crc16(gatewayConfigData+1,strlen(gatewayConfigData)-1);
-..\App\PC.c(266): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gatewayConfigData[strlen(gatewayConfigData)+1] = (uint8_t) (CRC16 & 0x00FF);
-..\App\PC.c(267): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gatewayConfigData[strlen(gatewayConfigData)] = (uint8_t) ((CRC16 & 0xFF00)>>8);
-..\App\PC.c(268): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gatewayConfigData[strlen(gatewayConfigData)]=END;
-..\App\PC.c(269): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gd_com_232_send(gatewayConfigData,strlen(gatewayConfigData));
-..\App\PC.c(289): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	sprintf(json_config+2,"{\"host\":\"%s\",\"port\":%d,\"messageTopic\":\"%s\",\"commandTopic\":\"%s\",\"baudrate\":%d,\"dataBit\":%d,\"stopBit\":%d,\"checkBit\":%d,\"flowControl\":%d,\"deviceId\":\"%s\",\"dataSource\":%d,\"version645\":%d,\"inboundTime\":%d,\"pollTime\":%d,",
-..\App\PC.c(306): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	sprintf(json_config+strlen(json_config),"\"sensorData\":[");
-..\App\PC.c(306): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	sprintf(json_config+strlen(json_config),"\"sensorData\":[");
-..\App\PC.c(312): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  			sprintf(json_config+strlen(json_config),"{\"rFunctionCode\":%d,\"registerAddress\":%d,\"slaveAddress\":%d,\"registerByteNum\":%d,\"identifier\":\"%s\",\"deviceId\":\"%s\",\"precise\":%d,\"bigLittleFormat\":%d},",
-..\App\PC.c(312): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  			sprintf(json_config+strlen(json_config),"{\"rFunctionCode\":%d,\"registerAddress\":%d,\"slaveAddress\":%d,\"registerByteNum\":%d,\"identifier\":\"%s\",\"deviceId\":\"%s\",\"precise\":%d,\"bigLittleFormat\":%d},",
-..\App\PC.c(324): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  			sprintf(json_config+strlen(json_config),
-..\App\PC.c(324): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  			sprintf(json_config+strlen(json_config),
-..\App\PC.c(338): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	memset(json_config+strlen(json_config)-1,0,1);
-..\App\PC.c(340): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	sprintf(json_config+strlen(json_config),"],\"commandData\":[");
-..\App\PC.c(340): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	sprintf(json_config+strlen(json_config),"],\"commandData\":[");
-..\App\PC.c(344): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  		sprintf(json_config+strlen(json_config),"{\"deviceId\":\"%s\",\"identifier\":\"%s\",\"registerAddress\":%d,\"slaveAddress\":%d,\"wFunctionCode\":%d,\"registerByteNum\":%d,\"bigLittleFormat\":%d},",
-..\App\PC.c(344): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  		sprintf(json_config+strlen(json_config),"{\"deviceId\":\"%s\",\"identifier\":\"%s\",\"registerAddress\":%d,\"slaveAddress\":%d,\"wFunctionCode\":%d,\"registerByteNum\":%d,\"bigLittleFormat\":%d},",
-..\App\PC.c(354): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	memset(json_config+strlen(json_config)-1,0,1);
-..\App\PC.c(356): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	sprintf(json_config+strlen(json_config),"]}");
-..\App\PC.c(356): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-  	sprintf(json_config+strlen(json_config),"]}");
-..\App\PC.c(358): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	uint16_t CRC16=mmodbus_crc16(json_config+1,strlen(json_config)-1);
-..\App\PC.c(359): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	json_config[strlen(json_config)+1] = (uint8_t) (CRC16 & 0x00FF);
-..\App\PC.c(360): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	json_config[strlen(json_config)] = (uint8_t) ((CRC16 & 0xFF00)>>8);
-..\App\PC.c(362): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	json_config[strlen(json_config)]=END;
-..\App\PC.c(363): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-  	gd_com_232_send(json_config,strlen(json_config));
-..\App\PC.c(382): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const char *"
-  	uint16_t CRC16=mmodbus_crc16(resp+1,strlen(resp)-1);
-..\App\PC.c(382): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const uint8_t *"
-  	uint16_t CRC16=mmodbus_crc16(resp+1,strlen(resp)-1);
-..\App\PC.c(383): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const char *"
-  	resp[strlen(resp)+1] = (uint8_t) (CRC16 & 0x00FF);
-..\App\PC.c(384): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const char *"
-  	resp[strlen(resp)] = (uint8_t) ((CRC16 & 0xFF00)>>8);
-..\App\PC.c(385): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const char *"
-  	resp[strlen(resp)]=END;
-..\App\PC.c(386): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "const char *"
-  	gd_com_232_send(resp,strlen(resp));
-..\App\PC.c(386): warning:  #167-D: argument of type "int8_t *" is incompatible with parameter of type "uint8_t *"
-  	gd_com_232_send(resp,strlen(resp));
-..\App\PC.c(425): warning:  #223-D: function "delay_1ms" declared implicitly
-  		delay_1ms(50);
-..\App\PC.c: 48 warnings, 0 errors
-compiling parseDeviceMessage.c...
-..\App\parseDeviceMessage.c(74): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "const uint8_t *"
-  				processHttp(dmaBuffer);
-..\App\parseDeviceMessage.c(77): warning:  #940-D: missing return statement at end of non-void function "WaitForUpData" 
-  }
-..\App\parseDeviceMessage.c(122): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-    strcpy(gateway.host, processStringData(json, "host"));
-..\App\parseDeviceMessage.c(125): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-    strcpy(gateway.messageTopic, processStringData(json, "messageTopic"));
-..\App\parseDeviceMessage.c(126): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-    strcpy(gateway.commandTopic, processStringData(json, "commandTopic"));
-..\App\parseDeviceMessage.c(147): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-            strcpy(gateway.device_read_data[i].deviceId, processStringData(read_data_obj, "deviceId"));
-..\App\parseDeviceMessage.c(148): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-            strcpy(gateway.device_read_data[i].keyword, processStringData(read_data_obj, "identifier"));
-..\App\parseDeviceMessage.c(159): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-            strcpy(gateway.device_read_data[i].deviceId, processStringData(read_data_obj, "deviceId"));
-..\App\parseDeviceMessage.c(160): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-            strcpy(gateway.device_read_data[i].keyword, processStringData(read_data_obj, "identifier"));
-..\App\parseDeviceMessage.c(183): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-          strcpy(gateway.device_write_data[i].deviceId, processStringData(write_data_obj, "deviceId"));
-..\App\parseDeviceMessage.c(184): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-            strcpy(gateway.device_write_data[i].keyword, processStringData(write_data_obj, "identifier"));
-..\App\parseDeviceMessage.c(212): warning:  #1295-D: Deprecated declaration parseCommandData - give arg types
-  void parseCommandData();
-..\App\parseDeviceMessage.c(363): warning:  #188-D: enumerated type mixed with another type
-  		mmodbus_set16bitOrder(gateway->device_read_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c(417): warning:  #188-D: enumerated type mixed with another type
-  			mmodbus_set16bitOrder(gateway->device_read_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c(424): warning:  #177-D: variable "value"  was declared but never referenced
-          uint32_t value = (uint32_t)data[0] << 8 | data[1];
-..\App\parseDeviceMessage.c(454): warning:  #167-D: argument of type "char *" is incompatible with parameter of type "uint8_t *"
-      while (MQTT_BUFFER_READ(json))
-..\App\parseDeviceMessage.c(462): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-          strcpy(action1, processStringData(mqtt_sub_json, "action"));
-..\App\parseDeviceMessage.c(473): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-          strcpy(identifier, processStringData(mqtt_sub_json, "identifier"));
-..\App\parseDeviceMessage.c(475): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-          strcpy(deviceId, processStringData(mqtt_sub_json, "deviceId"));
-..\App\parseDeviceMessage.c(478): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "char *restrict"
-          strcpy(messageId, processStringData(mqtt_sub_json, "messageId"));
-..\App\parseDeviceMessage.c(486): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-              if (strcmp(gateway->device_write_data[i].deviceId, deviceId) == 0)
-..\App\parseDeviceMessage.c(486): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-              if (strcmp(gateway->device_write_data[i].deviceId, deviceId) == 0)
-..\App\parseDeviceMessage.c(488): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-                if (strcmp(gateway->device_write_data[i].keyword, identifier) == 0) // 瀵绘壘鍒板�搴斿瓨鍌ㄧ殑鍦板潃
-..\App\parseDeviceMessage.c(488): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-                if (strcmp(gateway->device_write_data[i].keyword, identifier) == 0) // 瀵绘壘鍒板�搴斿瓨鍌ㄧ殑鍦板潃
-..\App\parseDeviceMessage.c(494): warning:  #188-D: enumerated type mixed with another type
-                      mmodbus_set16bitOrder(gateway->device_write_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c(516): warning:  #188-D: enumerated type mixed with another type
-                      mmodbus_set16bitOrder(gateway->device_write_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c(556): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-              if (strcmp(gateway->device_read_data[i].deviceId, deviceId) == 0)
-..\App\parseDeviceMessage.c(556): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-              if (strcmp(gateway->device_read_data[i].deviceId, deviceId) == 0)
-..\App\parseDeviceMessage.c(558): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-                if (strcmp(gateway->device_read_data[i].keyword, identifier) == 0) // 瀵绘壘鍒板�搴斿瓨鍌ㄧ殑鍦板潃
-..\App\parseDeviceMessage.c(558): warning:  #167-D: argument of type "uint8_t *" is incompatible with parameter of type "const char *"
-                if (strcmp(gateway->device_read_data[i].keyword, identifier) == 0) // 瀵绘壘鍒板�搴斿瓨鍌ㄧ殑鍦板潃
-..\App\parseDeviceMessage.c(565): warning:  #188-D: enumerated type mixed with another type
-                      mmodbus_set16bitOrder(gateway->device_read_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c(570): warning:  #177-D: variable "value1"  was declared but never referenced
-                      uint8_t value1;
-..\App\parseDeviceMessage.c(600): warning:  #188-D: enumerated type mixed with another type
-                      mmodbus_set16bitOrder(gateway->device_read_data[i].bigLittleFormat);
-..\App\parseDeviceMessage.c: 33 warnings, 0 errors
-compiling gd32f10x_can.c...
-compiling gd32f10x_crc.c...
-compiling gd32f10x_dac.c...
-compiling gd32f10x_enet.c...
-compiling gd32f10x_dbg.c...
-compiling gd32f10x_dma.c...
-compiling gd32f10x_fwdgt.c...
-compiling gd32f10x_exmc.c...
-compiling gd32f10x_exti.c...
-compiling gd32f10x_gpio.c...
-compiling gd32f10x_fmc.c...
-compiling gd32f10x_i2c.c...
-compiling gd32f10x_misc.c...
-compiling gd32f10x_rtc.c...
-compiling gd32f10x_pmu.c...
-compiling gd32f10x_sdio.c...
-compiling gd32f10x_rcu.c...
-compiling spi.c...
-compiling gd32f10x_wwdgt.c...
-compiling usart.c...
-..\bsp\usart.c(27): warning:  #223-D: function "memset" declared implicitly
-     memset(UART0_RX_BUF,0,UART0_RX_LEN);
-..\bsp\usart.c(158): warning:  #550-D: variable "value"  was set but never used
-  	uint8_t value;
-..\bsp\usart.c(13): warning:  #177-D: variable "COM_IT_HANDLER"  was declared but never referenced
-  static uint32_t COM_IT_HANDLER[COMn] = {COM_EC800_IT_HANDLER, COM_485_IT_HANDLER, COM_232_IT_HANDLER};
-..\bsp\usart.c: 3 warnings, 0 errors
-compiling dlt645.c...
-compiling key.c...
-compiling led.c...
-compiling gd32f10x_spi.c...
-compiling gd32f10x_usart.c...
-compiling ring_buffer.c...
-compiling w25q32.c...
-compiling gd32f10x_timer.c...
-compiling dlt645_2007.c...
-compiling dlt645_data.c...
-compiling dlt645_1997.c...
-compiling cJSON.c...
-compiling dlt645_port.c...
-..\dlt\port\dlt645_port.c(84): warning:  #223-D: function "memcpy" declared implicitly
-  			memcpy(msg, &(dlt645_port.rxBuf[4]), len-4);
-..\dlt\port\dlt645_port.c(103): warning:  #223-D: function "memset" declared implicitly
-  	memset(dlt645_port.rxBuf, 0, DLT_RXSIZE);
-..\dlt\port\dlt645_port.c: 2 warnings, 0 errors
-linking...
-Program Size: Code=36448 RO-data=2652 RW-data=224 ZI-data=86992  
-FromELF: creating hex file...
+Build target 'GD32F103C8T6'
 After Build - User command #1: fromelf --bin --output ./Objects/Ringzle.bin ./Objects/Ringzle.axf
-".\Objects\Ringzle.axf" - 0 Error(s), 127 Warning(s).
+".\Objects\Ringzle.axf" - 0 Error(s), 0 Warning(s).
 
 <h2>Software Packages used:</h2>
 
@@ -356,7 +42,7 @@ Package Vendor: GigaDevice
   D:\workSoftware\stm32Software\mdk\mdkpack\GigaDevice\GD32F10x_DFP\2.0.3\Device\Include
 
 <h2>Collection of Component Files used:</h2>
-Build Time Elapsed:  00:00:02
+Build Time Elapsed:  00:00:00
 </pre>
 </body>
 </html>

文件差异内容过多而无法显示
+ 1151 - 1288
app/Proj/Objects/Ringzle.htm


文件差异内容过多而无法显示
+ 94 - 90
app/Proj/Objects/Ringzle_GD32F103C8T6.dep


二进制
app/Proj/Objects/device_message.crf


+ 1 - 1
app/Proj/Objects/device_message.d

@@ -32,4 +32,4 @@
 .\objects\device_message.o: ..\Firmware\Include\gd32f10x_enet.h
 .\objects\device_message.o: D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin\..\include\stdlib.h
 .\objects\device_message.o: ..\Firmware\Include\gd32f10x_misc.h
-.\objects\device_message.o: ..\bsp\w25q32.h
+.\objects\device_message.o: D:\workSoftware\stm32Software\mdk\mdkcore\ARM\ARMCC\Bin\..\include\string.h

二进制
app/Proj/Objects/dlt645_port.crf


二进制
app/Proj/Objects/ec800m.crf


二进制
app/Proj/Objects/gd32f10x_it.crf


+ 3 - 0
app/Proj/Objects/gd32f10x_it.d

@@ -46,3 +46,6 @@
 .\objects\gd32f10x_it.o: ..\App\systick.h
 .\objects\gd32f10x_it.o: ..\dlt\port\dlt645_port.h
 .\objects\gd32f10x_it.o: ..\dlt\inc\dlt645.h
+.\objects\gd32f10x_it.o: ..\App\parseDeviceMessage.h
+.\objects\gd32f10x_it.o: ..\App\device_message.h
+.\objects\gd32f10x_it.o: ..\bsp\ring_buffer.h

二进制
app/Proj/Objects/key.crf


二进制
app/Proj/Objects/log.crf


二进制
app/Proj/Objects/main.crf


二进制
app/Proj/Objects/mmodbus.crf


二进制
app/Proj/Objects/mqttrecv.crf


二进制
app/Proj/Objects/otaevent.crf


二进制
app/Proj/Objects/parsedevicemessage.crf


二进制
app/Proj/Objects/pc.crf


二进制
app/Proj/Objects/ring_buffer.crf


二进制
app/Proj/Objects/usart.crf


文件差异内容过多而无法显示
+ 111 - 84
app/Proj/Ringzle.uvguix.16936


+ 53 - 17
app/Proj/Ringzle.uvoptx

@@ -157,57 +157,73 @@
         <Bp>
           <Number>0</Number>
           <Type>0</Type>
-          <LineNumber>182</LineNumber>
+          <LineNumber>374</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134270766</Address>
+          <Address>134261490</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\PC.c</Filename>
+          <Filename>..\App\parseDeviceMessage.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/PC.c\182</Expression>
+          <Expression>\\Ringzle\../App/parseDeviceMessage.c\374</Expression>
         </Bp>
         <Bp>
           <Number>1</Number>
           <Type>0</Type>
-          <LineNumber>183</LineNumber>
+          <LineNumber>110</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134270776</Address>
+          <Address>134259474</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\PC.c</Filename>
+          <Filename>..\App\main.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/PC.c\183</Expression>
+          <Expression>\\Ringzle\../App/main.c\110</Expression>
         </Bp>
         <Bp>
           <Number>2</Number>
           <Type>0</Type>
-          <LineNumber>27</LineNumber>
+          <LineNumber>149</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>134246942</Address>
+          <Address>134245918</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
           <SizeOfObject>0</SizeOfObject>
           <BreakByAccess>0</BreakByAccess>
           <BreakIfRCount>1</BreakIfRCount>
-          <Filename>..\App\mqttRecv.c</Filename>
+          <Filename>..\App\main.c</Filename>
           <ExecCommand></ExecCommand>
-          <Expression>\\Ringzle\../App/mqttRecv.c\27</Expression>
+          <Expression>\\Ringzle\../App/main.c\149</Expression>
+        </Bp>
+        <Bp>
+          <Number>3</Number>
+          <Type>0</Type>
+          <LineNumber>94</LineNumber>
+          <EnabledFlag>1</EnabledFlag>
+          <Address>134259392</Address>
+          <ByteObject>0</ByteObject>
+          <HtxType>0</HtxType>
+          <ManyObjects>0</ManyObjects>
+          <SizeOfObject>0</SizeOfObject>
+          <BreakByAccess>0</BreakByAccess>
+          <BreakIfRCount>1</BreakIfRCount>
+          <Filename>..\App\main.c</Filename>
+          <ExecCommand></ExecCommand>
+          <Expression>\\Ringzle\../App/main.c\94</Expression>
         </Bp>
       </Breakpoint>
       <MemoryWindow1>
         <Mm>
           <WinNumber>1</WinNumber>
           <SubType>8</SubType>
-          <ItemText>&amp;mqttRecv</ItemText>
+          <ItemText>dmaBuffer</ItemText>
           <AccSizeX>0</AccSizeX>
         </Mm>
       </MemoryWindow1>
@@ -278,7 +294,7 @@
 
   <Group>
     <GroupName>Startup</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -298,7 +314,7 @@
 
   <Group>
     <GroupName>App</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -722,7 +738,7 @@
 
   <Group>
     <GroupName>bsp</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -766,7 +782,7 @@
       <GroupNumber>5</GroupNumber>
       <FileNumber>40</FileNumber>
       <FileType>1</FileType>
-      <tvExp>1</tvExp>
+      <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
       <PathWithFileName>..\bsp\ring_buffer.c</PathWithFileName>
@@ -888,4 +904,24 @@
     </File>
   </Group>
 
+  <Group>
+    <GroupName>JSMN</GroupName>
+    <tvExp>0</tvExp>
+    <tvExpOptDlg>0</tvExpOptDlg>
+    <cbSel>0</cbSel>
+    <RteFlg>0</RteFlg>
+    <File>
+      <GroupNumber>8</GroupNumber>
+      <FileNumber>49</FileNumber>
+      <FileType>5</FileType>
+      <tvExp>0</tvExp>
+      <tvExpOptDlg>0</tvExpOptDlg>
+      <bDave2>0</bDave2>
+      <PathWithFileName>..\jsmn\jsmn.h</PathWithFileName>
+      <FilenameWithoutPath>jsmn.h</FilenameWithoutPath>
+      <RteFlg>0</RteFlg>
+      <bShared>0</bShared>
+    </File>
+  </Group>
+
 </ProjectOpt>

+ 11 - 1
app/Proj/Ringzle.uvprojx

@@ -338,7 +338,7 @@
               <MiscControls></MiscControls>
               <Define>USE_STDPERIPH_DRIVER,GD32F10X_XD</Define>
               <Undefine></Undefine>
-              <IncludePath>..\App;..\CMSIS;..\Firmware\Include;..\bsp;..\internet;..\cjson;..\dlt;..\dlt\inc;..\dlt\port</IncludePath>
+              <IncludePath>..\App;..\CMSIS;..\Firmware\Include;..\bsp;..\internet;..\cjson;..\dlt;..\dlt\inc;..\dlt\port;..\jsmn</IncludePath>
             </VariousControls>
           </Cads>
           <Aads>
@@ -654,6 +654,16 @@
             </File>
           </Files>
         </Group>
+        <Group>
+          <GroupName>JSMN</GroupName>
+          <Files>
+            <File>
+              <FileName>jsmn.h</FileName>
+              <FileType>5</FileType>
+              <FilePath>..\jsmn\jsmn.h</FilePath>
+            </File>
+          </Files>
+        </Group>
       </Groups>
     </Target>
   </Targets>

+ 1 - 1
app/Startup/startup_gd32f10x_xd.s

@@ -51,7 +51,7 @@ __initial_sp
 ;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
 ; </h>
 
-Heap_Size           EQU     0x0000C000
+Heap_Size           EQU     0x00010000
 
                     AREA    HEAP, NOINIT, READWRITE, ALIGN = 3
 __heap_base

+ 1 - 1
app/bsp/key.c

@@ -40,7 +40,7 @@ void EXTI1_IRQHandler(void){
         /* 判断按键是否仍然被按下 */
         if (gpio_input_bit_get(KEY_PORT[0], KEY_PIN[0]) == RESET) {
             /* 执行数据清除操作 */
-            clear_gateway_config_block();
+//            clear_gateway_config_block();
         }
 
         /* 清除EXTI1中断标志 */

+ 1 - 1
app/bsp/usart.c

@@ -275,7 +275,7 @@ void dma_config_change(char *dmaBuffer,uint32_t bufferSize)
  *  返回值:无
  *  函数作用:配置485串口参数
  */
-void config_485_port(uint32_t com,uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity, uint8_t flowcontrol)
+void config_485_port(uint32_t com,uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity)
 {
 	 uint32_t com_id = 0U;
 	 uint8_t wordLength;

+ 1 - 1
app/bsp/usart.h

@@ -90,7 +90,7 @@ extern uint8_t UART0_RX_MQTT_SUB_STAT;
 	
 void gd_com_sendByte( uint8_t com, uint8_t ch);
 void gd_com_send( uint32_t com, uint8_t *Buf,uint16_t size);
-void config_485_port(uint32_t com,uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity, uint8_t flowcontrol);
+void config_485_port(uint32_t com,uint32_t baudrate, uint8_t databits, uint8_t stopbits, uint8_t parity);
 void nvic_config(void);
 void gd_com_232_Receive(void);
 void gd_com_232_send(uint8_t *message,uint16_t size);

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

@@ -101,7 +101,6 @@ static int dlt645_hw_write(dlt645_t *ctx, uint8_t *buf, uint16_t len)
 {
 
 	memset(dlt645_port.rxBuf, 0, DLT_RXSIZE);
-	delay_1ms(50);
 	gpio_bit_set(DLT645_CTRL_GPIO, DLT645_CTRL_PIN);
 	for (uint16_t i = 0; i < len; i++)
 	{

+ 471 - 0
app/jsmn/jsmn.h

@@ -0,0 +1,471 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2010 Serge Zaitsev
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+#ifndef JSMN_H
+#define JSMN_H
+
+#include <stddef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef JSMN_STATIC
+#define JSMN_API static
+#else
+#define JSMN_API extern
+#endif
+
+/**
+ * JSON type identifier. Basic types are:
+ * 	o Object
+ * 	o Array
+ * 	o String
+ * 	o Other primitive: number, boolean (true/false) or null
+ */
+typedef enum {
+  JSMN_UNDEFINED = 0,
+  JSMN_OBJECT = 1 << 0,
+  JSMN_ARRAY = 1 << 1,
+  JSMN_STRING = 1 << 2,
+  JSMN_PRIMITIVE = 1 << 3
+} jsmntype_t;
+
+enum jsmnerr {
+  /* Not enough tokens were provided */
+  JSMN_ERROR_NOMEM = -1,
+  /* Invalid character inside JSON string */
+  JSMN_ERROR_INVAL = -2,
+  /* The string is not a full JSON packet, more bytes expected */
+  JSMN_ERROR_PART = -3
+};
+
+/**
+ * JSON token description.
+ * type		type (object, array, string etc.)
+ * start	start position in JSON data string
+ * end		end position in JSON data string
+ */
+typedef struct jsmntok {
+  jsmntype_t type;
+  int start;
+  int end;
+  int size;
+#ifdef JSMN_PARENT_LINKS
+  int parent;
+#endif
+} jsmntok_t;
+
+/**
+ * JSON parser. Contains an array of token blocks available. Also stores
+ * the string being parsed now and current position in that string.
+ */
+typedef struct jsmn_parser {
+  unsigned int pos;     /* offset in the JSON string */
+  unsigned int toknext; /* next token to allocate */
+  int toksuper;         /* superior token node, e.g. parent object or array */
+} jsmn_parser;
+
+/**
+ * Create JSON parser over an array of tokens
+ */
+JSMN_API void jsmn_init(jsmn_parser *parser);
+
+/**
+ * Run JSON parser. It parses a JSON data string into and array of tokens, each
+ * describing
+ * a single JSON object.
+ */
+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                        jsmntok_t *tokens, const unsigned int num_tokens);
+
+#ifndef JSMN_HEADER
+/**
+ * Allocates a fresh unused token from the token pool.
+ */
+static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens,
+                                   const size_t num_tokens) {
+  jsmntok_t *tok;
+  if (parser->toknext >= num_tokens) {
+    return NULL;
+  }
+  tok = &tokens[parser->toknext++];
+  tok->start = tok->end = -1;
+  tok->size = 0;
+#ifdef JSMN_PARENT_LINKS
+  tok->parent = -1;
+#endif
+  return tok;
+}
+
+/**
+ * Fills token type and boundaries.
+ */
+static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type,
+                            const int start, const int end) {
+  token->type = type;
+  token->start = start;
+  token->end = end;
+  token->size = 0;
+}
+
+/**
+ * Fills next available token with JSON primitive.
+ */
+static int jsmn_parse_primitive(jsmn_parser *parser, const char *js,
+                                const size_t len, jsmntok_t *tokens,
+                                const size_t num_tokens) {
+  jsmntok_t *token;
+  int start;
+
+  start = parser->pos;
+
+  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    switch (js[parser->pos]) {
+#ifndef JSMN_STRICT
+    /* In strict mode primitive must be followed by "," or "}" or "]" */
+    case ':':
+#endif
+    case '\t':
+    case '\r':
+    case '\n':
+    case ' ':
+    case ',':
+    case ']':
+    case '}':
+      goto found;
+    default:
+                   /* to quiet a warning from gcc*/
+      break;
+    }
+    if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
+      parser->pos = start;
+      return JSMN_ERROR_INVAL;
+    }
+  }
+#ifdef JSMN_STRICT
+  /* In strict mode primitive must be followed by a comma/object/array */
+  parser->pos = start;
+  return JSMN_ERROR_PART;
+#endif
+
+found:
+  if (tokens == NULL) {
+    parser->pos--;
+    return 0;
+  }
+  token = jsmn_alloc_token(parser, tokens, num_tokens);
+  if (token == NULL) {
+    parser->pos = start;
+    return JSMN_ERROR_NOMEM;
+  }
+  jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+  token->parent = parser->toksuper;
+#endif
+  parser->pos--;
+  return 0;
+}
+
+/**
+ * Fills next token with JSON string.
+ */
+static int jsmn_parse_string(jsmn_parser *parser, const char *js,
+                             const size_t len, jsmntok_t *tokens,
+                             const size_t num_tokens) {
+  jsmntok_t *token;
+
+  int start = parser->pos;
+  
+  /* Skip starting quote */
+  parser->pos++;
+  
+  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    char c = js[parser->pos];
+
+    /* Quote: end of string */
+    if (c == '\"') {
+      if (tokens == NULL) {
+        return 0;
+      }
+      token = jsmn_alloc_token(parser, tokens, num_tokens);
+      if (token == NULL) {
+        parser->pos = start;
+        return JSMN_ERROR_NOMEM;
+      }
+      jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos);
+#ifdef JSMN_PARENT_LINKS
+      token->parent = parser->toksuper;
+#endif
+      return 0;
+    }
+
+    /* Backslash: Quoted symbol expected */
+    if (c == '\\' && parser->pos + 1 < len) {
+      int i;
+      parser->pos++;
+      switch (js[parser->pos]) {
+      /* Allowed escaped symbols */
+      case '\"':
+      case '/':
+      case '\\':
+      case 'b':
+      case 'f':
+      case 'r':
+      case 'n':
+      case 't':
+        break;
+      /* Allows escaped symbol \uXXXX */
+      case 'u':
+        parser->pos++;
+        for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0';
+             i++) {
+          /* If it isn't a hex character we have an error */
+          if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) ||   /* 0-9 */
+                (js[parser->pos] >= 65 && js[parser->pos] <= 70) ||   /* A-F */
+                (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */
+            parser->pos = start;
+            return JSMN_ERROR_INVAL;
+          }
+          parser->pos++;
+        }
+        parser->pos--;
+        break;
+      /* Unexpected symbol */
+      default:
+        parser->pos = start;
+        return JSMN_ERROR_INVAL;
+      }
+    }
+  }
+  parser->pos = start;
+  return JSMN_ERROR_PART;
+}
+
+/**
+ * Parse JSON string and fill tokens.
+ */
+JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len,
+                        jsmntok_t *tokens, const unsigned int num_tokens) {
+  int r;
+  int i;
+  jsmntok_t *token;
+  int count = parser->toknext;
+
+  for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) {
+    char c;
+    jsmntype_t type;
+
+    c = js[parser->pos];
+    switch (c) {
+    case '{':
+    case '[':
+      count++;
+      if (tokens == NULL) {
+        break;
+      }
+      token = jsmn_alloc_token(parser, tokens, num_tokens);
+      if (token == NULL) {
+        return JSMN_ERROR_NOMEM;
+      }
+      if (parser->toksuper != -1) {
+        jsmntok_t *t = &tokens[parser->toksuper];
+#ifdef JSMN_STRICT
+        /* In strict mode an object or array can't become a key */
+        if (t->type == JSMN_OBJECT) {
+          return JSMN_ERROR_INVAL;
+        }
+#endif
+        t->size++;
+#ifdef JSMN_PARENT_LINKS
+        token->parent = parser->toksuper;
+#endif
+      }
+      token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY);
+      token->start = parser->pos;
+      parser->toksuper = parser->toknext - 1;
+      break;
+    case '}':
+    case ']':
+      if (tokens == NULL) {
+        break;
+      }
+      type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY);
+#ifdef JSMN_PARENT_LINKS
+      if (parser->toknext < 1) {
+        return JSMN_ERROR_INVAL;
+      }
+      token = &tokens[parser->toknext - 1];
+      for (;;) {
+        if (token->start != -1 && token->end == -1) {
+          if (token->type != type) {
+            return JSMN_ERROR_INVAL;
+          }
+          token->end = parser->pos + 1;
+          parser->toksuper = token->parent;
+          break;
+        }
+        if (token->parent == -1) {
+          if (token->type != type || parser->toksuper == -1) {
+            return JSMN_ERROR_INVAL;
+          }
+          break;
+        }
+        token = &tokens[token->parent];
+      }
+#else
+      for (i = parser->toknext - 1; i >= 0; i--) {
+        token = &tokens[i];
+        if (token->start != -1 && token->end == -1) {
+          if (token->type != type) {
+            return JSMN_ERROR_INVAL;
+          }
+          parser->toksuper = -1;
+          token->end = parser->pos + 1;
+          break;
+        }
+      }
+      /* Error if unmatched closing bracket */
+      if (i == -1) {
+        return JSMN_ERROR_INVAL;
+      }
+      for (; i >= 0; i--) {
+        token = &tokens[i];
+        if (token->start != -1 && token->end == -1) {
+          parser->toksuper = i;
+          break;
+        }
+      }
+#endif
+      break;
+    case '\"':
+      r = jsmn_parse_string(parser, js, len, tokens, num_tokens);
+      if (r < 0) {
+        return r;
+      }
+      count++;
+      if (parser->toksuper != -1 && tokens != NULL) {
+        tokens[parser->toksuper].size++;
+      }
+      break;
+    case '\t':
+    case '\r':
+    case '\n':
+    case ' ':
+      break;
+    case ':':
+      parser->toksuper = parser->toknext - 1;
+      break;
+    case ',':
+      if (tokens != NULL && parser->toksuper != -1 &&
+          tokens[parser->toksuper].type != JSMN_ARRAY &&
+          tokens[parser->toksuper].type != JSMN_OBJECT) {
+#ifdef JSMN_PARENT_LINKS
+        parser->toksuper = tokens[parser->toksuper].parent;
+#else
+        for (i = parser->toknext - 1; i >= 0; i--) {
+          if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) {
+            if (tokens[i].start != -1 && tokens[i].end == -1) {
+              parser->toksuper = i;
+              break;
+            }
+          }
+        }
+#endif
+      }
+      break;
+#ifdef JSMN_STRICT
+    /* In strict mode primitives are: numbers and booleans */
+    case '-':
+    case '0':
+    case '1':
+    case '2':
+    case '3':
+    case '4':
+    case '5':
+    case '6':
+    case '7':
+    case '8':
+    case '9':
+    case 't':
+    case 'f':
+    case 'n':
+      /* And they must not be keys of the object */
+      if (tokens != NULL && parser->toksuper != -1) {
+        const jsmntok_t *t = &tokens[parser->toksuper];
+        if (t->type == JSMN_OBJECT ||
+            (t->type == JSMN_STRING && t->size != 0)) {
+          return JSMN_ERROR_INVAL;
+        }
+      }
+#else
+    /* In non-strict mode every unquoted value is a primitive */
+    default:
+#endif
+      r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens);
+      if (r < 0) {
+        return r;
+      }
+      count++;
+      if (parser->toksuper != -1 && tokens != NULL) {
+        tokens[parser->toksuper].size++;
+      }
+      break;
+
+#ifdef JSMN_STRICT
+    /* Unexpected char in strict mode */
+    default:
+      return JSMN_ERROR_INVAL;
+#endif
+    }
+  }
+
+  if (tokens != NULL) {
+    for (i = parser->toknext - 1; i >= 0; i--) {
+      /* Unmatched opened object or array */
+      if (tokens[i].start != -1 && tokens[i].end == -1) {
+        return JSMN_ERROR_PART;
+      }
+    }
+  }
+
+  return count;
+}
+
+/**
+ * Creates a new parser based over a given buffer with an array of tokens
+ * available.
+ */
+JSMN_API void jsmn_init(jsmn_parser *parser) {
+  parser->pos = 0;
+  parser->toknext = 0;
+  parser->toksuper = -1;
+}
+
+#endif /* JSMN_HEADER */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* JSMN_H */

+ 1 - 1
bootloader/OBJ/bootloader.build_log.htm

@@ -41,7 +41,7 @@ Package Vendor: GigaDevice
   D:\workSoftware\stm32Software\mdk\mdkpack\GigaDevice\GD32F10x_DFP\2.0.3\Device\Include
 
 <h2>Collection of Component Files used:</h2>
-Build Time Elapsed:  00:00:01
+Build Time Elapsed:  00:00:00
 </pre>
 </body>
 </html>

文件差异内容过多而无法显示
+ 517 - 529
bootloader/USER/JLinkLog.txt


文件差异内容过多而无法显示
+ 34 - 25
bootloader/USER/bootloader.uvguix.16936


+ 1 - 1
bootloader/USER/bootloader.uvoptx

@@ -341,7 +341,7 @@
       <GroupNumber>3</GroupNumber>
       <FileNumber>10</FileNumber>
       <FileType>1</FileType>
-      <tvExp>1</tvExp>
+      <tvExp>0</tvExp>
       <tvExpOptDlg>0</tvExpOptDlg>
       <bDave2>0</bDave2>
       <PathWithFileName>..\LIB\Source\gd32f10x_wwdgt.c</PathWithFileName>

+ 4 - 0
版本信息.txt

@@ -0,0 +1,4 @@
+1.1.0
+修改整体格式层级关系,
+以及减小dma空间占用量瞬时大空间获取后释放
+修改