Skip to content

Commit a38fa6b

Browse files
authored
API Revamp (#1)
* Convert modules into packages * Fix ObdDeviceConnection class * Remove unneeded mavenCentral() * Fix VIN command * Fix AT commands * Fix trouble codes command * Change version number
1 parent 606d5ae commit a38fa6b

File tree

33 files changed

+46
-66
lines changed

33 files changed

+46
-66
lines changed

build.gradle.kts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
22

33
plugins {
4-
kotlin("jvm") version "1.3.21"
4+
kotlin("jvm") version "1.3.61"
55
}
66

77
group = "com.github.eltonvs.obd"
8-
version = "0.0.1"
8+
version = "1.0.0"
99

1010
repositories {
11-
mavenCentral()
11+
jcenter()
1212
}
1313

1414
dependencies {
15-
implementation(kotlin("stdlib-jdk8"))
15+
implementation(kotlin("stdlib"))
16+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3")
17+
testImplementation(kotlin("test"))
18+
testImplementation(kotlin("test-junit"))
1619
}
1720

1821
tasks.withType<KotlinCompile> {

command/build.gradle.kts

Lines changed: 0 additions & 22 deletions
This file was deleted.

connection/build.gradle.kts

Lines changed: 0 additions & 22 deletions
This file was deleted.

settings.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
rootProject.name = "kotlin-obd-api"
2-
include("command", "connection")

command/src/main/kotlin/com/github/eltonvs/obd/command/ATCommand.kt renamed to src/main/kotlin/com/github/eltonvs/obd/command/ATCommand.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ package com.github.eltonvs.obd.command
33

44
abstract class ATCommand : ObdCommand() {
55
override val mode = "AT"
6+
override val skipDigitCheck = true
67
}

command/src/main/kotlin/com/github/eltonvs/obd/command/Exceptions.kt renamed to src/main/kotlin/com/github/eltonvs/obd/command/Exceptions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ abstract class BadResponseException(private val command: ObdCommand, private val
3333
throw UnknownErrorException(command, response)
3434
matches(UNSUPPORTED_COMMAND_MESSAGE_PATTERN.toRegex()) ->
3535
throw UnSupportedCommandException(command, response)
36-
!matches(DIGITS_LETTERS_PATTERN.toRegex()) ->
36+
!command.skipDigitCheck && !matches(DIGITS_LETTERS_PATTERN.toRegex()) ->
3737
throw NonNumericResponseException(command, response)
3838
else -> response
3939
}

command/src/main/kotlin/com/github/eltonvs/obd/command/ObdCommand.kt renamed to src/main/kotlin/com/github/eltonvs/obd/command/ObdCommand.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ abstract class ObdCommand {
88
abstract val pid: String
99

1010
open val defaultUnit: String = ""
11+
open val skipDigitCheck: Boolean = false
1112
open val handler: (ObdRawResponse) -> String = { it.value }
1213

1314
val rawCommand: String

command/src/main/kotlin/com/github/eltonvs/obd/command/RegexUtils.kt renamed to src/main/kotlin/com/github/eltonvs/obd/command/RegexUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,7 @@ object RegexPatterns {
2626

2727
fun removeAll(pattern: Pattern, input: String): String {
2828
return pattern.matcher(input).replaceAll("")
29-
}
29+
}
30+
31+
fun removeAll(input: String, vararg patterns: Pattern) =
32+
patterns.fold(input) { acc, pattern -> removeAll(pattern, acc) }

0 commit comments

Comments
 (0)