diff --git a/gradle.properties b/gradle.properties index 4680ae2..8035280 100644 --- a/gradle.properties +++ b/gradle.properties @@ -36,26 +36,26 @@ PASSWORD=xintai2018 RELEASE=true # AI CLOUD 云平台 # 工具类 -MOGO_UTILS_VERSION=1.3.58 +MOGO_UTILS_VERSION=1.3.59 # 网络请求 -MOGO_NETWORK_VERSION=1.3.58 +MOGO_NETWORK_VERSION=1.3.59 # 网络DNS -MOGO_HTTPDNS_VERSION=1.3.58 +MOGO_HTTPDNS_VERSION=1.3.59 # 鉴权 -MOGO_PASSPORT_VERSION=1.3.58 +MOGO_PASSPORT_VERSION=1.3.59 # 常链接 -MOGO_SOCKET_VERSION=1.3.58 +MOGO_SOCKET_VERSION=1.3.59 # 数据采集 -MOGO_REALTIME_VERSION=1.3.58 +MOGO_REALTIME_VERSION=1.3.59 # 探路,道路事件发布,获取 -MOGO_TANLU_VERSION=1.3.58 +MOGO_TANLU_VERSION=1.3.59 # 直播推流 -MOGO_LIVE_VERSION=1.3.58 +MOGO_LIVE_VERSION=1.3.59 # 直播拉流 -MOGO_TRAFFICLIVE_VERSION=1.3.58 +MOGO_TRAFFICLIVE_VERSION=1.3.59 # 定位服务 -MOGO_LOCATION_VERSION=1.3.58 +MOGO_LOCATION_VERSION=1.3.59 # 远程通讯模块 -MOGO_TELEMATIC_VERSION=1.3.58 +MOGO_TELEMATIC_VERSION=1.3.59 # v2x -MOGO_V2X_VERSION=1.3.58 +MOGO_V2X_VERSION=1.3.59 diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/MogoProtocolMsg.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/MogoProtocolMsg.java index 72ad34e..2a923c8 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/MogoProtocolMsg.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/MogoProtocolMsg.java @@ -12,6 +12,7 @@ public class MogoProtocolMsg { // 同步美化模式状态 public static final int SYNC_MODE_STATUS = 3; public static final int REQ_CAR_NUMBER = 4; + public static final int REQ_MAC_ADDRESS = 5; private int protocolType; private int bodyLength; diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/NSDNettyManager.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/NSDNettyManager.java index 78cd7c9..b9f7a67 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/NSDNettyManager.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/NSDNettyManager.java @@ -110,8 +110,7 @@ public class NSDNettyManager { nettyTcpServer.setListener(mDefaultServerListener); nettyTcpServer.start(); } else { - Logger.i(TAG, "服务端已开启,断开连接!"); - NettyTcpServer.getInstance().disconnect(); + Logger.i(TAG, "服务端已开启,不要重复启动!"); } } diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java index 8693a76..5540acb 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/NettyTcpClient.java @@ -289,7 +289,7 @@ public class NettyTcpClient { * @return 获取TCP连接状态 */ public boolean getConnectStatus() { - return isConnected; + return channel != null && channel.isOpen() && channel.isActive(); } public boolean isConnecting() { diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/handler/NettyClientHandler.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/handler/NettyClientHandler.java index c0e36c2..2347341 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/handler/NettyClientHandler.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/client/handler/NettyClientHandler.java @@ -6,6 +6,8 @@ import com.mogo.telematic.client.NettyTcpClient; import com.mogo.telematic.client.listener.NettyClientListener; import com.mogo.telematic.client.status.ConnectState; +import org.jetbrains.annotations.NotNull; + import io.netty.channel.ChannelHandlerContext; import io.netty.channel.SimpleChannelInboundHandler; import io.netty.handler.timeout.IdleStateEvent; @@ -19,7 +21,7 @@ public class NettyClientHandler extends SimpleChannelInboundHandler? + private val listener: NettyClientListener<*> ) : ChannelInboundHandlerAdapter() { private val maxRetries = Int.MAX_VALUE @@ -33,7 +33,7 @@ class ReconnectHandler( @Throws(Exception::class) override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) { Logger.e(TAG, "ReconnectHandler#exceptionCaught cause message is:${cause.message}") - listener?.onClientStatusConnectChanged( + listener.onClientStatusConnectChanged( ConnectState.STATUS_CONNECT_ERROR, cause.message, ctx.channel() @@ -45,7 +45,14 @@ class ReconnectHandler( @Throws(Exception::class) override fun channelInactive(ctx: ChannelHandlerContext) { Logger.d(TAG, "ReconnectHandler channelInactive ...") - listener?.onClientStatusConnectChanged(STATUS_CONNECT_CLOSED, "channelInactive", ctx.channel()) + synchronized(NettyTcpClient::class.java) { + NettyTcpClient.sSERVER_SN = "" + } + listener.onClientStatusConnectChanged( + STATUS_CONNECT_CLOSED, + "channelInactive", + ctx.channel() + ) var allowRetry = false if (retries < maxRetries) { allowRetry = true diff --git a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/netty/NettyTcpServer.java b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/netty/NettyTcpServer.java index df7ffa9..cbd4191 100644 --- a/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/netty/NettyTcpServer.java +++ b/libraries/mogo-telematic/src/main/java/com/mogo/telematic/server/netty/NettyTcpServer.java @@ -51,7 +51,7 @@ public class NettyTcpServer { // private boolean connectStatus; private EventLoopGroup bossGroup; private EventLoopGroup workerGroup; - private boolean isServerStart; + private volatile boolean isServerStart; public static NettyTcpServer getInstance() { if (instance == null) {