和obu联调升级功能完成
This commit is contained in:
@@ -44,6 +44,9 @@ class MoGoObuProvider : IMoGoObuProvider {
|
||||
CommonUtils.getIpAddressString()
|
||||
)
|
||||
}
|
||||
|
||||
//监听obu版本数据
|
||||
MogoPrivateObuNewManager.INSTANCE.readSystemConfig()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,4 +77,8 @@ class MoGoObuProvider : IMoGoObuProvider {
|
||||
override fun setObuLog(isChecked: Boolean) {
|
||||
MogoPrivateObuNewManager.INSTANCE.setObuLog(isChecked)
|
||||
}
|
||||
|
||||
override fun uploadObuPack(filePathArray: Array<String>) {
|
||||
MogoPrivateObuNewManager.INSTANCE.uploadObuPack(filePathArray)
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.datacenter.obu
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
import com.mogo.eagle.core.data.enums.*
|
||||
@@ -9,6 +10,7 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.angle.Default
|
||||
import com.mogo.eagle.core.function.api.map.angle.TooClose
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
@@ -19,8 +21,10 @@ import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.Config
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
|
||||
import com.mogo.eagle.core.utilcode.util.FileUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.support.obu.ObuBase
|
||||
import com.mogo.support.obu.ObuScene
|
||||
@@ -32,6 +36,8 @@ import com.mogo.support.obu.model.*
|
||||
import com.mogo.support.obu.option.MogoObuCom
|
||||
import com.mogo.support.obu.option.MogoObuLog
|
||||
import com.mogo.support.obu.option.MogoObuOptions
|
||||
import com.mogo.support.obu.upgrade.ObuSoftwareUpgradeStatus
|
||||
import com.mogo.support.obu.upgrade.OnUpgradeListener
|
||||
import com.zhidao.support.obu.ObuManager
|
||||
import com.zhidao.support.obu.OnObuListener
|
||||
import mogo.telematics.pad.MessagePad
|
||||
@@ -43,7 +49,7 @@ import kotlin.math.roundToInt
|
||||
* @since 2021/8/23
|
||||
* @description 自研OBU 管理
|
||||
*/
|
||||
class MogoPrivateObuNewManager private constructor() {
|
||||
class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
companion object {
|
||||
val INSTANCE: MogoPrivateObuNewManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
MogoPrivateObuNewManager()
|
||||
@@ -51,9 +57,12 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
}
|
||||
|
||||
private var mObuStatusInfo = CallerObuConnectListenerManager.getObuStatusInfo()
|
||||
private var mContext: Context? = null
|
||||
var mVersionName: String? = null
|
||||
|
||||
fun connectObu(context: Context, obuIpAddress: String, padIpAddress: String) {
|
||||
ObuManager.getInstance().registerObuListener(mogoObuListener)
|
||||
mContext = context
|
||||
val com = MogoObuCom.newBuilder()
|
||||
.setLocalIp(padIpAddress)
|
||||
.setComType(MogoObuComType.UDP)
|
||||
@@ -83,6 +92,59 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
ObuManager.getInstance().connect(options)
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传obu文件的状态, 升级成功,需要删除obu的文件和解压文件夹
|
||||
*/
|
||||
override fun onUpgradeStatus(status: ObuSoftwareUpgradeStatus?, t: Throwable?) {
|
||||
Log.d("liyz", "onUpgradeStatus status = $status ")
|
||||
//上传完成就相当于成功了,立即升级,比上电升级,只是多了一个重启
|
||||
if (status == ObuSoftwareUpgradeStatus.UPLOAD_FINISH|| status == ObuSoftwareUpgradeStatus.EXEC_UPGRADE_PROGRAM_FINISH
|
||||
|| status == ObuSoftwareUpgradeStatus.CONNECTION_FAILED|| status == ObuSoftwareUpgradeStatus.AUTHENTICATION_FAILED
|
||||
|| status == ObuSoftwareUpgradeStatus.CHANNEL_ABNORMITY|| status == ObuSoftwareUpgradeStatus.UPGRADE_PACKAGE_ERROR
|
||||
|| status == ObuSoftwareUpgradeStatus.UPGRADE_PACKAGE_CHECK_FAILED || status == ObuSoftwareUpgradeStatus.PACKAGE_UPLOAD_FAILED
|
||||
|| status == ObuSoftwareUpgradeStatus.EXEC_UPGRADE_PROGRAM_FAILED || status == ObuSoftwareUpgradeStatus.UNKNOWN) {
|
||||
|
||||
UiThreadHandler.post {
|
||||
var isDeleteSuccess = FileUtils.delete(Config.downLoadObuPath)
|
||||
var isDeleteUnzipSuccess = FileUtils.delete(Config.downLoadUnzipObuPath)
|
||||
Log.d("liyz",
|
||||
"onUpgradeStatus ---isDeleteSuccess = $isDeleteSuccess ---isDeleteUnzipSuccess = $isDeleteUnzipSuccess")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前的obu版本
|
||||
*/
|
||||
override fun onCurrentVersion(version: MogoObuSystemBConfigData) {
|
||||
Log.e("liyz", "onCurrentVersion version = ${version.version}")
|
||||
if (!version.version.isNullOrEmpty()) {
|
||||
mVersionName = version.version
|
||||
CallerDevaToolsManager.queryObuUpgrade(version.version)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听obu
|
||||
*/
|
||||
fun readSystemConfig() {
|
||||
ObuManager.getInstance().readSystemBConfig(mContext, MogoObuConst.OBU_DEFAULT_IP, this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 传递obu升级包给硬件
|
||||
* @param upgradePackage 升级包文件绝对路径 只能包含 升级包MD5文件和升级包文件
|
||||
* @param isUpgradeNow 是否立即升级
|
||||
* false:OBU设备下次上电时执行升级程序
|
||||
* ture: OBU设备立即执行升级程序 TODO 警告:执行立即升级时请确保车辆是静止状态。车辆在运行过程中升级设备可能会影响驾驶,严重时可能造成安全隐患!!!
|
||||
* @param listener 升级回调
|
||||
* @return 是否调用成功
|
||||
*/
|
||||
fun uploadObuPack(filePathArray: Array<String>) {
|
||||
Log.d("liyz", " filePathArray = $filePathArray")
|
||||
ObuManager.getInstance().uploadUpgradePackage(MogoObuConst.OBU_DEFAULT_IP, filePathArray,false,this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 断开新obu
|
||||
*/
|
||||
@@ -101,6 +163,9 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
return ObuManager.getInstance().connectStatus == MogoObuConstants.CONNECT_STATUS.CONNECTED
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置obu sdk日志的输出
|
||||
*/
|
||||
fun setObuLog(isChecked: Boolean) {
|
||||
ObuManager.getInstance().setEnableLog(isChecked)
|
||||
val builder: MogoObuLog.Builder =
|
||||
@@ -111,6 +176,9 @@ class MogoPrivateObuNewManager private constructor() {
|
||||
ObuManager.getInstance().logConfig(builder.build())
|
||||
}
|
||||
|
||||
/**
|
||||
* obu 回调监听
|
||||
*/
|
||||
private val mogoObuListener: OnObuListener = object : OnObuListener {
|
||||
/**
|
||||
* 连接状态的改变
|
||||
|
||||
Reference in New Issue
Block a user