新增LED设置,gps时间设置,开关机,直播蓝牙下发;修改添加设备没有支付,返回再次扫描不到设备bug
This commit is contained in:
@@ -1 +1 @@
|
||||
#Fri Oct 31 15:54:13 CST 2025
|
||||
#Thu Nov 13 11:09:24 CST 2025
|
||||
|
||||
@@ -28,9 +28,9 @@ android {
|
||||
applicationId "com.abbidot.tracker"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 35
|
||||
versionCode 2022
|
||||
// versionName "2.0.22"
|
||||
versionName "2.0.22-Beta4"
|
||||
versionCode 2100
|
||||
// versionName "2.1.0"
|
||||
versionName "2.1.0-Beta1"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.abbidot.tracker.bean
|
||||
|
||||
/**
|
||||
*Created by .yzq on 2025/11/13/周四.
|
||||
* @link
|
||||
* @description:
|
||||
*/
|
||||
data class ActionConStateBean(var conState: Int, var mac: String) {
|
||||
constructor() : this(0, "")
|
||||
}
|
||||
@@ -16,16 +16,16 @@ import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityMapLiveBinding
|
||||
import com.abbidot.tracker.vm.MapLiveViewModel
|
||||
import com.abbidot.tracker.vm.FencesManageViewModel
|
||||
import com.abbidot.tracker.vm.FencesMapViewModel
|
||||
import com.abbidot.tracker.vm.FindBleDeviceViewModel
|
||||
import com.abbidot.tracker.vm.TrackerSetViewModel
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.LedLightViewModel
|
||||
import com.abbidot.tracker.ui.common.map.MapLiveCommon
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.FencesManageViewModel
|
||||
import com.abbidot.tracker.vm.FencesMapViewModel
|
||||
import com.abbidot.tracker.vm.FindBleDeviceViewModel
|
||||
import com.abbidot.tracker.vm.MapLiveViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
import com.clj.fastble.data.BleDevice
|
||||
import com.daimajia.androidanimations.library.Techniques
|
||||
@@ -40,7 +40,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
private val mMapLiveViewModel: MapLiveViewModel by viewModels()
|
||||
val mFencesMapViewModel: FencesMapViewModel by viewModels()
|
||||
val mFencesManageViewModel: FencesManageViewModel by viewModels()
|
||||
private val mTrackerManageViewModel: TrackerSetViewModel by viewModels()
|
||||
private val mLedLightViewModel: LedLightViewModel by viewModels()
|
||||
private val mFindBleDeviceViewModel: FindBleDeviceViewModel by viewModels()
|
||||
lateinit var mPet: PetBean
|
||||
|
||||
@@ -79,7 +79,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
)
|
||||
}
|
||||
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(this, mPet.deviceId, mLiveStatus)
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(this, mPet.deviceId, mLiveStatus,0)
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
@@ -113,7 +113,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
}
|
||||
|
||||
|
||||
mTrackerManageViewModel.mLedSwitchLiveData.observe(this) {
|
||||
mLedLightViewModel.mLedSwitchLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mViewBinding.mapLiveDeviceLedSwitch.isChecked =
|
||||
@@ -193,6 +193,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
stopMapLive()
|
||||
}
|
||||
|
||||
@@ -203,7 +204,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
dialog.dismiss()
|
||||
mLiveStatus = 0
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@MapLiveActivity, mPet.deviceId, mLiveStatus
|
||||
this@MapLiveActivity, mPet.deviceId, mLiveStatus,0
|
||||
)
|
||||
}
|
||||
}, okTextResId = R.string.txt_sure
|
||||
@@ -224,7 +225,7 @@ class MapLiveActivity : BaseActivity<ActivityMapLiveBinding>(ActivityMapLiveBind
|
||||
setBleLedMode(mPet.macID, mHistoryDataBean!!.lightMode)
|
||||
ConstantInt.Open
|
||||
}
|
||||
mTrackerManageViewModel.setLedSwitch(this, mHistoryDataBean!!.deviceInfoId, ledSwitch)
|
||||
mLedLightViewModel.setLedSwitch(this, mHistoryDataBean!!.deviceInfoId, ledSwitch,0)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -14,20 +14,41 @@ import kotlinx.coroutines.launch
|
||||
* @description:
|
||||
*/
|
||||
class LedLightViewModel : ViewModel() {
|
||||
|
||||
val mSetLedLightLiveData = MutableLiveData<Result<String>>()
|
||||
val mLedSwitchLiveData = MutableLiveData<Result<String>>()
|
||||
|
||||
/**
|
||||
* 设置light灯光
|
||||
*/
|
||||
fun setLedLight(activity: BaseActivity<*>, mapDeviceBean: MapDeviceBean) {
|
||||
fun setLedLight(activity: BaseActivity<*>, mapDeviceBean: MapDeviceBean, modeType: Int) {
|
||||
activity.showLoading(true)
|
||||
mapDeviceBean.apply {
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setLedLight(
|
||||
deviceServerId, ledRedValue, ledGreenValue, ledBlueValue, ledMode, ledSwitch
|
||||
deviceServerId,
|
||||
ledRedValue,
|
||||
ledGreenValue,
|
||||
ledBlueValue,
|
||||
ledMode,
|
||||
ledSwitch,
|
||||
modeType
|
||||
)
|
||||
mSetLedLightLiveData.value = result
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置ledSwitch开关
|
||||
*/
|
||||
fun setLedSwitch(
|
||||
activity: BaseActivity<*>?, deviceInfoId: String, ledSwitch: Int, modeType: Int
|
||||
) {
|
||||
activity?.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setLedSwitch(deviceInfoId, ledSwitch, modeType)
|
||||
mLedSwitchLiveData.value = result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,7 +827,8 @@ interface INetworkService {
|
||||
suspend fun setupDeviceLiveStatus(
|
||||
@Query("deviceId") deviceId: String,
|
||||
@Query("liveState") liveState: Int,
|
||||
@Query("sendState") sendState: Int
|
||||
@Query("sendState") sendState: Int,
|
||||
@Query("modeType") modeType: Int,
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -957,7 +958,9 @@ interface INetworkService {
|
||||
@FormUrlEncoded
|
||||
@POST("device/turnoff")
|
||||
suspend fun turnoff(
|
||||
@Field("deviceInfoId") deviceInfoId: String, @Field("turnOff") turnOff: Int
|
||||
@Field("deviceInfoId") deviceInfoId: String,
|
||||
@Field("turnOff") turnOff: Int,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -966,7 +969,9 @@ interface INetworkService {
|
||||
@FormUrlEncoded
|
||||
@POST("device/gnssInterval")
|
||||
suspend fun reportInterval(
|
||||
@Field("deviceInfoId") deviceInfoId: String, @Field("gnssInterval") gnssInterval: Int
|
||||
@Field("deviceInfoId") deviceInfoId: String,
|
||||
@Field("gnssInterval") gnssInterval: Int,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -984,7 +989,9 @@ interface INetworkService {
|
||||
@FormUrlEncoded
|
||||
@POST("device/ledSwitch")
|
||||
suspend fun setLedSwitch(
|
||||
@Field("deviceInfoId") deviceInfoId: String, @Field("ledSwitch") ledSwitch: Int
|
||||
@Field("deviceInfoId") deviceInfoId: String,
|
||||
@Field("ledSwitch") ledSwitch: Int,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
@@ -998,7 +1005,8 @@ interface INetworkService {
|
||||
@Field("green") green: Int,
|
||||
@Field("blue") blue: Int,
|
||||
@Field("lightMode") lightMode: Int,
|
||||
@Field("ledSwitch") ledSwitch: Int
|
||||
@Field("ledSwitch") ledSwitch: Int,
|
||||
@Field("modeType") modeType: Int
|
||||
): BaseResponse<String>
|
||||
|
||||
/**
|
||||
|
||||
@@ -453,8 +453,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
/**
|
||||
* 移除围栏
|
||||
*/
|
||||
suspend fun removeFence(fenceId: String, deviceServiceId: String,modeType:Int) = getResult {
|
||||
service.removeFence(fenceId, deviceServiceId,modeType)
|
||||
suspend fun removeFence(fenceId: String, deviceServiceId: String, modeType: Int) = getResult {
|
||||
service.removeFence(fenceId, deviceServiceId, modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -731,8 +731,8 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
/**
|
||||
* 打开关闭直播
|
||||
*/
|
||||
suspend fun setupDeviceLiveStatus(deviceId: String, liveState: Int) = getResult {
|
||||
service.setupDeviceLiveStatus(deviceId, liveState, 0)
|
||||
suspend fun setupDeviceLiveStatus(deviceId: String, liveState: Int, modeType: Int) = getResult {
|
||||
service.setupDeviceLiveStatus(deviceId, liveState, 0, modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -857,14 +857,14 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
* 关闭设备
|
||||
*/
|
||||
suspend fun turnoff(deviceInfoId: String, turnOff: Int) = getResult {
|
||||
service.turnoff(deviceInfoId, turnOff)
|
||||
service.turnoff(deviceInfoId, turnOff, 1)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置设备上报下发时间
|
||||
*/
|
||||
suspend fun reportInterval(deviceInfoId: String, gnssInterval: Int) = getResult {
|
||||
service.reportInterval(deviceInfoId, gnssInterval)
|
||||
suspend fun reportInterval(deviceInfoId: String, gnssInterval: Int, modeType: Int) = getResult {
|
||||
service.reportInterval(deviceInfoId, gnssInterval, modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -877,17 +877,23 @@ object NetworkApi : BaseNetworkApi<INetworkService>(INetworkService.BASE_URL) {
|
||||
/**
|
||||
* 设置ledSwitch开关
|
||||
*/
|
||||
suspend fun setLedSwitch(deviceInfoId: String, ledSwitch: Int) = getResult {
|
||||
service.setLedSwitch(deviceInfoId, ledSwitch)
|
||||
suspend fun setLedSwitch(deviceInfoId: String, ledSwitch: Int, modeType: Int) = getResult {
|
||||
service.setLedSwitch(deviceInfoId, ledSwitch, modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置light灯光
|
||||
*/
|
||||
suspend fun setLedLight(
|
||||
deviceServerId: String, red: Int, green: Int, blue: Int, lightMode: Int, ledSwitch: Int
|
||||
deviceServerId: String,
|
||||
red: Int,
|
||||
green: Int,
|
||||
blue: Int,
|
||||
lightMode: Int,
|
||||
ledSwitch: Int,
|
||||
modeType: Int
|
||||
) = getResult {
|
||||
service.setLedLight(deviceServerId, red, green, blue, lightMode, ledSwitch)
|
||||
service.setLedLight(deviceServerId, red, green, blue, lightMode, ledSwitch, modeType)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.abbidot.tracker.ui.activity.device
|
||||
|
||||
import android.content.Intent
|
||||
import android.text.TextUtils
|
||||
import android.view.View
|
||||
import android.widget.NumberPicker
|
||||
import androidx.activity.viewModels
|
||||
@@ -17,9 +18,9 @@ import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityAddNewTracker3Binding
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.ConnectionDeviceViewModel
|
||||
import com.abbidot.tracker.vm.TrackerSetViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
|
||||
class AddNewTracker3Activity :
|
||||
BaseActivity<ActivityAddNewTracker3Binding>(ActivityAddNewTracker3Binding::inflate),
|
||||
@@ -32,6 +33,7 @@ class AddNewTracker3Activity :
|
||||
private var mDeviceOutId = ""
|
||||
private var mDeviceId = ""
|
||||
private var mScanDeviceList: ArrayList<DataBean>? = null
|
||||
private var mConBleMac = ""
|
||||
|
||||
override fun getTopBar() = mViewBinding.ilAddNewTracker3TopBar.titleTopBar
|
||||
|
||||
@@ -93,6 +95,7 @@ class AddNewTracker3Activity :
|
||||
XEventBus.observe(this, EventName.ConnectDeviceState) { ble: BleTrackDeviceBean ->
|
||||
setButtonEnabled(mViewBinding.btnPairTrackerYes, ConstantInt.Type1)
|
||||
if (ble.conState == ConState.CONNECTED) {
|
||||
mConBleMac = ble.mac
|
||||
val intent = Intent(mContext, AddPairedSuccessActivity::class.java)
|
||||
intent.putExtra(ConstantString.DeviceOutId, mDeviceOutId)
|
||||
intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
@@ -136,6 +139,20 @@ class AddNewTracker3Activity :
|
||||
}
|
||||
}
|
||||
|
||||
override fun leftBackOnClick() {
|
||||
disconnectBle()
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
|
||||
/**
|
||||
* 防止没支付后退页面。扫描不到设备情况
|
||||
*/
|
||||
private fun disconnectBle() {
|
||||
if (!TextUtils.isEmpty(mConBleMac)) {
|
||||
SRBleUtil.instance.disconnectToMac(mConBleMac)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
mViewBinding.apply {
|
||||
when (v!!) {
|
||||
@@ -146,7 +163,7 @@ class AddNewTracker3Activity :
|
||||
}
|
||||
|
||||
btnPairTrackerYes -> {
|
||||
BleManager.getInstance().disconnectAllDevice()
|
||||
disconnectBle()
|
||||
setButtonEnabled(mViewBinding.btnPairTrackerYes, ConstantInt.Type0)
|
||||
mTrackerSetViewModel.bindDevice(
|
||||
this@AddNewTracker3Activity, mDeviceOutId
|
||||
@@ -154,6 +171,7 @@ class AddNewTracker3Activity :
|
||||
}
|
||||
|
||||
mRightImageButton -> {
|
||||
disconnectBle()
|
||||
val intent = Intent(mContext, AddNewTracker2Activity::class.java)
|
||||
intent.putExtra(ConstantString.isFirstBind, isFirstBind)
|
||||
startActivityFinish(intent)
|
||||
|
||||
@@ -199,13 +199,6 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
mLedLightViewModel.mSetLedLightLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
// XEventBus.post(EventName.UpdateData + "TrackerManageSetActivity")
|
||||
// XEventBus.post(EventName.UpdateData + "TrackerManageFragment")
|
||||
mPetBean?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
macID, SRBleCmdUtil.instance.setNotifySyncData()
|
||||
)
|
||||
}
|
||||
showToast(R.string.txt_change_successful, isFinish = true)
|
||||
}
|
||||
})
|
||||
@@ -270,7 +263,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
if (null != mBleTrackDeviceBean) {
|
||||
//判断是否有蓝牙连接
|
||||
if (BleManager.getInstance().isConnected(mBleTrackDeviceBean!!.bleDevice)) {
|
||||
finishAndSave()
|
||||
finishAndSave(ConstantInt.Type1)
|
||||
} else {
|
||||
super.leftBackOnClick()
|
||||
}
|
||||
@@ -282,10 +275,10 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
/**
|
||||
* 保存设置数据
|
||||
*/
|
||||
private fun finishAndSave() {
|
||||
private fun finishAndSave(modeType: Int) {
|
||||
mMapDeviceBean?.apply {
|
||||
isFinishSave = true
|
||||
mLedLightViewModel.setLedLight(this@LedLightActivity, this)
|
||||
mLedLightViewModel.setLedLight(this@LedLightActivity, this, modeType)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +368,14 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
||||
when (v) {
|
||||
//手动连接设备
|
||||
ledLightBluetoothTips.trbBleConnectState -> connectionBtn(ledLightBluetoothTips.trbBleConnectState.text.toString())
|
||||
btnLedLightSetSave -> finishAndSave()
|
||||
btnLedLightSetSave -> {
|
||||
val modeType = if (null != mBleTrackDeviceBean && BleManager.getInstance()
|
||||
.isConnected(mBleTrackDeviceBean!!.bleDevice)
|
||||
) ConstantInt.Type1
|
||||
else ConstantInt.Type2
|
||||
finishAndSave(modeType)
|
||||
}
|
||||
|
||||
btnLedLightIssue -> showLedIssue()
|
||||
ilLedLightIssueLayout.tvCloseIssueBtn -> showLedIssue()
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class PowerOffActivity : BaseActivity<ActivityPowerOffBinding>(ActivityPowerOffB
|
||||
}
|
||||
|
||||
mViewBinding.apply {
|
||||
setOnClickListenerViews(btnPowerOffYes,ilPowerOffBluetoothTips.trbBleConnectState)
|
||||
setOnClickListenerViews(btnPowerOffYes, ilPowerOffBluetoothTips.trbBleConnectState)
|
||||
}
|
||||
|
||||
connectBle()
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.abbidot.tracker.ui.activity.device.set
|
||||
|
||||
import android.view.View
|
||||
import androidx.activity.viewModels
|
||||
import com.abbidot.baselibrary.constant.EventName
|
||||
import com.abbidot.baselibrary.eventbus.XEventBus
|
||||
import com.abbidot.baselibrary.list.BaseRecyclerAdapter
|
||||
import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.tracker.R
|
||||
@@ -9,6 +11,7 @@ import com.abbidot.tracker.adapter.DurationSetAdapter
|
||||
import com.abbidot.tracker.base.BaseActivity
|
||||
import com.abbidot.tracker.bean.DataBean
|
||||
import com.abbidot.tracker.bean.MapDeviceBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
@@ -18,6 +21,7 @@ import com.abbidot.tracker.util.ViewUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleCmdUtil
|
||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||
import com.abbidot.tracker.vm.TrackerSetViewModel
|
||||
import com.clj.fastble.BleManager
|
||||
|
||||
class TrackingDurationSetActivity :
|
||||
BaseActivity<ActivityTrackingDurationSetBinding>(ActivityTrackingDurationSetBinding::inflate) {
|
||||
@@ -61,13 +65,49 @@ class TrackingDurationSetActivity :
|
||||
ViewUtil.instance.updateDataBeanOnlySelectedItem(
|
||||
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
||||
)
|
||||
mMapDeviceBean?.apply {
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
deviceMacId, SRBleCmdUtil.instance.setNotifySyncData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//接收发送指令后设备返回的数据
|
||||
XEventBus.observe(this, EventName.DeviceReceiveData) { receiveData: ReceiveDeviceData ->
|
||||
mMapDeviceBean?.let {
|
||||
if (it.deviceMacId == receiveData.mac) {
|
||||
val data = receiveData.data
|
||||
parseData(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析数据
|
||||
*/
|
||||
private fun parseData(data: ByteArray?) {
|
||||
data?.apply {
|
||||
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
|
||||
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
|
||||
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
|
||||
if (data0 == 0x12 && data1 == 1) {
|
||||
mMapDeviceBean?.apply {
|
||||
val dataBean = mDurationSetAdapter.getData()[mSelectIndex]
|
||||
if (data2 == 0) {
|
||||
mTrackerSetViewModel.reportInterval(
|
||||
this@TrackingDurationSetActivity,
|
||||
deviceServerId,
|
||||
dataBean.imageId,
|
||||
ConstantInt.Type1
|
||||
)
|
||||
} else {
|
||||
mTrackerSetViewModel.reportInterval(
|
||||
this@TrackingDurationSetActivity,
|
||||
deviceServerId,
|
||||
dataBean.imageId,
|
||||
ConstantInt.Type3
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +117,7 @@ class TrackingDurationSetActivity :
|
||||
for (time in timeList) {
|
||||
DataBean().apply {
|
||||
imageId = time
|
||||
name = String.format(getString(R.string.txt_duration_min_unit), time)
|
||||
name = String.format(getString(R.string.txt_duration_min_unit), "$time")
|
||||
durationList.add(this)
|
||||
}
|
||||
}
|
||||
@@ -105,9 +145,19 @@ class TrackingDurationSetActivity :
|
||||
mMapDeviceBean?.apply {
|
||||
mSelectIndex = pos
|
||||
val dataBean = mDurationSetAdapter.getData()[pos]
|
||||
mTrackerSetViewModel.reportInterval(
|
||||
this@TrackingDurationSetActivity, deviceServerId, dataBean.imageId
|
||||
)
|
||||
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
deviceMacId,
|
||||
SRBleCmdUtil.instance.setAndRedGpsDuration(duration = dataBean.imageId * 60L)
|
||||
)
|
||||
} else {
|
||||
mTrackerSetViewModel.reportInterval(
|
||||
this@TrackingDurationSetActivity,
|
||||
deviceServerId,
|
||||
dataBean.imageId,
|
||||
ConstantInt.Type2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import com.abbidot.tracker.constant.ConstantInt
|
||||
import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.databinding.ActivityLiveV2Binding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.LedLightViewModel
|
||||
import com.abbidot.tracker.dialog.CommonDialog1
|
||||
import com.abbidot.tracker.dialog.SelectMapTypeDialog
|
||||
import com.abbidot.tracker.ui.DebugActivity
|
||||
@@ -47,7 +48,6 @@ import com.abbidot.tracker.vm.FencesMapViewModel
|
||||
import com.abbidot.tracker.vm.FindBleDeviceViewModel
|
||||
import com.abbidot.tracker.vm.MapLiveViewModel
|
||||
import com.abbidot.tracker.vm.MapViewModel
|
||||
import com.abbidot.tracker.vm.TrackerSetViewModel
|
||||
import com.abbidot.tracker.widget.MapDeviceNetView
|
||||
import com.clj.fastble.BleManager
|
||||
import com.daimajia.androidanimations.library.Techniques
|
||||
@@ -64,7 +64,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
private val mMapViewModel: MapViewModel by viewModels()
|
||||
private val mFindBleDeviceViewModel: FindBleDeviceViewModel by viewModels()
|
||||
private val mMapLiveViewModel: MapLiveViewModel by viewModels()
|
||||
private val mTrackerManageViewModel: TrackerSetViewModel by viewModels()
|
||||
private val mLedLightViewModel: LedLightViewModel by viewModels()
|
||||
private val mCountDownViewModel: CountDownTimerViewModel by viewModels()
|
||||
private val mConDeviceViewModel: ConnectionDeviceViewModel by viewModels()
|
||||
|
||||
@@ -115,6 +115,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
|
||||
//设备Led灯开关
|
||||
private var isLedOpen = false
|
||||
private var mRequestModeType = ConstantInt.Type1
|
||||
|
||||
override fun getTopBar() = null
|
||||
|
||||
@@ -197,6 +198,13 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图加载好了
|
||||
*/
|
||||
private fun mapLoadOk() {
|
||||
showPetNameAndHead()
|
||||
}
|
||||
|
||||
override fun liveDataObserve() {
|
||||
mCountDownViewModel.mCountDownEndLiveData.observe(this) {
|
||||
when (mStartLiveIndex) {
|
||||
@@ -311,7 +319,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
} else {
|
||||
mPetBean?.apply {
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, deviceId, mLiveStatus
|
||||
this@LiveActivityV2, deviceId, mLiveStatus, mRequestModeType
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -344,11 +352,11 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
//搜索蓝牙的设备状态
|
||||
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
|
||||
if (conState == ConState.DEVICE_NOT_FOUND) {
|
||||
openNetLive()
|
||||
openNetLive(ConstantInt.Type2)
|
||||
}
|
||||
}
|
||||
|
||||
mTrackerManageViewModel.mLedSwitchLiveData.observe(this) {
|
||||
mLedLightViewModel.mLedSwitchLiveData.observe(this) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
// mViewBinding.cbLiveV2DeviceLightSwitch.isChecked =
|
||||
@@ -401,11 +409,44 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
if (data0 == 0x06 && data1 == 1) {
|
||||
val data3 = SRBleCmdUtil.instance.byteToInt(data[3])
|
||||
//开启直播
|
||||
if (data2 == 1 && data3 == 0) {
|
||||
LogUtil.e("开启直播")
|
||||
} else if (data2 == 0 && data3 == 0) {
|
||||
//停止轨迹Live直播
|
||||
LogUtil.e("//停止轨迹Live直播")
|
||||
if (data2 == 1) {
|
||||
if (data3 == 0) {
|
||||
LogUtil.e("蓝牙开启直播成功")
|
||||
mPetBean?.apply {
|
||||
mRequestModeType = ConstantInt.Type1
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, deviceId, mLiveStatus, mRequestModeType
|
||||
)
|
||||
}
|
||||
} else {
|
||||
LogUtil.e("蓝牙开启直播失败")
|
||||
openNetLive(ConstantInt.Type3)
|
||||
}
|
||||
} else if (data2 == 0) {
|
||||
mPetBean?.apply {
|
||||
//停止Live直播
|
||||
mRequestModeType = if (data3 == 0) {
|
||||
LogUtil.e("蓝牙停止直播成功")
|
||||
ConstantInt.Type1
|
||||
} else {
|
||||
LogUtil.e("蓝牙停止直播失败")
|
||||
ConstantInt.Type3
|
||||
}
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, deviceId, 0, mRequestModeType
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (data0 == 3 && data1 == 1) {
|
||||
val modeType = if (data2 == 0) {
|
||||
ConstantInt.Type1
|
||||
} else {
|
||||
ConstantInt.Type3
|
||||
}
|
||||
mMapDeviceBean?.apply {
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, deviceServerId, ledSwitch, modeType
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,16 +455,15 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
/**
|
||||
* 开启网络上报直播
|
||||
*/
|
||||
private fun openNetLive() {
|
||||
private fun openNetLive(modeType: Int) {
|
||||
if (isLiveJump) {
|
||||
mPetBean?.apply {
|
||||
if (!BleManager.getInstance().isConnected(macID)) {
|
||||
//刚开始显示Starting Live.
|
||||
mCountDownViewModel.startCountDown(2)
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, deviceId, mLiveStatus
|
||||
)
|
||||
}
|
||||
//刚开始显示Starting Live.
|
||||
mCountDownViewModel.startCountDown(2)
|
||||
mRequestModeType = modeType
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, deviceId, mLiveStatus, modeType
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -493,9 +533,15 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
val ledSwitch = if (isLedOpen) ConstantInt.Open
|
||||
else ConstantInt.Close
|
||||
|
||||
setLedSwitch(ledSwitch)
|
||||
mMapDeviceBean?.apply {
|
||||
mTrackerManageViewModel.setLedSwitch(null, deviceServerId, ledSwitch)
|
||||
this.ledSwitch = ledSwitch
|
||||
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
||||
setLedSwitch(ledSwitch)
|
||||
} else {
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, deviceServerId, ledSwitch, ConstantInt.Type2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -515,6 +561,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
private fun updateConState(trackBleDevice: BleTrackDeviceBean) {
|
||||
mTrackBleDevice = trackBleDevice
|
||||
if (trackBleDevice.conState == ConState.CONNECTED) {
|
||||
LogUtil.e("更新设备连接状态")
|
||||
if (isLiveJump) {
|
||||
if (isStartLive) {
|
||||
mMapLiveViewModel.stopGetData()
|
||||
@@ -535,7 +582,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
// mViewBinding.ilLiveV2BluetoothFindDevice.ivMapLiveV2BleConState.setValue(2)
|
||||
} else if (trackBleDevice.conState == ConState.CONNECTION_FAIL) {
|
||||
if (isLiveJump) {
|
||||
openNetLive()
|
||||
openNetLive(ConstantInt.Type2)
|
||||
}
|
||||
} else if (trackBleDevice.conState == ConState.DISCONNECTED) {
|
||||
if (isLiveJump && isStartLive) {
|
||||
@@ -597,7 +644,6 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
val bleConDevice = SRBleUtil.instance.getConnectMacDevice(macID)
|
||||
if (null == bleConDevice) {
|
||||
if (isLiveJump) {
|
||||
openNetLive()
|
||||
//没有连接,一进入页面就尝试连接
|
||||
mConDeviceViewModel.connectDeviceToMac(this@LiveActivityV2, macID)
|
||||
}
|
||||
@@ -841,13 +887,6 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 地图加载好了
|
||||
*/
|
||||
private fun mapLoadOk() {
|
||||
showPetNameAndHead()
|
||||
}
|
||||
|
||||
/**
|
||||
* 找蓝牙设备
|
||||
*/
|
||||
@@ -898,14 +937,19 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
||||
* 停止直播
|
||||
*/
|
||||
private fun stopLive() {
|
||||
mTrackBleDevice?.apply {
|
||||
SRBleUtil.instance.writeData(
|
||||
bleDevice, SRBleCmdUtil.instance.setLiveSwitch(0, 0)
|
||||
)
|
||||
mPetBean?.apply {
|
||||
if (BleManager.getInstance().isConnected(macID)) {
|
||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||
macID, SRBleCmdUtil.instance.setLiveSwitch(0, 0)
|
||||
)
|
||||
} else {
|
||||
mRequestModeType = ConstantInt.Type2
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, mPetBean!!.deviceId, 0, mRequestModeType
|
||||
)
|
||||
}
|
||||
}
|
||||
mMapLiveViewModel.setupDeviceLiveStatus(
|
||||
this@LiveActivityV2, mPetBean!!.deviceId, 0
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.abbidot.tracker.constant.ConstantString
|
||||
import com.abbidot.tracker.constant.GetResultCallback
|
||||
import com.abbidot.tracker.constant.MultipleEntity
|
||||
import com.abbidot.tracker.databinding.FragmentHomeTrackBinding
|
||||
import com.abbidot.tracker.deprecated.ui.activity.vm.LedLightViewModel
|
||||
import com.abbidot.tracker.dialog.DFUNewDialog
|
||||
import com.abbidot.tracker.ui.activity.HomeV2Activity
|
||||
import com.abbidot.tracker.ui.activity.device.fences.VirtualFencesActivity
|
||||
@@ -62,6 +63,7 @@ class HomeTrackFragment :
|
||||
|
||||
private val mTrackerInfoViewModel: TrackerInfoViewModel by viewModels()
|
||||
private val mTrackerSetViewModel: TrackerSetViewModel by viewModels()
|
||||
private val mLedLightViewModel: LedLightViewModel by viewModels()
|
||||
private val mConnectionDeviceViewModel: ConnectionDeviceViewModel by viewModels()
|
||||
private val mDeviceDFUViewModel: DeviceDFUViewModel by viewModels()
|
||||
private val mDownLoadFileViewModel: DownLoadFileViewModel by viewModels()
|
||||
@@ -211,20 +213,22 @@ class HomeTrackFragment :
|
||||
}
|
||||
//接收开蓝牙操作,然后搜索连接设备
|
||||
XEventBus.observe(this, EventName.ActionConDeviceState) { conState: Int ->
|
||||
if (conState == ConState.CONNECTING || conState == ConState.CONNECTING_MAC) {
|
||||
// mConnectionDeviceViewModel.connectingFailCountDown()
|
||||
mTrackStateList[4].apply {
|
||||
menuValue = getString(R.string.txt_connecting)
|
||||
colorRedId = R.color.gray
|
||||
isSwitch = true
|
||||
mHomePetTrackStateAdapter.notifyItemChanged(4)
|
||||
}
|
||||
} else {
|
||||
mTrackStateList[4].apply {
|
||||
menuValue = getString(R.string.txt_unconnect_no)
|
||||
isSwitch = false
|
||||
colorRedId = R.color.orange_color3
|
||||
mHomePetTrackStateAdapter.notifyItemChanged(4)
|
||||
mHomeV2Activity.getPet()?.apply {
|
||||
if (BleManager.getInstance().isConnected(macID)) return@apply
|
||||
if (conState == ConState.CONNECTING || conState == ConState.CONNECTING_MAC) {
|
||||
mTrackStateList[4].apply {
|
||||
menuValue = getString(R.string.txt_connecting)
|
||||
colorRedId = R.color.gray
|
||||
isSwitch = true
|
||||
mHomePetTrackStateAdapter.notifyItemChanged(4)
|
||||
}
|
||||
} else {
|
||||
mTrackStateList[4].apply {
|
||||
menuValue = getString(R.string.txt_unconnect_no)
|
||||
isSwitch = false
|
||||
colorRedId = R.color.orange_color3
|
||||
mHomePetTrackStateAdapter.notifyItemChanged(4)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,19 +328,25 @@ class HomeTrackFragment :
|
||||
mTurnoffLiveData.observe(viewLifecycleOwner) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||
mTrackMenuAdapter.notifyItemChanged(4)
|
||||
bleTurnOff()
|
||||
// mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||
// mTrackMenuAdapter.notifyItemChanged(4)
|
||||
// bleTurnOff()
|
||||
mBleTrackDeviceBean?.apply {
|
||||
SRBleUtil.instance.writeData(
|
||||
bleDevice, SRBleCmdUtil.instance.forcedShutdown()
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
mLedSwitchLiveData.observe(viewLifecycleOwner) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
mLedLightViewModel.mLedSwitchLiveData.observe(viewLifecycleOwner) {
|
||||
dealRequestResult(it, object : GetResultCallback {
|
||||
override fun onResult(any: Any) {
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,22 +731,42 @@ class HomeTrackFragment :
|
||||
)
|
||||
}
|
||||
}
|
||||
} else if (data0 == 3 && data1 == 0 && data2 == 0) {
|
||||
val data3 = SRBleCmdUtil.instance.byteToInt(data[3])
|
||||
if (data3 in 1..3) setLedState(ConstantInt.Open)
|
||||
else setLedState(ConstantInt.Close)
|
||||
} else if (data0 == 4) {
|
||||
if (data1 == 1 && data2 == 0) {
|
||||
mTrackMenuList[1].menuValue = ""
|
||||
mTrackMenuList[2].menuValue = ""
|
||||
mTrackMenuList[3].menuValue = ""
|
||||
//取消红点显示
|
||||
mTrackMenuList[3].isSwitch = false
|
||||
mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||
mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
|
||||
mBleTrackDeviceBean?.apply {
|
||||
SRBleUtil.instance.disconnectToMac(mac)
|
||||
} else if (data0 == 3 && data1 == 1) {
|
||||
val ledSwitch =
|
||||
if (mTrackStateList[5].menuValue == getString(R.string.tracker_manage_set_led_on)) {
|
||||
ConstantInt.Close
|
||||
} else {
|
||||
ConstantInt.Open
|
||||
}
|
||||
val modeType = if (data2 == 0) {
|
||||
val data3 = SRBleCmdUtil.instance.byteToInt(data[3])
|
||||
if (data3 in 1..3) setLedState(ConstantInt.Open)
|
||||
else setLedState(ConstantInt.Close)
|
||||
ConstantInt.Type1
|
||||
} else {
|
||||
ConstantInt.Type3
|
||||
}
|
||||
mMapDeviceBean?.let {
|
||||
setLedState(ledSwitch)
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, it.deviceServerId, ledSwitch, modeType
|
||||
)
|
||||
}
|
||||
} else if (data0 == 4 && data1 == 1 && data2 == 0) {
|
||||
mMapDeviceBean?.let {
|
||||
mTrackerSetViewModel.turnOff(mHomeV2Activity, it.deviceServerId)
|
||||
}
|
||||
mTrackMenuList[1].menuValue = ""
|
||||
mTrackMenuList[2].menuValue = ""
|
||||
mTrackMenuList[3].menuValue = ""
|
||||
//取消红点显示
|
||||
mTrackMenuList[3].isSwitch = false
|
||||
mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||
mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
|
||||
} else if (data0 == 0x18 && data1 == 1 && data2 == 0) {
|
||||
mBleTrackDeviceBean?.apply {
|
||||
SRBleUtil.instance.disconnectToMac(mac)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -850,16 +880,21 @@ class HomeTrackFragment :
|
||||
} else {
|
||||
ConstantInt.Open
|
||||
}
|
||||
//蓝牙控制
|
||||
getBleTrackDeviceBean(false)?.let {
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext!!, it.bleDevice, ledSwitch)
|
||||
}
|
||||
//远程控制
|
||||
mMapDeviceBean?.let {
|
||||
mTrackerSetViewModel.setLedSwitch(null, it.deviceServerId, ledSwitch)
|
||||
}
|
||||
|
||||
setLedState(ledSwitch)
|
||||
mMapDeviceBean?.let {
|
||||
if (BleManager.getInstance().isConnected(it.deviceMacId)) {
|
||||
//蓝牙控制
|
||||
getBleTrackDeviceBean(false)?.let { ble ->
|
||||
SRBleUtil.instance.setBleLedSwitch(mContext!!, ble.bleDevice, ledSwitch)
|
||||
}
|
||||
} else {
|
||||
setLedState(ledSwitch)
|
||||
//远程控制
|
||||
mLedLightViewModel.setLedSwitch(
|
||||
null, it.deviceServerId, ledSwitch, ConstantInt.Type2
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -87,13 +87,13 @@ class PetV2Fragment : BaseFragment<FragmentPetV2Binding>(FragmentPetV2Binding::i
|
||||
activity?.apply {
|
||||
mHomeV2Activity = this as HomeV2Activity
|
||||
}
|
||||
(mFragments[1] as HomeTrackFragment).onResume()
|
||||
//其他页面是否选择了宠物
|
||||
if (mCurrentShowPetPos != mHomeV2Activity.mSelectPetPosition) {
|
||||
showPetNameAndHead(mHomeV2Activity.mSelectPetPosition)
|
||||
} else {
|
||||
(mFragments[1] as HomeTrackFragment).getPetTrackerInfoData()
|
||||
}
|
||||
(mFragments[1] as HomeTrackFragment).onResume()
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
|
||||
@@ -175,13 +175,21 @@ class SRBleCmdUtil private constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 关机
|
||||
* 关机,设备会上报关机状态后关机
|
||||
*/
|
||||
fun shutdownDevice(): ByteArray {
|
||||
val byteArray = byteArrayOf(0x04, CMD_WRITE.toByte())
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 强制关机消息,设备不会上报,立马关机
|
||||
*/
|
||||
fun forcedShutdown(): ByteArray {
|
||||
val byteArray = byteArrayOf(0x18, CMD_WRITE.toByte())
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取固件版本号
|
||||
*/
|
||||
@@ -350,5 +358,14 @@ class SRBleCmdUtil private constructor() {
|
||||
val byteArray = byteArrayOf(0x13, CMD_READ.toByte(), 0)
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置/查询定位时间间隔
|
||||
*/
|
||||
fun setAndRedGpsDuration(writeAndRed: Int = CMD_WRITE, duration: Long = 0): ByteArray {
|
||||
var byteArray = byteArrayOf(0x12, writeAndRed.toByte())
|
||||
byteArray = byteArray.plus(longTo2ByteArray(duration))
|
||||
return getCrc8Cmd(byteArray)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -439,6 +439,9 @@ class SRBleUtil private constructor() {
|
||||
fun cancelBleScan(log: String = "") {
|
||||
if (BleManager.getInstance().scanSate == BleScanState.STATE_SCANNING) {
|
||||
isScanInterrupt = true
|
||||
XEventBus.post(
|
||||
EventName.ActionConDeviceState, ConState.DEVICE_NOT_FOUND
|
||||
)
|
||||
if (TextUtils.isEmpty(log)) LogUtil.e("正在扫描设备,取消蓝牙扫描")
|
||||
else LogUtil.e(log)
|
||||
BleManager.getInstance().cancelScan()
|
||||
|
||||
@@ -118,17 +118,17 @@ class ConnectionDeviceViewModel : ViewModel() {
|
||||
/**
|
||||
* 连接中倒计时20s变为未连接状态
|
||||
*/
|
||||
fun connectingFailCountDown() {
|
||||
mCountDownTimer = object : CountDownTimer(20 * 1000, 1000) {
|
||||
override fun onTick(time: Long) {
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
LogUtil.e("连接中倒计时20s变为未连接状态")
|
||||
XEventBus.post(EventName.ActionConDeviceState, ConState.CONNECTION_FAIL)
|
||||
}
|
||||
}.start()
|
||||
}
|
||||
// fun connectingFailCountDown() {
|
||||
// mCountDownTimer = object : CountDownTimer(20 * 1000, 1000) {
|
||||
// override fun onTick(time: Long) {
|
||||
// }
|
||||
//
|
||||
// override fun onFinish() {
|
||||
// LogUtil.e("连接中倒计时20s变为未连接状态")
|
||||
// XEventBus.post(EventName.ActionConDeviceState, ConState.CONNECTION_FAIL)
|
||||
// }
|
||||
// }.start()
|
||||
// }
|
||||
|
||||
/**
|
||||
* 连接成功后取消倒计时
|
||||
@@ -276,7 +276,7 @@ class ConnectionDeviceViewModel : ViewModel() {
|
||||
super.onCleared()
|
||||
LogUtil.e("ConnectionDeviceViewModel,onCleared")
|
||||
SRBleUtil.instance.isBleConnecting = false
|
||||
SRBleUtil.instance.cancelBleScan("退出APP,取消扫描蓝")
|
||||
SRBleUtil.instance.cancelBleScan("onCleared,退出当前页面,取消扫描蓝牙")
|
||||
cancelFailCountDown()
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,12 @@ class MapLiveViewModel : ViewModel() {
|
||||
/**
|
||||
* 打开关闭直播
|
||||
*/
|
||||
fun setupDeviceLiveStatus(activity: BaseActivity<*>, deviceId: String, liveState: Int) {
|
||||
fun setupDeviceLiveStatus(
|
||||
activity: BaseActivity<*>, deviceId: String, liveState: Int, modeType: Int
|
||||
) {
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setupDeviceLiveStatus(deviceId, liveState)
|
||||
val result = NetworkApi.setupDeviceLiveStatus(deviceId, liveState, modeType)
|
||||
mMapLiveStatusLiveData.value = result
|
||||
}
|
||||
}
|
||||
@@ -60,7 +62,7 @@ class MapLiveViewModel : ViewModel() {
|
||||
/**
|
||||
* 停止获取数据
|
||||
*/
|
||||
fun stopGetData() {
|
||||
fun stopGetData() {
|
||||
if (null != mCountDownTimer) {
|
||||
mCountDownTimer!!.cancel()
|
||||
mCountDownTimer = null
|
||||
|
||||
@@ -17,24 +17,12 @@ import kotlinx.coroutines.launch
|
||||
*/
|
||||
class TrackerSetViewModel : ViewModel() {
|
||||
val mAddBindDeviceLiveData = MutableLiveData<Result<DeviceDetailBean>>()
|
||||
val mLedSwitchLiveData = MutableLiveData<Result<String>>()
|
||||
val mTurnoffLiveData = MutableLiveData<Result<String>>()
|
||||
val mReportIntervalLiveData = MutableLiveData<Result<String>>()
|
||||
val mSetLiveTimeLiveData = MutableLiveData<Result<String>>()
|
||||
val mUnbindDeviceLiveData = MutableLiveData<Result<String>>()
|
||||
val mAssignOtherTrackerLiveData = MutableLiveData<Result<String>>()
|
||||
|
||||
/**
|
||||
* 设置ledSwitch开关
|
||||
*/
|
||||
fun setLedSwitch(activity: BaseActivity<*>?, deviceInfoId: String, ledSwitch: Int) {
|
||||
activity?.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.setLedSwitch(deviceInfoId, ledSwitch)
|
||||
mLedSwitchLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭设备
|
||||
*/
|
||||
@@ -49,10 +37,12 @@ class TrackerSetViewModel : ViewModel() {
|
||||
/**
|
||||
* 设置设备上报下发时间
|
||||
*/
|
||||
fun reportInterval(activity: BaseActivity<*>, deviceInfoId: String, gnssInterval: Int) {
|
||||
fun reportInterval(
|
||||
activity: BaseActivity<*>, deviceInfoId: String, gnssInterval: Int, modeType: Int
|
||||
) {
|
||||
activity.showLoading(true)
|
||||
viewModelScope.launch {
|
||||
val result = NetworkApi.reportInterval(deviceInfoId, gnssInterval)
|
||||
val result = NetworkApi.reportInterval(deviceInfoId, gnssInterval, modeType)
|
||||
mReportIntervalLiveData.value = result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<include
|
||||
android:id="@+id/il_live_v2_data_light_switch"
|
||||
layout="@layout/layout_device_light_image_button"
|
||||
android:layout_width="@dimen/dp_160"
|
||||
android:layout_width="@dimen/dp_150"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/tv_live_v2_direction_title"
|
||||
android:layout_alignEnd="@id/tv_live_v2_direction_title"
|
||||
@@ -67,7 +67,7 @@
|
||||
android:background="@drawable/shape44_gray_yellow_bg"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="@dimen/dp_40">
|
||||
android:paddingHorizontal="@dimen/dp_30">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:layout_width="@dimen/dp_10"
|
||||
|
||||
Reference in New Issue
Block a user