|  | @@ -39,10 +39,10 @@ uint8_t PongMsg[] = "PONG\0";
 | 
	
		
			
				|  |  |  tRadioDriver *Radio=NULL;
 | 
	
		
			
				|  |  |  /*
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  | -*	º¯ Êý Ãû: void data_task(void *pdata)
 | 
	
		
			
				|  |  | -*	¹¦ÄÜ˵Ã÷: Ö÷ÒªÊÇdata_task´¦ÀíỊ̈߳¬ÓÅÏȼ¶¸ß¡£ÆäÔËÐÐÂß¼Êǽ«nandflashÖеÄÊý¾Ý½âÎö³öÀ´ÂÖѯ·¢ËÍÊý¾Ý
 | 
	
		
			
				|  |  | -*	ÐÎ    ²Î£ºÎÞ
 | 
	
		
			
				|  |  | -*	·µ »Ø Öµ: ÎÞ
 | 
	
		
			
				|  |  | +*	函 数 �: void data_task(void *pdata)
 | 
	
		
			
				|  |  | +*	功能说明: 主è¦�是data_task处ç�†çº¿ç¨‹ï¼Œä¼˜å…ˆçº§é«˜ã€‚å…¶è¿�行逻辑是将nandflashä¸çš„æ•°æ�®è§£æž�出æ�¥è½®è¯¢å�‘é€�æ•°æ�®
 | 
	
		
			
				|  |  | +*	形    �:无
 | 
	
		
			
				|  |  | +*	返 回 值: 无
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -79,7 +79,7 @@ GATEWAY_PARAMS *get;
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  |  	while (current_device!=NULL)
 | 
	
		
			
				|  |  |  	{		
 | 
	
		
			
				|  |  | -		char buf[1000];	// ½ÓÊÕmodbus¶ÁÈ¡µÄÊý¾Ý	
 | 
	
		
			
				|  |  | +		char buf[1000];	// 接收modbus读�的数�	
 | 
	
		
			
				|  |  |  		READ_MODBUS_DATA(current_device, buf);		
 | 
	
		
			
				|  |  |  		if(current_device->nextDevice!=NULL) 
 | 
	
		
			
				|  |  |  		{
 | 
	
	
		
			
				|  | @@ -92,14 +92,14 @@ GATEWAY_PARAMS *get;
 | 
	
		
			
				|  |  |  				if( jsoncunt || time2  <= time1 - 10000)
 | 
	
		
			
				|  |  |  				{
 | 
	
		
			
				|  |  |  					memset(pubJsonStringCopy,0, strlen(pubJsonStringCopy));
 | 
	
		
			
				|  |  | -					memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//±¸·ÝÉÏÒ»´ÎµÄÊý¾Ý
 | 
	
		
			
				|  |  | +					memcpy(pubJsonStringCopy + strlen(pubJsonStringCopy), buf, strlen(buf));//备份上一次的数�
 | 
	
		
			
				|  |  |  					sprintf(pubJsonString,"{\"DEVICEID\":\"%s\",\"data\":[%s]",get->deviceId, buf);									
 | 
	
		
			
				|  |  |  					int msg = MBOX_USER_PUBLISHQOS2;	
 | 
	
		
			
				|  |  |  					if(mqtt_connectFlag==1) OSMboxPost(mqtt_sendMseeageMbox, &msg);
 | 
	
		
			
				|  |  |  					current_device=get->device_params;
 | 
	
		
			
				|  |  |  					jsoncunt = 0;
 | 
	
		
			
				|  |  |  					time2 = OSTimeGet();
 | 
	
		
			
				|  |  | -				}//10s½øÐÐÒ»´Î
 | 
	
		
			
				|  |  | +				}//10s进行一次
 | 
	
		
			
				|  |  |  				
 | 
	
		
			
				|  |  |  				else
 | 
	
		
			
				|  |  |  				{
 | 
	
	
		
			
				|  | @@ -122,7 +122,7 @@ GATEWAY_PARAMS *get;
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	#if 0   //²âÊÔ´úÂë²»¾¹ýת·¢Ö±½Ó½øÐÐÏàÓ¦µÄ½âÎö
 | 
	
		
			
				|  |  | +	#if 0   //测试代���过转�直接进行相应的解�
 | 
	
		
			
				|  |  |  			SlaveProtocolAnalysis(string,bufferLength);
 | 
	
		
			
				|  |  |  			data_acquisition();
 | 
	
		
			
				|  |  |  			uint8_t node_string[256];
 | 
	
	
		
			
				|  | @@ -133,10 +133,10 @@ GATEWAY_PARAMS *get;
 | 
	
		
			
				|  |  |   
 | 
	
		
			
				|  |  |  /*
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  | -*	º¯ Êý Ãû: int READ_MODBUS_DATA(DEVICE_PARAMS *device)
 | 
	
		
			
				|  |  | -*	¹¦ÄÜ˵Ã÷: ¶ÁÈ¡µ±Ç°½ÚµãÉϵÄmodbusÊý¾Ý
 | 
	
		
			
				|  |  | -*	ÐÎ    ²Î£ºDEVICE_PARAMS *device  µ±Ç°É豸
 | 
	
		
			
				|  |  | -*	·µ »Ø Öµ:  1 £º³É¹¦  0£ºÊ§°Ü
 | 
	
		
			
				|  |  | +*	函 数 �: int READ_MODBUS_DATA(DEVICE_PARAMS *device)
 | 
	
		
			
				|  |  | +*	功能说明: 读�当�节点上的modbus数�
 | 
	
		
			
				|  |  | +*	形    �:DEVICE_PARAMS *device  当�设备
 | 
	
		
			
				|  |  | +*	返 回 值:  1 :�功  0:失败
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -152,7 +152,7 @@ int READ_MODBUS_DATA(DEVICE_PARAMS *device, char* buf)
 | 
	
		
			
				|  |  |  			if (current_device->protocol == MODBUS_READ)
 | 
	
		
			
				|  |  |  			{
 | 
	
		
			
				|  |  |  				protocol_485=1;
 | 
	
		
			
				|  |  | -				uint16_t data[currentModbusParams->registerByteNum /2]; // modbus¼Ä´æÆ÷³¤¶È
 | 
	
		
			
				|  |  | +				uint16_t data[currentModbusParams->registerByteNum /2]; // modbus寄å˜å™¨é•¿åº¦
 | 
	
		
			
				|  |  |  				mmodbus_set16bitOrder(current_device->MDBbigLittleFormat);
 | 
	
		
			
				|  |  |  				if (currentModbusParams->functionCode == 0x03 | currentModbusParams->functionCode == 0x01)
 | 
	
		
			
				|  |  |  				{
 | 
	
	
		
			
				|  | @@ -200,10 +200,10 @@ int READ_MODBUS_DATA(DEVICE_PARAMS *device, char* buf)
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  	/*
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  | -*	º¯ Êý Ãû:void WRITE_MODBUS_DATA(char* cJSONstring)
 | 
	
		
			
				|  |  | -*	¹¦ÄÜ˵Ã÷: ½ÓÊÕmqttÊý¾Ý²¢Ð´Èëmodbus¼Ä´æÆ÷
 | 
	
		
			
				|  |  | -*	ÐÎ    ²Î£ºchar* cJSONstring mqtt½ÓÊÕµ½µÄÊý¾Ý
 | 
	
		
			
				|  |  | -*	·µ »Ø Öµ: ÎÞ
 | 
	
		
			
				|  |  | +*	函 数 �:void WRITE_MODBUS_DATA(char* cJSONstring)
 | 
	
		
			
				|  |  | +*	功能说明: 接收mqttæ•°æ�®å¹¶å†™å…¥modbus寄å˜å™¨
 | 
	
		
			
				|  |  | +*	形    �:char* cJSONstring mqtt接收到的数�
 | 
	
		
			
				|  |  | +*	返 回 值: 无
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  |  void WRITE_MODBUS_DATA(char* cJSONstring)
 | 
	
	
		
			
				|  | @@ -271,7 +271,7 @@ void WRITE_MODBUS_DATA(char* cJSONstring)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -// ±È½ÏÁ½¸ö JSONItem Êý×飬ÕÒµ½±ä»¯µÄ²¿·Ö²¢´òÓ¡
 | 
	
		
			
				|  |  | +// 比较两个 JSONItem 数组,找到�化的部分
 | 
	
		
			
				|  |  |  void  findDifference(char* buf, char* pubJsonStringCopy, char* string) 
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |      const char* delimiter = "{}";
 | 
	
	
		
			
				|  | @@ -281,7 +281,7 @@ void  findDifference(char* buf, char* pubJsonStringCopy, char* string)
 | 
	
		
			
				|  |  |  		char* data2 = malloc(strlen(pubJsonStringCopy) + 1);	;
 | 
	
		
			
				|  |  |  		memcpy(data1, buf, strlen(buf));
 | 
	
		
			
				|  |  |  		memcpy(data2, pubJsonStringCopy, strlen(pubJsonStringCopy));
 | 
	
		
			
				|  |  | -    // ÀûÓÃstrtok_rº¯Êý·Ö¸î×Ö·û´®£¬²¢ÖðÒ»±È½Ï
 | 
	
		
			
				|  |  | +    // 利用strtok_r函数分割å—符串,并é€�一比较
 | 
	
		
			
				|  |  |      char* token1 = strtok_r((char*)data1, delimiter, &saveptr1);
 | 
	
		
			
				|  |  |      char* token2 = strtok_r((char*)data2, delimiter, &saveptr2);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -293,7 +293,7 @@ void  findDifference(char* buf, char* pubJsonStringCopy, char* string)
 | 
	
		
			
				|  |  |          token2 = strtok_r(NULL, delimiter, &saveptr2);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//    // Èç¹ûÓÐÊ£Óà×Ö·û´®Î´±È½Ï£¬Ôò´òÓ¡Ê£Óà×Ö·û´®
 | 
	
		
			
				|  |  | +//    // 如果有剩余å—符串未比较,则打å�°å‰©ä½™å—符串
 | 
	
		
			
				|  |  |  //    while (token1 != NULL) {
 | 
	
		
			
				|  |  |  //        sprintf(string + strlen(string),"%s,", token1);
 | 
	
		
			
				|  |  |  //        token1 = strtok_r(NULL, delimiter, &saveptr1);
 |