1.增加G40蓝牙日志上报
This commit is contained in:
@@ -32,7 +32,8 @@ public class TopSlideLayoutManager extends LinearLayoutManager {
|
||||
View firstChild = getChildAt(0);
|
||||
if (firstChild != null) {
|
||||
int top = getDecoratedTop(firstChild) - mTopOffset;
|
||||
layoutDecoratedWithMargins(firstChild, firstChild.getLeft(), top, firstChild.getRight(), top + firstChild.getHeight());
|
||||
layoutDecoratedWithMargins(firstChild, firstChild.getLeft(), top,
|
||||
firstChild.getRight(), top + firstChild.getHeight());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -310,7 +310,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
//蓝牙连接就去连接socket
|
||||
// mBleReportManage.dealBleReportData(macID, null)
|
||||
} else {
|
||||
mLogBleReportViewModel.uploadLog(mContext, macID)
|
||||
mLogBleReportViewModel.uploadLog(mContext, macID,deviceOutId)
|
||||
startCountDownConBle(15)
|
||||
}
|
||||
}
|
||||
@@ -454,7 +454,7 @@ class HomeV2Activity : BaseActivity<ActivityHomeV2Binding>(ActivityHomeV2Binding
|
||||
packageUnavailableState()
|
||||
//刚开始打开APP上传日志
|
||||
getPet(false)?.apply {
|
||||
mLogBleReportViewModel.uploadLog(mContext, macID)
|
||||
mLogBleReportViewModel.uploadLog(mContext, macID,deviceOutId)
|
||||
}
|
||||
} else {
|
||||
onChangeClick(mSelectPetPosition)
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.abbidot.tracker.vm.GeoCoderViewModel
|
||||
import com.abbidot.tracker.widget.NoClickSlideSeekBar
|
||||
import com.abbidot.tracker.widget.TypefaceTextView
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlin.math.abs
|
||||
|
||||
|
||||
/**
|
||||
@@ -156,6 +157,7 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
val dy = mLastY - event.rawY
|
||||
if (abs(dy) >50){
|
||||
val layoutParams = svHomeRouteMapScroll.layoutParams
|
||||
val diff = (svHomeRouteMapScroll.height + dy).toInt()
|
||||
isSlideUp = dy >= 0.0f
|
||||
@@ -170,6 +172,7 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
|
||||
mLastY = event.rawY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP -> {
|
||||
LogUtil.e("ACTION_UP")
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.abbidot.baselibrary.util.AppUtils
|
||||
import com.abbidot.baselibrary.util.LogUtil
|
||||
import com.abbidot.tracker.bean.BleTrackDeviceBean
|
||||
import com.abbidot.tracker.bean.ReceiveDeviceData
|
||||
import com.abbidot.tracker.util.SocketUtilManage
|
||||
import com.abbidot.tracker.util.SocketUtilManageV2
|
||||
import com.abbidot.tracker.util.Util
|
||||
import com.clj.fastble.BleManager
|
||||
@@ -68,8 +67,12 @@ class SRBleUtil private constructor() {
|
||||
UUID.fromString("6e400004-b5a3-f393-e0a9-e50e24dcca9e").toString()
|
||||
|
||||
//日志上报notify
|
||||
private val logNotifyCharacteristicUUID =
|
||||
private val logG30NotifyCharacteristicUUID =
|
||||
UUID.fromString("6e400005-b5a3-f393-e0a9-e50e24dcca9e").toString()
|
||||
private val logG40ServiceUUID =
|
||||
UUID.fromString("0000d0d0-0000-1000-8000-00805f9b34fb").toString()
|
||||
private val logG40NotifyCharacteristicUUID =
|
||||
UUID.fromString("0000d0d2-0000-1000-8000-00805f9b34fb").toString()
|
||||
|
||||
//保存已连接成功设备的全局变量
|
||||
private val mTrackDeviceList = mutableListOf<BleTrackDeviceBean>()
|
||||
@@ -192,11 +195,11 @@ class SRBleUtil private constructor() {
|
||||
* 打开通道通知
|
||||
*/
|
||||
fun openNotify(
|
||||
bleDevice: BleDevice, gatt: BluetoothGatt, uuid_service: String, uuid_notify: String
|
||||
bleDevice: BleDevice, gatt: BluetoothGatt, uuidService: String, uuidNotify: String
|
||||
) {
|
||||
val notifyId = uuid_notify.split("-")[0]
|
||||
val notifyId = uuidNotify.split("-")[0]
|
||||
BleManager.getInstance()
|
||||
.notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() {
|
||||
.notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() {
|
||||
override fun onNotifySuccess() {
|
||||
LogUtil.e("onNotifySuccess:${bleDevice.name}--${bleDevice.mac}")
|
||||
//绑定
|
||||
@@ -250,18 +253,22 @@ class SRBleUtil private constructor() {
|
||||
* 打开蓝牙日志上报通道
|
||||
*/
|
||||
private fun openBleReportNotify(
|
||||
bleDevice: BleDevice, uuid_service: String, uuid_notify: String
|
||||
bleDevice: BleDevice, uuidService: String, uuidNotify: String
|
||||
) {
|
||||
BleManager.getInstance()
|
||||
.notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() {
|
||||
.notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() {
|
||||
override fun onNotifySuccess() {
|
||||
LogUtil.e("打开蓝牙上报通道成功:${bleDevice.name}--${bleDevice.mac}")
|
||||
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
|
||||
openG30LogReportNotify(
|
||||
bleDevice, notifyServiceUUID, logG30NotifyCharacteristicUUID
|
||||
)
|
||||
}
|
||||
|
||||
override fun onNotifyFailure(exception: BleException?) {
|
||||
LogUtil.e("打开蓝牙上报通道失败:${bleDevice.mac},$exception")
|
||||
openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID)
|
||||
openG30LogReportNotify(
|
||||
bleDevice, notifyServiceUUID, logG30NotifyCharacteristicUUID
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCharacteristicChanged(data: ByteArray?) {
|
||||
@@ -276,13 +283,44 @@ class SRBleUtil private constructor() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开日志上报通道
|
||||
* 打开g30日志上报通道
|
||||
*/
|
||||
private fun openLogReportNotify(
|
||||
bleDevice: BleDevice, uuid_service: String, uuid_notify: String
|
||||
private fun openG30LogReportNotify(
|
||||
bleDevice: BleDevice, uuidService: String, uuidNotify: String
|
||||
) {
|
||||
BleManager.getInstance()
|
||||
.notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() {
|
||||
.notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() {
|
||||
override fun onNotifySuccess() {
|
||||
LogUtil.e("打开日志上报通道成功:${bleDevice.name}--${bleDevice.mac}")
|
||||
notifyDeviceState(bleDevice, ConState.CONNECTED)
|
||||
}
|
||||
|
||||
override fun onNotifyFailure(exception: BleException?) {
|
||||
LogUtil.e("打开日志上报通道失败:${bleDevice.mac},$exception")
|
||||
openG40LogReportNotify(
|
||||
bleDevice,
|
||||
logG40ServiceUUID,
|
||||
logG40NotifyCharacteristicUUID
|
||||
)
|
||||
}
|
||||
|
||||
override fun onCharacteristicChanged(data: ByteArray?) {
|
||||
data?.apply {
|
||||
val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac)
|
||||
XEventBus.post(EventName.LogReport, deviceData)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开g40日志上报通道
|
||||
*/
|
||||
private fun openG40LogReportNotify(
|
||||
bleDevice: BleDevice, uuidService: String, uuidNotify: String
|
||||
) {
|
||||
BleManager.getInstance()
|
||||
.notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() {
|
||||
override fun onNotifySuccess() {
|
||||
LogUtil.e("打开日志上报通道成功:${bleDevice.name}--${bleDevice.mac}")
|
||||
notifyDeviceState(bleDevice, ConState.CONNECTED)
|
||||
@@ -295,9 +333,6 @@ class SRBleUtil private constructor() {
|
||||
|
||||
override fun onCharacteristicChanged(data: ByteArray?) {
|
||||
data?.apply {
|
||||
// val formatData = HexUtil.formatHexString(data, true)
|
||||
// LogUtil.e("接收日志上报通道数据:${bleDevice.mac},$formatData")
|
||||
// LogUtil.e(String(data, Charsets.UTF_8))
|
||||
val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac)
|
||||
XEventBus.post(EventName.LogReport, deviceData)
|
||||
}
|
||||
@@ -308,8 +343,8 @@ class SRBleUtil private constructor() {
|
||||
/**
|
||||
* 关闭通道通知
|
||||
*/
|
||||
fun closeNotify(bleDevice: BleDevice, uuid_service: String, uuid_notify: String) {
|
||||
BleManager.getInstance().stopNotify(bleDevice, uuid_service, uuid_notify)
|
||||
fun closeNotify(bleDevice: BleDevice, uuidService: String, uuidNotify: String) {
|
||||
BleManager.getInstance().stopNotify(bleDevice, uuidService, uuidNotify)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class LogBleReportViewModel : ViewModel() {
|
||||
/**
|
||||
* 设备日志上传
|
||||
*/
|
||||
fun uploadLog(context: Context, mac: String) {
|
||||
fun uploadLog(context: Context, mac: String, deviceOutId: String) {
|
||||
//是否有网络功能
|
||||
if (QMUIDisplayHelper.hasInternet(context)) {
|
||||
viewModelScope.launch {
|
||||
@@ -72,7 +72,8 @@ class LogBleReportViewModel : ViewModel() {
|
||||
fileName
|
||||
)
|
||||
if (file.exists()) {
|
||||
val newFileName = "${mac}_${System.currentTimeMillis()}.txt"
|
||||
val newFileName =
|
||||
"${deviceOutId}_${mac}_${System.currentTimeMillis() / 1000}.txt"
|
||||
val newFile = File(
|
||||
FileUtil.getDiskCacheDirectory(
|
||||
context, FileUtil.LOG_DIRECTORY_NAME
|
||||
|
||||
Reference in New Issue
Block a user