|  | @@ -223,59 +223,63 @@ int READ_MODBUS_DATA(DEVICE_PARAMS *device)
 | 
	
		
			
				|  |  |  *	�� �� ֵ: ��
 | 
	
		
			
				|  |  |  *********************************************************************************************************
 | 
	
		
			
				|  |  |  */
 | 
	
		
			
				|  |  | -void WRITE_MODBUS_DATA(char* cJSONstring){
 | 
	
		
			
				|  |  | +void WRITE_MODBUS_DATA(char* cJSONstring)
 | 
	
		
			
				|  |  | +{
 | 
	
		
			
				|  |  | +	uint16_t data;
 | 
	
		
			
				|  |  | +	uint16_t number;
 | 
	
		
			
				|  |  | +	uint16_t slaveAddress;
 | 
	
		
			
				|  |  | +	
 | 
	
		
			
				|  |  |  	GATEWAY_PARAMS* get;
 | 
	
		
			
				|  |  |  	get = get_gateway_config_params();
 | 
	
		
			
				|  |  |  	DEVICE_PARAMS* current_device = get->device_params;
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  |  	cJSON *root = cJSON_Parse(cJSONstring);
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  |  	const char *deviceId = cJSON_GetStringValue(cJSON_GetObjectItem(root, "deviceId"));	
 | 
	
		
			
				|  |  |  	const cJSON *power = cJSON_GetObjectItemCaseSensitive(root, "power");
 | 
	
		
			
				|  |  |  	const cJSON *temp = cJSON_GetObjectItemCaseSensitive(root, "temp");
 | 
	
		
			
				|  |  |  	const cJSON *mode = cJSON_GetObjectItemCaseSensitive(root, "mode");
 | 
	
		
			
				|  |  |  	const cJSON *fan = cJSON_GetObjectItemCaseSensitive(root, "fan");
 | 
	
		
			
				|  |  |  	
 | 
	
		
			
				|  |  | -	uint16_t slaveAddress;
 | 
	
		
			
				|  |  | -	uint16_t number;
 | 
	
		
			
				|  |  | -	uint16_t data;
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  |  	while(current_device)
 | 
	
		
			
				|  |  |  	{
 | 
	
		
			
				|  |  |  		char* device_ID = (char*)current_device->deviceID;
 | 
	
		
			
				|  |  |  		GATEWAY_WRITE_MODBUS_COMMAND *currentModbusParams = current_device->params->gateway_write_modbus_command;
 | 
	
		
			
				|  |  | -		if(!strcmp(device_ID,deviceId)){
 | 
	
		
			
				|  |  | +		if(!strcmp(device_ID,deviceId))
 | 
	
		
			
				|  |  | +		{
 | 
	
		
			
				|  |  |  			OSTimeDlyHMSM(0, 0, 0, 60);
 | 
	
		
			
				|  |  |  			OSIntEnter();
 | 
	
		
			
				|  |  | -			if(power){
 | 
	
		
			
				|  |  | -					slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | -					number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | -					data = power->valueint;
 | 
	
		
			
				|  |  | -					mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  | +			if(power)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | +				number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | +				data = power->valueint;
 | 
	
		
			
				|  |  | +				mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -			if(temp){
 | 
	
		
			
				|  |  | -					currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | -					slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | -					number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | -					data = temp->valueint;
 | 
	
		
			
				|  |  | -					mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  | +			if(temp)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | +				slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | +				number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | +				data = temp->valueint;
 | 
	
		
			
				|  |  | +				mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -			if(mode){
 | 
	
		
			
				|  |  | -					currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | -					slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | -					number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | -					data = mode->valueint;
 | 
	
		
			
				|  |  | -					mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  | +			if(mode)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | +				slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | +				number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | +				data = mode->valueint;
 | 
	
		
			
				|  |  | +				mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -			if(fan){
 | 
	
		
			
				|  |  | -					currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | -					slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | -					number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | -					data = fan->valueint;
 | 
	
		
			
				|  |  | -					mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  | +			if(fan)
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				currentModbusParams = currentModbusParams->nextParams;
 | 
	
		
			
				|  |  | +				slaveAddress = currentModbusParams->slaveAddress;
 | 
	
		
			
				|  |  | +				number =currentModbusParams->registerAddress;
 | 
	
		
			
				|  |  | +				data = fan->valueint;
 | 
	
		
			
				|  |  | +				mmodbus_writeHoldingRegister16i(slaveAddress, number, data);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			OSIntExit();
 |