diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoTelematicProvider.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoTelematicProvider.kt index b1f0fd6a96..12eeedf1da 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoTelematicProvider.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/MoGoTelematicProvider.kt @@ -4,6 +4,7 @@ import android.content.Context import com.alibaba.android.arouter.facade.annotation.Route import com.mogo.eagle.core.data.constants.MogoServicePaths import com.mogo.eagle.core.function.api.telematic.IMogoTelematicProvider +import com.mogo.telematic.MogoProtocolMsg import com.mogo.telematic.NSDNettyManager @Route(path = MogoServicePaths.PATH_TELEMATIC_PROVIDER) @@ -26,4 +27,16 @@ class MoGoTelematicProvider: IMogoTelematicProvider { override fun getServerToken(): String { return NSDNettyManager.getInstance().serverSn } + + override fun sendMsgToAllClients(type: Int, byteArray: ByteArray) { + NSDNettyManager.getInstance().sendMsgToAllClients( + MogoProtocolMsg(type, byteArray.size, byteArray) + ) + } + + override fun sendMsgToServer(type: Int, byteArray: ByteArray) { + NSDNettyManager.getInstance().sendMogoProtocolMsgToServer( + MogoProtocolMsg(type, byteArray.size, byteArray), + null) + } } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt index 17471344ec..5144d53600 100644 --- a/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt +++ b/core/function-impl/mogo-core-function-datacenter/src/main/java/com/mogo/eagle/core/function/datacenter/autopilot/telematic/TeleMsgHandler.kt @@ -8,10 +8,12 @@ import com.mogo.eagle.core.data.app.AppConfigInfo import com.mogo.eagle.core.data.config.FunctionBuildConfig import com.mogo.eagle.core.data.deva.chain.ChainConstant import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS +import com.mogo.eagle.core.data.telematic.TelematicConstant import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setDemoMode import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIgnoreConditionDraw import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager +import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager import com.mogo.eagle.core.utilcode.mogo.logger.* import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant import com.mogo.eagle.core.utilcode.util.ToastUtils @@ -122,6 +124,9 @@ class TeleMsgHandler : IMsgHandler { } } } + TelematicConstant.BUSINESS_STRING -> { + CallerTelematicListenerManager.invokeReceivedMsg(TelematicConstant.BUSINESS_STRING, it.body) + } else -> { } } @@ -166,6 +171,9 @@ class TeleMsgHandler : IMsgHandler { invokeNettyConnResult("司机屏SN未获取到,不发送给乘客屏") } } + TelematicConstant.BUSINESS_STRING -> { + CallerTelematicListenerManager.invokeReceivedMsg(TelematicConstant.BUSINESS_STRING, it.body) + } else -> { } } diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/telematic/TelematicConstant.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/telematic/TelematicConstant.kt new file mode 100644 index 0000000000..6c02b811db --- /dev/null +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/telematic/TelematicConstant.kt @@ -0,0 +1,7 @@ +package com.mogo.eagle.core.data.telematic + +class TelematicConstant { + companion object { + const val BUSINESS_STRING = 100 + } +} \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IMogoTelematicProvider.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IMogoTelematicProvider.kt index 70303c7b99..39ff7d0f62 100644 --- a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IMogoTelematicProvider.kt +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IMogoTelematicProvider.kt @@ -10,4 +10,8 @@ interface IMogoTelematicProvider: IProvider { fun getServerIp(): String fun getServerToken(): String + + fun sendMsgToAllClients(type: Int, byteArray: ByteArray) + + fun sendMsgToServer(type: Int, byteArray: ByteArray) } \ No newline at end of file diff --git a/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IReceivedMsgListener.kt b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IReceivedMsgListener.kt new file mode 100644 index 0000000000..c64b114963 --- /dev/null +++ b/core/mogo-core-function-api/src/main/java/com/mogo/eagle/core/function/api/telematic/IReceivedMsgListener.kt @@ -0,0 +1,5 @@ +package com.mogo.eagle.core.function.api.telematic + +interface IReceivedMsgListener { + fun onReceivedMsg(type: Int, byteArray: ByteArray) +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicListenerManager.kt new file mode 100644 index 0000000000..54201e9325 --- /dev/null +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicListenerManager.kt @@ -0,0 +1,14 @@ +package com.mogo.eagle.core.function.call.telematic + +import com.mogo.eagle.core.function.api.telematic.IReceivedMsgListener +import com.mogo.eagle.core.function.call.base.CallerBase + +object CallerTelematicListenerManager: CallerBase() { + + fun invokeReceivedMsg(type: Int, byteArray: ByteArray) { + M_LISTENERS.forEach { + val listener = it.value + listener.onReceivedMsg(type, byteArray) + } + } +} \ No newline at end of file diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicManager.kt index 34bf5ea141..c164e12b15 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/telematic/CallerTelematicManager.kt @@ -34,4 +34,20 @@ object CallerTelematicManager { fun getServerToken(): String { return providerApi?.getServerToken() ?: "" } + + /** + * 发送数据给所有客户端 + * type:保存在TelematicConstant中 + */ + fun sendMsgToAllClients(type: Int, byteArray: ByteArray) { + providerApi?.sendMsgToAllClients(type, byteArray) + } + + /** + * 发送数据给服务端 + * type:保存在TelematicConstant中 + */ + fun sendMsgToServer(type: Int, byteArray: ByteArray) { + providerApi?.sendMsgToServer(type, byteArray) + } } \ No newline at end of file