Skip to content

Commit

Permalink
First version
Browse files Browse the repository at this point in the history
  • Loading branch information
MacFJA committed Nov 12, 2018
0 parents commit db5f52f
Show file tree
Hide file tree
Showing 13 changed files with 1,553 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Created by .ignore support plugin (hsz.mobi)
### Maven template
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar

21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The MIT License (MIT)

Copyright (c) 2018 [MacFJA](https://github.com/MacFJA)

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
100 changes: 100 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# OB2 Service

OBD2 Service is a small service around the library [io.github.macfja.obd2](https://github.com/MacFJA/OBD2).

## Usage

```java
import io.github.macfja.obd2.Command;
import io.github.macfja.obd2.Response;
import io.github.macfja.obd2.command.DTCsCommand;
import io.github.macfja.obd2.command.livedata.VehicleSpeed;
import io.github.macfja.obd2.elm327.Commander;
import io.github.macfja.obd2.response.MultipleDiagnosticTroubleCodeResponse;
import io.github.macfja.obd2.service.Obd2Service;
import io.github.macfja.obd2.service.ObdObserver;
import io.github.macfja.obd2.service.ObdObserverIgnoreError;
import io.github.macfja.obd2.service.Service;

public class Example {
public static void main(String[] args) {
new Example();
}

public Example()
{
Obd2Service service = new Service(new Commander());
service.setCommunication(OBD.toComponent, OBD.fromComponent);

service.schedule(VehicleSpeed.class, 5, new ObdObserver() {
@Override
public void update(Response response) {
System.out.println(String.format("You are driving at: %s", response.getFormattedString()));
}

@Override
public void error(Command request, Response response, Exception exception) {
System.err.println(String.format("Unable to read vehicle speed: %s", exception.getLocalizedMessage()));
}
});

service.addObserver(DTCsCommand.class, new ObdObserverIgnoreError() {
@Override
public void update(Response response) {
if (response instanceof MultipleDiagnosticTroubleCodeResponse) {
System.out.println(String.format(
"DTCs have been requested. Here the result: %d DTC",
((MultipleDiagnosticTroubleCodeResponse) response).getTroubleCodes().size()
));
}
}
});
}
}
```

## Installation

To install this library you need to first have [io.github.macfja.obd2](https://github.com/MacFJA/OBD2) available.
The library is mandatory. See [OBD2 for Java README](https://github.com/MacFJA/OBD2) for more detail on how install it.
(Notice: JitPack will not work, because the groupId and artifactId are changed)

### From the sources

Clone the project:
```
git clone https://github.com/MacFJA/OBD2Service.git
```
Install the project into your local Maven repository:
```
cd OBD2Service/
mvn clean
mvn install
```
Remove the source:
```
cd ..
rm -r OBD2Service/
```
Add the dependency in your Maven project:
```xml
<project>
<!-- ... -->
<dependencies>
<!-- ... -->
<dependency>
<groupId>io.github.macfja</groupId>
<artifactId>obd2-service</artifactId>
<version>1.0.0</version>
</dependency>
<!-- ... -->
</dependencies>
<!-- ... -->
</project>
```

### From a release

Go to the [releases page](https://github.com/MacFJA/OBD2Service/releases), and download the **jar**.

Next add the **jar** in your project classpath.
158 changes: 158 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.github.macfja</groupId>
<artifactId>obd2-service</artifactId>
<version>1.0.0</version>
<name>OBD2 Service</name>
<description>A Service for the OBD2 library</description>
<url>https://github.com/MacFJA/OBD2Service</url>

<issueManagement>
<url>https://github.com/MacFJA/OBD2Service/issues</url>
<system>GitHub Issues</system>
</issueManagement>

<licenses>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<url>https://github.com/MacFJA/OBD2Service</url>
<connection>scm:git:git://github.com/MacFJA/OBD2Service.git</connection>
<developerConnection>scm:git:[email protected]:MacFJA/OBD2Service.git</developerConnection>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<jdk.version>1.7</jdk.version>
<junit.version>4.12</junit.version>
<mockito.version>2.23.0</mockito.version>
<slf4j.version>1.7.25</slf4j.version>
<obd2.version>1.1.0</obd2.version>

<maven-plugin.compiler.version>3.8.0</maven-plugin.compiler.version>
<maven-plugin.javadoc.version>3.0.1</maven-plugin.javadoc.version>
<maven-plugin.source.version>3.0.1</maven-plugin.source.version>
<maven-plugin.assembly.version>3.1.0</maven-plugin.assembly.version>
<maven-plugin.surefire.version>2.22.1</maven-plugin.surefire.version>
</properties>

<dependencies>
<dependency>
<groupId>io.github.macfja</groupId>
<artifactId>obd2</artifactId>
<version>${obd2.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
<scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!-- Fix java version -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-plugin.compiler.version}</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<!-- JavaDoc Generation -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven-plugin.javadoc.version}</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Source Jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven-plugin.source.version}</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- All in one Jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-plugin.assembly.version}</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Test -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-plugin.surefire.version}</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<parallel>methods</parallel>
<threadCount>2</threadCount>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit db5f52f

Please sign in to comment.