|
@@ -29,6 +29,8 @@ object FusionManager : LifecycleObserver, OnFdcClientStateChangedListener,
|
|
|
|
|
|
var stateFusion: FdcClient.FdcClientState = FdcClient.FdcClientState.Stopped
|
|
|
private const val timeoutMax = 4000
|
|
|
+ var firstLink = false
|
|
|
+ private set
|
|
|
private var isLogin = false
|
|
|
val pumpList = arrayListOf<PumpInfo>()
|
|
|
|
|
@@ -42,10 +44,19 @@ object FusionManager : LifecycleObserver, OnFdcClientStateChangedListener,
|
|
|
|
|
|
stateFusion = state
|
|
|
when (state) {
|
|
|
- FdcClient.FdcClientState.Connected -> loginFetchInfo()
|
|
|
+ FdcClient.FdcClientState.Connected -> {
|
|
|
+ firstLink = true
|
|
|
+ loginFetchInfo()
|
|
|
+ }
|
|
|
// 中途断网重连
|
|
|
FdcClient.FdcClientState.Connecting -> onFusionEvent?.onFusionReconnect()
|
|
|
- FdcClient.FdcClientState.MyAddReConnect -> onFusionEvent?.onFusionInit(FusionError.WrongAddress, StringUtil.get(R.string.wrong_fusion_address))
|
|
|
+ FdcClient.FdcClientState.MyAddReConnect -> {
|
|
|
+ if (!firstLink) {
|
|
|
+ onFusionEvent?.onFusionInit(FusionError.WrongAddress, StringUtil.get(R.string.wrong_fusion_address))
|
|
|
+ } else {
|
|
|
+ onFusionEvent?.onFusionReconnect()
|
|
|
+ }
|
|
|
+ }
|
|
|
else -> {}
|
|
|
}
|
|
|
}
|
|
@@ -92,6 +103,7 @@ object FusionManager : LifecycleObserver, OnFdcClientStateChangedListener,
|
|
|
FdcClient.getDefault().removeOnFdcServiceResponseReceivedListeners(manager)
|
|
|
FdcClient.getDefault().removeOnFdcMessageReceivedListeners(manager)
|
|
|
FdcClient.getDefault().stop()
|
|
|
+ firstLink = false
|
|
|
}
|
|
|
}
|
|
|
|