[Update]Adas多屏代码更改、Netty框架自定义协议并解决粘包/拆包问题
This commit is contained in:
@@ -225,7 +225,7 @@ ext {
|
||||
//========================= 新架构的 Maven 版本管理 =========================
|
||||
mogo_core_function_autopilot : "com.mogo.eagle.core.function.impl:autopilot:${MOGO_CORE_FUNCTION_AUTOPILOT_VERSION}",
|
||||
mogo_core_function_check : "com.mogo.eagle.core.function.impl:check:${MOGO_CORE_FUNCTION_CHECK_VERSION}",
|
||||
mogo_core_function_devatools : "com.mogo.eagle.core.function.impl:devatools:${MOGO_CORE_FUNCTION_DEVATOOLS_VERSION}",
|
||||
mogo_core_function_devatools : "com.mogo.eagle.core.function.impl:devatools:${MOGO_CORE_FUNCTION_CHECK_VERSION}",
|
||||
mogo_core_function_hmi : "com.mogo.eagle.core.function.impl:hmi:${MOGO_CORE_FUNCTION_HMI_VERSION}",
|
||||
mogo_core_function_map : "com.mogo.eagle.core.function.impl:map:${MOGO_CORE_FUNCTION_MAP_VERSION}",
|
||||
mogo_core_function_main : "com.mogo.eagle.core.function.impl:main:${MOGO_CORE_FUNCTION_MAIN_VERSION}",
|
||||
|
||||
@@ -53,6 +53,7 @@ dependencies {
|
||||
|
||||
implementation rootProject.ext.dependencies.mogochainbase
|
||||
implementation rootProject.ext.dependencies.mogoami
|
||||
implementation rootProject.ext.dependencies.mogoaicloudtelematic
|
||||
|
||||
if (Boolean.valueOf(USE_MAVEN_PACKAGE)) {
|
||||
implementation rootProject.ext.dependencies.mogo_core_data
|
||||
|
||||
@@ -18,10 +18,21 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.telematic.MogoProtocolMsg
|
||||
import com.mogo.telematic.MogoProtocolMsg.NORMAL_DATA
|
||||
import com.mogo.telematic.NSDNettyManager
|
||||
import com.mogo.telematic.client.listener.NettyClientListener
|
||||
import com.mogo.telematic.client.status.ConnectState
|
||||
import com.mogo.telematic.server.netty.NettyServerListener
|
||||
import com.zhidao.support.adas.high.AdasManager
|
||||
import com.zhidao.support.adas.high.bean.IPCUpgradeInfo
|
||||
import com.zhidao.support.adas.high.common.CupidLogUtils
|
||||
import io.netty.channel.Channel
|
||||
import java.util.concurrent.TimeUnit
|
||||
import com.zhidao.support.adas.high.AdasOptions
|
||||
import io.netty.channel.ChannelFuture
|
||||
import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* @author xiaoyuzhou
|
||||
@@ -47,17 +58,104 @@ class MoGoAutopilotProvider :
|
||||
// TODO 临时方案,根据不同的身份标识,连接不同的工控机IP
|
||||
when (FunctionBuildConfig.appIdentityMode) {
|
||||
0 -> // 司机
|
||||
AdasManager.getInstance().create(context, "192.168.1.102")
|
||||
{
|
||||
// "192.168.1.102"
|
||||
val options = AdasOptions.Builder().setClient(false).build()
|
||||
AdasManager.getInstance().create(context, options)
|
||||
NSDNettyManager.getInstance().startNSDNettyServer(context, object : NettyServerListener<MogoProtocolMsg> {
|
||||
override fun onMessageResponseServer(
|
||||
msg: MogoProtocolMsg?,
|
||||
ChannelId: String?
|
||||
) {
|
||||
Logger.d(TAG, "Receive client data is:${msg?.toString()}")
|
||||
}
|
||||
|
||||
override fun onStartServer() {
|
||||
Logger.d(TAG, "onStartServer")
|
||||
}
|
||||
|
||||
override fun onStopServer() {
|
||||
Logger.d(TAG, "onStopServer")
|
||||
}
|
||||
|
||||
override fun onChannelConnect(channel: Channel?) {
|
||||
// TODO:("暂时保存一个Client的channel,后面管理多个Client的channel")
|
||||
NSDNettyManager.getInstance().selectChannel(channel)
|
||||
val socketAddress = channel?.remoteAddress().toString()
|
||||
Logger.d(TAG, "Client ip is:${socketAddress}")
|
||||
}
|
||||
|
||||
override fun onChannelDisConnect(channel: Channel?) {
|
||||
Logger.d(TAG, "onChannelDisConnect")
|
||||
}
|
||||
})
|
||||
}
|
||||
1 -> // 乘客
|
||||
AdasManager.getInstance().create(context, "192.168.1.103")
|
||||
{
|
||||
// "192.168.1.102"
|
||||
val options = AdasOptions.Builder().build()
|
||||
AdasManager.getInstance().create(context, options)
|
||||
NSDNettyManager.getInstance().searchAndConnectServer(context, object : NettyClientListener<MogoProtocolMsg> {
|
||||
override fun onMessageResponseClient(msg: MogoProtocolMsg?, index: Int) {
|
||||
Logger.d(TAG, "收到司机端的数据!")
|
||||
// 乘客端收到adas数据直接解析,后续分发解析后的数据流程同司机端
|
||||
msg?.let {
|
||||
AdasManager.getInstance().parseIPCData(it.body)
|
||||
Logger.d(TAG, "解析司机端数据完毕!")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClientStatusConnectChanged(statusCode: Int, index: Int) {
|
||||
when (statusCode) {
|
||||
ConnectState.STATUS_CONNECT_SUCCESS -> Logger.d(TAG, "乘客端连接司机端服务成功! index is:${index}")
|
||||
else -> Logger.d(TAG, "client statusCode is:${statusCode}")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
//
|
||||
else -> // 默认采用UDP寻址方式
|
||||
AdasManager.getInstance().create(context)
|
||||
{
|
||||
val options = AdasOptions.Builder().setClient(false).build()
|
||||
AdasManager.getInstance().create(context, options)
|
||||
}
|
||||
}
|
||||
//////////////////////////////////注意先后顺序,AdasManager.getInstance().create后才可以设置监听/////////////////////////////////////////////
|
||||
// 监听 adas 连接状态
|
||||
AdasManager.getInstance().setOnAdasConnectStatusListener(MoGoAdasMsgConnectStatusListenerImpl())
|
||||
// 监听ADAS-SDK获取到的工控机数据
|
||||
// 监听ADAS-SDK获取到的工控机数据(乘客也需注册)
|
||||
AdasManager.getInstance().setOnAdasListener(MoGoAdasListenerImpl())
|
||||
// 司机端监听
|
||||
if (FunctionBuildConfig.appIdentityMode == 0) {
|
||||
AdasManager.getInstance().setOnMultiDeviceListener { bytes ->
|
||||
Logger.d(
|
||||
TAG,
|
||||
"司机端接收到工控机吐出来的数据为:${Arrays.toString(bytes)}"
|
||||
)
|
||||
// 发送数据给乘客端
|
||||
if (NSDNettyManager.getInstance().isServerStart) {
|
||||
Logger.d(
|
||||
TAG,
|
||||
"司机端透传数据给乘客端!"
|
||||
)
|
||||
NSDNettyManager.getInstance().sendMogoProtocolMsgToClient(MogoProtocolMsg(NORMAL_DATA, bytes.size, bytes)) { channelFuture: ChannelFuture ->
|
||||
if (channelFuture.isSuccess) {
|
||||
Logger.d(
|
||||
TAG,
|
||||
"Send data to client is success."
|
||||
)
|
||||
} else {
|
||||
Logger.d(
|
||||
TAG,
|
||||
"Send data to client is failure."
|
||||
)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Logger.d(TAG, "司机端Server未启动!")
|
||||
}
|
||||
}
|
||||
}
|
||||
// 同步数据给工控机的服务
|
||||
AsyncDataToAutopilotServer.INSTANCE.initServer()
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ kapt.include.compile.classpath=false
|
||||
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
|
||||
# org.gradle.parallel=true
|
||||
# AndroidX package structure to make it clearer which packages are bundled with the
|
||||
# Android operating system, and which are packaged with your app's APK
|
||||
# Android operating system, and which are packaged with your app'protoc_platforms APK
|
||||
# https://developer.android.com/topic/libraries/support-library/androidx-rn
|
||||
android.useAndroidX=true
|
||||
# Automatically convert third-party libraries to use AndroidX
|
||||
@@ -63,21 +63,23 @@ SERVICE_CHAIN_VERSION=1.0.47
|
||||
LOGLIB_VERSION=1.1.19
|
||||
######## MogoAiCloudSDK Version ########
|
||||
# 网络请求
|
||||
MOGO_NETWORK_VERSION=1.3.18
|
||||
MOGO_NETWORK_VERSION=1.3.19-beta
|
||||
# 鉴权
|
||||
MOGO_PASSPORT_VERSION=1.3.18
|
||||
MOGO_PASSPORT_VERSION=1.3.19-beta
|
||||
# 常链接
|
||||
MOGO_SOCKET_VERSION=1.3.18
|
||||
MOGO_SOCKET_VERSION=1.3.19-beta
|
||||
# 数据采集
|
||||
MOGO_REALTIME_VERSION=1.3.18
|
||||
MOGO_REALTIME_VERSION=1.3.19-beta
|
||||
# 探路,道路事件发布,获取
|
||||
MOGO_TANLU_VERSION=1.3.18
|
||||
MOGO_TANLU_VERSION=1.3.19-beta
|
||||
# 直播推流
|
||||
MOGO_LIVE_VERSION=1.3.18
|
||||
MOGO_LIVE_VERSION=1.3.19-beta
|
||||
# 直播拉流
|
||||
MOGO_TRAFFICLIVE_VERSION=1.3.18
|
||||
MOGO_TRAFFICLIVE_VERSION=1.3.19-beta
|
||||
# 定位服务
|
||||
MOGO_LOCATION_VERSION=1.3.18
|
||||
MOGO_LOCATION_VERSION=1.3.19-beta
|
||||
# 远程通讯模块
|
||||
MOGO_TELEMATIC_VERSION=1.3.19-beta
|
||||
######## MogoAiCloudSDK Version ########
|
||||
# 自研地图
|
||||
MAP_SDK_VERSION=2.0.0.24
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
GROUP=com.mogo.adas
|
||||
POM_ARTIFACT_ID=mogo-adas
|
||||
VERSION_CODE=1
|
||||
VERSION_CODE=1
|
||||
@@ -52,7 +52,7 @@ import okhttp3.WebSocket;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: AdasChannel
|
||||
* @Description: java类作用描述
|
||||
@@ -134,6 +134,8 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
}
|
||||
|
||||
private void initData(Context context) {
|
||||
//原始数据解析类
|
||||
socketReader = new SocketReader();
|
||||
MgContextUtils.setContext(context.getApplicationContext());
|
||||
//消息工厂
|
||||
myMessageFactory = new MyMessageFactory();
|
||||
@@ -167,7 +169,6 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
|
||||
|
||||
private void initSocket() {
|
||||
mSocket = new FpgaSocket();
|
||||
socketReader = new SocketReader();
|
||||
mSocket.setWebSocketListener(this);
|
||||
if (isUseQueue) {
|
||||
WebSocketQueueManager.getInstance().registerWebSocketListener(this);
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.zhidao.support.adas.high.bean.ConfigInfo;
|
||||
import com.zhidao.support.adas.high.bean.MapLocationInfo;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: AdasManager
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -18,7 +18,7 @@ import com.zhidao.support.adas.high.bean.record.AutopilotRecordResult;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: OnAdasListener
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: MapLocationInfo
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.zhidao.support.adas.high.bean;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: RectInfo
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.zhidao.support.adas.high.bean;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high.bean
|
||||
* @ClassName: WarnMessageInfo
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.zhidao.support.adas.high.common;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: PACKAGE_NAME
|
||||
* @ClassName: com.zhidao.lib.adas.high.common.Constants
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -37,7 +37,7 @@ import okhttp3.WebSocketListener;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: FpgaSocket
|
||||
* @Description: java类作用描述
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
import okio.ByteString;
|
||||
|
||||
/**
|
||||
* @ProjectName: lib-adas-fpga
|
||||
*
|
||||
* @Package: com.zhidao.lib.adas.high
|
||||
* @ClassName: IWebSocket
|
||||
* @Description: java类作用描述
|
||||
|
||||
Reference in New Issue
Block a user