| | |
| | | public void run() {
|
| | | while (true) {
|
| | | try {
|
| | | Thread.sleep(1000);
|
| | | Thread.sleep(5000);
|
| | | // LogUtils.i("checkIfCertified=" + HDLLink.getInstance().checkIfCertified() + " getTcp().connected=" + getTcp().connected);
|
| | | try {
|
| | | if (!HDLLink.getInstance().checkIfCertified() || (!TextUtils.isEmpty(getTcpIp()) && getTcp().connected)) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public SocketBoot getTcp() throws RuntimeException {
|
| | | if (TextUtils.isEmpty(getTcpIp())) {
|
| | | public synchronized SocketBoot getTcp() throws RuntimeException {
|
| | | String gatewayIpAddress=getTcpIp();
|
| | | if (TextUtils.isEmpty(gatewayIpAddress)) {
|
| | | LogUtils.e("请搜索网关");
|
| | | throw new RuntimeException("请搜索网关");
|
| | | }
|
| | | //如果没有初始化,或者网关IP更改了,就重新初始化
|
| | | if (tcpBoot == null || !getTcpOptions().getIp().equals(getTcpIp())) {
|
| | | tcpBoot = TcpClient.init(getTcpIp(), getTcpPort(), getTcpOptions());
|
| | | if (tcpBoot == null || !getTcpOptions().getIp().equals(gatewayIpAddress)) {
|
| | | tcpBoot = TcpClient.init(gatewayIpAddress, getTcpPort(), getTcpOptions());
|
| | | tcpBoot.SetHeartbeat(new IHeartbeat() {
|
| | | @Override
|
| | | public void heartbeat() {
|