Skip to content

Commit

Permalink
Added thows marker and log to lower logs count
Browse files Browse the repository at this point in the history
  • Loading branch information
Corwin-Kh committed Nov 18, 2024
1 parent 967a62a commit c13c53d
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ import okio.sink
import okio.source
import org.json.JSONObject
import java.util.UUID
import kotlin.jvm.Throws

class VehicleMetricsPlugin(app: OsmandApplication) : OsmandPlugin(app), OBDReadStatusListener {
private var mapActivity: MapActivity? = null
Expand Down Expand Up @@ -307,7 +308,6 @@ class VehicleMetricsPlugin(app: OsmandApplication) : OsmandPlugin(app), OBDReadS

@MainThread
fun disconnect(forgetCurrentDeviceConnected: Boolean) {
LOG.debug("disconnect $forgetCurrentDeviceConnected")
obdDispatcher?.stopReading()
val lastConnectedDeviceInfo = connectedDeviceInfo
connectedDeviceInfo = null
Expand Down Expand Up @@ -355,14 +355,14 @@ class VehicleMetricsPlugin(app: OsmandApplication) : OsmandPlugin(app), OBDReadS
@SuppressLint("MissingPermission")
@MainThread
private fun connectToObdInternal(activity: Activity, deviceInfo: BTDeviceInfo) {
LOG.debug("connectToObd $deviceInfo reconnectCount $currentReconnectAttempt")
if (connectionState != OBDConnectionState.DISCONNECTED) {
disconnect(false)
}
currentReconnectAttempt--
if (currentReconnectAttempt <= 0) {
return
}
LOG.debug("connectToObd $deviceInfo reconnectCount $currentReconnectAttempt")
if (BLEUtils.isBLEEnabled(activity)) {
if (AndroidUtils.hasBLEPermission(activity)) {
onConnecting(deviceInfo)
Expand Down Expand Up @@ -435,6 +435,7 @@ class VehicleMetricsPlugin(app: OsmandApplication) : OsmandPlugin(app), OBDReadS
socket = connectedDevice.createRfcommSocketToServiceRecord(uuid)
}

@Throws(IOException::class)
override fun connect(): Pair<Source, Sink>? {
socket?.apply {
connect()
Expand Down

0 comments on commit c13c53d

Please sign in to comment.