예제 #1
0
void LeweiTcpClient::connentTcpServer()
{
	bIsConnecting = true;
	Serial.print("connecting...");
	
	_clientRevCtrl.stop();
	if (_clientRevCtrl.connect(tcpServer, 9960))
	{
		Serial.println("connected");
		//delay(800);
		sendOnlineCommand();
		/*
		String connStr = "{\"method\":\"update\",\"gatewayNo\":\""+String(_gatewayNo)+"\",\"userkey\":\""+String(_userKey)+"\"}&^!";
		char* c = (char*)malloc(connStr.length()+1);
		connStr.toCharArray(c,connStr.length()+1);
		_clientRevCtrl.print(c);
		free(c);
		c = NULL;
		connStr = "";
		*/
		
	}
	else 
	{
		_clientRevCtrl.stop();
		// if you didn't get a connection to the server:
		
		Serial.println("connect failed");
		Serial.println(_clientRevCtrl.status());
	}
	bIsConnecting = false;
}
예제 #2
0
void LeweiTcpClient::keepOnline()
{
	getResponse();
		if (_clientRevCtrl.connected()) 
		{
			if ((millis()-_starttime) > _postInterval)
			{
				_starttime = millis();
					sendOnlineCommand();
			}
		}
		else
		{
			if(!bIsConnecting)
			{
				connentTcpServer();
			}
		}
		/*
		if (_clientRevCtrl.connected()) 
		{
		}
		else
		{
			Serial.println("keepOnline::disconnected...reconnect");
			Serial.println(_clientRevCtrl.status());
			delay(1000);
			connentTcpServer();
		}
		*/
}
예제 #3
0
void LeweiTcpClient::keepOnline()
{
	getResponse();
	if ((millis()-_starttime) > _postInterval)
	{
		_starttime = millis();
			sendOnlineCommand();
	}
}
예제 #4
0
void LeweiTcpClient::connentTcpServer()
{
	Serial.print("Connect");
	
	_clientRevCtrl.stop();
	if (_clientRevCtrl.connect(tcpServer, 9960))
	{
		Serial.println("ed");
		sendOnlineCommand();		
	}
	else 
	{
		_clientRevCtrl.stop();
		// if you didn't get a connection to the server:
		
		Serial.println("Fail");
	}
}
예제 #5
0
void LeweiTcpClient::keepOnline()
{
	getResponse();
	
	if(_bEasyMode)
	{
		listenServer();
	}
		if (_clientRevCtrl.connected()) 
		{
			if ((millis()-_starttime) > _postInterval)
			{
				_starttime = millis();
					sendOnlineCommand();
			}
		}
		else
		{
			connentTcpServer();
		}
}