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; }
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(); } */ }
void LeweiTcpClient::keepOnline() { getResponse(); if ((millis()-_starttime) > _postInterval) { _starttime = millis(); sendOnlineCommand(); } }
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"); } }
void LeweiTcpClient::keepOnline() { getResponse(); if(_bEasyMode) { listenServer(); } if (_clientRevCtrl.connected()) { if ((millis()-_starttime) > _postInterval) { _starttime = millis(); sendOnlineCommand(); } } else { connentTcpServer(); } }