Skip to content

Commit 9437e70

Browse files
authored
Merge pull request #4 from barnhill/cleanup
Cleanup and update dependencies
2 parents b7c7294 + 27e4d77 commit 9437e70

File tree

20 files changed

+118
-106
lines changed

20 files changed

+118
-106
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
![AndroidOBD CI](https://github.com/barnhill/AndroidOBD/workflows/AndroidOBD%20CI/badge.svg) [![API](https://img.shields.io/badge/API-17%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=17)
1+
![AndroidOBD CI](https://github.com/barnhill/AndroidOBD/workflows/AndroidOBD%20CI/badge.svg) [![API](https://img.shields.io/badge/API-24%2B-brightgreen.svg?style=flat)](https://android-arsenal.com/api?level=24)
22

33
## Android OBD Library
44

@@ -9,14 +9,28 @@ This project offers a developer friendly interface to communicate with ELM 327 O
99

1010
### Usage ###
1111

12-
To use:
12+
Add Dependency:
1313
```Gradle
14-
implementation 'com.pnuema.android:obd:1.0.4'
14+
implementation 'com.pnuema.android:obd:1.2.0'
1515
```
1616

17-
### Contribution guidelines ###
17+
Code:
18+
```
19+
//Request MODE 1, PID 0C - RPM
20+
val pid = PID(ObdModes.MODE_01, "0C")
21+
val command = OBDCommand(pid)
22+
command.run(bluetoothSocket.inputStream, bluetoothSocket.outputStream)
23+
24+
Log.d("PID", "${pid.description} : ${pid.calculatedResult}")
25+
Log.d("PID Formatted Result", command.formattedResult)
26+
```
1827

19-
TODO
28+
```
29+
//Clear DTCs - NonPermanent
30+
val pid = PID(ObdModes.MODE_04) //Clear DTCs
31+
val command = OBDCommand(pid)
32+
command.run(bluetoothSocket.inputStream, bluetoothSocket.outputStream)
33+
```
2034

2135
### Who do I talk to? ###
2236

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ apply plugin: "com.vanniktech.maven.publish"
33

44
// Top-level build file where you can add configuration options common to all sub-projects/modules.
55
wrapper {
6-
gradleVersion = '7.4'
6+
gradleVersion = '7.5.1'
77
}
88

99
buildscript {
10-
ext.kotlin_version = '1.6.10'
10+
ext.kotlin_version = '1.7.10'
1111
repositories {
1212
google()
1313
mavenCentral()
1414
mavenLocal()
1515
}
1616
dependencies {
17-
classpath 'com.android.tools.build:gradle:7.0.4'
17+
classpath 'com.android.tools.build:gradle:7.2.2'
1818
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1919
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
20-
classpath "org.jetbrains.dokka:dokka-gradle-plugin:$kotlin_version"
21-
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.18.0'
20+
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.6.0"
21+
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.20.0'
2222
}
2323
}
2424

gradle.properties

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
# org.gradle.parallel=true
1919

2020
android.enableJetifier=true
21-
org.gradle.jvmargs=-Xmx2548M -Dkotlin.daemon.jvm.options\="-Xmx2548M"
21+
org.gradle.jvmargs=-Xmx1548M -Dkotlin.daemon.jvm.options\="-Xmx2548M"
2222
android.useAndroidX=true
2323
org.gradle.caching=true
2424

25+
android.disableAutomaticComponentCreation=true
26+
2527
GROUP=com.pnuema.android
26-
VERSION_NAME=1.0.4
28+
VERSION_NAME=1.2.0
2729

2830
POM_NAME=Android OBD Library
2931
POM_ARTIFACT_ID=obd
@@ -40,4 +42,7 @@ POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
4042
POM_LICENCE_DIST=repo
4143
POM_DEVELOPER_ID=barnhill
4244
POM_DEVELOPER_NAME=Brad Barnhill
43-
POM_DEVELOPER_URL=https://github.com/barnhill/
45+
POM_DEVELOPER_URL=https://github.com/barnhill/
46+
47+
SONATYPE_HOST=DEFAULT
48+
RELEASE_SIGNING_ENABLED=true

gradle/wrapper/gradle-wrapper.jar

935 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gradlew.bat

Lines changed: 8 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

obd/build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'kotlinx-serialization'
55
apply plugin: 'org.jetbrains.dokka'
66
apply plugin: "com.vanniktech.maven.publish"
77

8-
version = "1.0.4"
8+
version = "1.2.0"
99
group = "com.pnuema.android"
1010

1111
ext {
@@ -16,11 +16,11 @@ ext {
1616
}
1717

1818
android {
19-
compileSdkVersion 31
19+
compileSdkVersion 33
2020

2121
defaultConfig {
22-
minSdkVersion 17
23-
targetSdkVersion 31
22+
minSdkVersion 24
23+
targetSdkVersion 33
2424
versionCode 1
2525
versionName version
2626
}
@@ -39,13 +39,12 @@ android {
3939

4040
kotlinOptions {
4141
jvmTarget = JavaVersion.VERSION_11.toString()
42-
useIR = true
4342
}
4443
}
4544

4645
dependencies {
47-
implementation 'com.udojava:EvalEx:2.6'
48-
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0'
46+
implementation 'com.udojava:EvalEx:2.7'
47+
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2'
4948
implementation "androidx.startup:startup-runtime:1.1.1"
5049
}
5150

obd/src/main/java/com/pnuema/android/obd/ObdInitializer.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import com.pnuema.android.obd.statics.ObdLibrary
88
@Suppress("unused") //inited in the manifest
99
class ObdInitializer: Initializer<Context> {
1010
override fun create(context: Context): Context {
11-
ObdLibrary.init(context as? Application ?: error("ObdLibrary could not be initialized"))
11+
ObdLibrary.init(context as Application)
1212
return context
1313
}
1414

obd/src/main/java/com/pnuema/android/obd/commands/BaseObdCommand.kt

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
* License for the specific language governing permissions and limitations under
1111
* the License.
1212
*/
13+
@file:Suppress("unused")
14+
1315
package com.pnuema.android.obd.commands
1416

1517
import com.pnuema.android.obd.models.PID
1618
import com.pnuema.android.obd.statics.PersistentStorage
17-
import java.io.*
18-
import java.util.*
19+
import java.io.BufferedReader
20+
import java.io.IOException
21+
import java.io.InputStream
22+
import java.io.InputStreamReader
23+
import java.io.OutputStream
1924
import kotlin.system.measureTimeMillis
2025

2126
/**
@@ -41,7 +46,7 @@ abstract class BaseObdCommand {
4146

4247
private fun readPersistent() {
4348
if (mPid.isPersistent && PersistentStorage.containsPid(mPid)) {
44-
mPid.calculatedResult = PersistentStorage.getElement(mPid)?.calculatedResult?:0f
49+
mPid.calculatedResult = PersistentStorage.getElement(mPid)?.calculatedResult ?: 0f
4550
mPid.calculatedResultString = PersistentStorage.getElement(mPid)?.calculatedResultString
4651
mPid.data = PersistentStorage.getElement(mPid)?.data
4752
}
@@ -98,7 +103,7 @@ abstract class BaseObdCommand {
98103
*
99104
* @param other the ObdCommand to copy.
100105
*/
101-
constructor(other: BaseObdCommand) : this(other.cmd) {}
106+
constructor(other: BaseObdCommand) : this(other.cmd)
102107

103108
/**
104109
* This method exists so that for each command, there must be a method that is
@@ -168,18 +173,10 @@ abstract class BaseObdCommand {
168173
private fun fillBuffer() {
169174
// read string each two chars
170175
buffer.clear()
171-
val data = rawData ?: return
172-
var begin = 0
173-
var end = 2
174-
while (end <= data.length) {
176+
rawData?.chunked(2)?.forEach {
175177
try {
176-
buffer.add(Integer.decode("0x" + data.substring(begin, end)))
177-
} catch (e: NumberFormatException) {
178-
break
179-
}
180-
181-
begin = end
182-
end += 2
178+
buffer.add(Integer.decode("0x$it"))
179+
} catch (e: NumberFormatException) { return }
183180
}
184181
}
185182

0 commit comments

Comments
 (0)