Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/main/res/values-pl/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<string name="pref.connection.connection_type_dialog">Wybierz typ połączenia adaptera OBD</string>
<string name="pref.connection.connection_type"><b><font color='#01804F'>Typ połączenia adaptera OBD</font></b></string>
<string name="pref.connection.connection_timeout">Limit czasu połączenia</string>
<string name="pref.adapter.type">Typ adaptera</string>

<string name="pref.adapter_id">Dostępne urządzenia Bluetooth</string>
<string name="pref.gauge.number_of_columns">Liczba kolumn</string>
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@

<string name="pref.adapter_init_protocol">Protocol</string>
<string name="pref.adapter_init_sequence">Init Sequence</string>
<string name="pref.adapter.type">Adapter Type</string>

<string name="pref.general_settings">General settings</string>
<string name="pref.adapter.general_settings">Advanced settings</string>
Expand Down Expand Up @@ -771,6 +772,16 @@
<item name="CH_CAN" tools:ignore="Typos">CH_CAN</item>
</string-array>

<string-array name="pref.adapter_type_entries">
<item>Default Adapter</item>
<item>VGate vLinker MS</item>
</string-array>

<string-array name="pref.adapter_type_values">
<item>DEFAULT</item>
<item>VGATE_VLINKER_MS</item>
</string-array>


<!-- Extracted from layouts -->
<string name="dtc.freeze_frame_data">UDS Freeze Frame Data</string>
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@
app:singleLineTitle="false"
app:title="@string/pref.connection.category">

<ListPreference
android:defaultValue="DEFAULT"
android:entries="@array/pref.adapter_type_entries"
android:entryValues="@array/pref.adapter_type_values"
android:key="pref.adapter.type"
android:title="@string/pref.adapter.type"
app:useSimpleSummaryProvider="true" />

<ListPreference
android:defaultValue="1000"
android:dialogTitle="@string/pref.connection.connection_timeout"
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ allprojects {
google()
mavenCentral()
maven { url 'https://central.sonatype.com/repository/maven-snapshots' }
maven { url 'https://jitpack.io' }
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://jitpack.io' }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ data class Adapter(
@XmlPreference("pref.adapter.init.sequence", "DEFAULT", String::class)
var initSequence: String = "DEFAULT",

@XmlPreference("pref.adapter.type", "DEFAULT", String::class)
var type: String = "DEFAULT",

@XmlPreference("pref.adapter.reconnect.max_retry", "0", Int::class)
var maxReconnectNum: Int = 0,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import org.obd.graphs.bl.datalogger.connectors.ConnectionManager
import org.obd.graphs.bl.query.Query
import org.obd.graphs.bl.trip.tripManager
import org.obd.graphs.profile.PROFILE_CHANGED_EVENT
import org.obd.metrics.api.CANNetworkRegistry
import org.obd.metrics.api.DefaultCanNetworkRegistry
import org.obd.metrics.api.Workflow
import org.obd.metrics.api.WorkflowExecutionStatus
import org.obd.metrics.api.model.*
Expand Down Expand Up @@ -314,11 +316,38 @@ internal class WorkflowOrchestrator internal constructor() {
Init.Header.builder().mode(entry.key).header(entry.value).build()
}.toMutableList())
.protocol(Init.Protocol.valueOf(preferences.adapter.initProtocol))
.networkRegistry(networkRegistry(preferences.adapter.type))
.sequence(sequence(preferences.adapter.initSequence)).build()

return init
}

private fun networkRegistry(adapterType : String): CANNetworkRegistry {
Log.i(LOG_TAG,"Selected adapter type $adapterType")

return when (adapterType) {
"DEFAULT" -> {
DefaultCanNetworkRegistry()
}

"VGATE_VLINKER_MS" -> {
runCatching {
val clazz = Class.forName("org.obd.metrics.init.VgateVlinkerMsCANNetworkRegistry")
val defaultField = clazz.getDeclaredField("DEFAULT")
defaultField.get(null) as CANNetworkRegistry
}.getOrElse { exception ->
Log.e(LOG_TAG, "Reflection failed: ${exception.message}. Falling back to DefaultCanNetworkRegistry.")
DefaultCanNetworkRegistry()
}
}

else -> {
DefaultCanNetworkRegistry()
}
}
}


private fun sequence(seqName : String): CommandGroup<out Command?> =
if (seqName == "DEFAULT") {
DefaultCommandGroup.INIT
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
obdMetricVersion=11.19.0-SNAPSHOT
obdMetricVersion=11.21.0-SNAPSHOT
Loading