Skip to content

Commit 438aa63

Browse files
author
Powell Kinney
committed
Initial commit
0 parents  commit 438aa63

40 files changed

+3104
-0
lines changed

LICENSE

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Vinli
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Vinli Platform Documentation
2+
3+
This repository is the collection of documentation that describes how to interact with the Vinli Platform and devices. The compiled documentation is hosted at http://docs.vin.li.
4+
5+
If you have any questions that aren't covered, head over to our discussion repo https://github.com/vinli/discuss.
6+
7+
## Contributing
8+
9+
If you would like to help make this documentation better by fixing a type or adding some additional description around a subject, please do. Fork and submit a pull request and we'll pull it in as soon as we can.

_static/css/sphinx_rtd_theme.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@import url("https://media.readthedocs.org/css/sphinx_rtd_theme.css");
2+
3+
4+
.wy-side-nav-search {
5+
background: red !important;
6+
}

android/general/00_overview.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Overview
2+
========
3+
4+
The Vinli Android SDKs utilize the excellent [RxJava library](https://github.com/ReactiveX/RxJava) to provide a reactive interface through which apps may access both the physical Vinli Device and the Vinli Web APIs. Following reactive principles allows the Vinli SDKs to gracefully clear the asynchronous hurdles inherent in bluetooth device communication. For a lengthier explaination of the benefits of reactive APIs, [Couchbase has a great blog post](http://blog.couchbase.com/why-couchbase-chose-rxjava-new-java-sdk).
5+
6+
The Vinli Android SDK is split into two pieces, Net and Direct. The Net SDK provides access to the backend APIs--including authentication, device information, and diagnostic services. The Direct SDK provides direct access to Vinli Basic devices. Through the Direct SDK, apps can discover Vinli devices, query device information, and observe realtime vehicle telemetry.

android/general/01_direct.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
Direct SDK
2+
==========
3+
4+
The first step to access Vinli Devices is to discover available Vinli Devices in the area.
5+
6+
7+
Observer<Device> devices = VinliDevices.createDeviceObservable(activity);
8+
9+
10+
Calling `VinliDevices#createDeviceObservable` returns an `Observer` of devices that will report available devices as they are discovered.
11+
12+
Once a device is obtained, the developer needs to create a `DeviceInterface` by calling `Device#createDeviceInterface` with their current Android context.
13+
14+
To obtain relatively static information such as VIN, device ID, and DTC codes, the device interface exposes `Device#readVin`, `Device#readChipId`, and `Device#readDtcCodes`, respectively
15+
16+
Frequently updated information is accessed by supplying the `Pid` (for Parameter IDs) constant corresponding to the desired vehicle data. To observe realtime changes to the data, pass the desired `Pid` to `DeviceInterface#observe`. To synchronously retrieve the latest value for a parameter, pass the desired `Pid` to `DeviceInterface#getLatest`. Examples of available `Pid` constants include `Pid.Rpm` and `Pid.Speed_Mph`
17+
18+
* To observe realtime streams of frequently updated device characteristic, the device interface provides `Device#observe{{characteristic}}` methods for each available charateristic, e.g. `Device#observeRpm` and `Device#observeSpeedMph`
19+
* To synchronously get only the latest observed value raw OBD value for a characteristic, the device interface exposes a `Device#getLatest{{characteristic}}` method for each available characteristic, e.g. `Device#getLatestRpm` and `Device#getLatestSpeed`
20+
21+
Example Android fragment to show a device's vehicle's VIN, RPM, and speed:
22+
23+
24+
public class DeviceDetailFragment extends Fragment {
25+
public static final String DEVICE = "vinli_device";
26+
27+
private final List<Subscription> mCreatedSubscriptions = new ArrayList<Subscription>();
28+
private final List<Subscription> mVisibleSubscriptions = new ArrayList<Subscription>();
29+
30+
private Device mDevice;
31+
private DeviceInterface mDi;
32+
33+
@Override public void onCreate(Bundle savedInstanceState) {
34+
super.onCreate(savedInstanceState);
35+
if (getArguments().containsKey(ARG_ITEM_ID)) {
36+
mDevice = getArguments().getParcelable(ARG_ITEM_ID);
37+
mDi = mDevice.createDeviceInterface(getActivity());
38+
} else {
39+
throw new IllegalArgumentException("missing device");
40+
}
41+
}
42+
43+
@Override public View onCreateView(LayoutInflater inflater, ViewGroup
44+
container, Bundle savedInstanceState) {
45+
final View rootView = inflater.inflate(R.layout.fragment_device_detail, container, false);
46+
47+
((TextView) rootView.findViewById(R.id.name)).setText(mDevice.getName());
48+
49+
final TextView vin = (TextView) rootView.findViewById(R.id.vin);
50+
mCreatedSubscriptions.add(AndroidObservable.bindFragment(this, mDi.readVin())
51+
.subscribe(new Observer<String>() {
52+
@Override public void onCompleted() {}
53+
@Override public void onError(Throwable e) {
54+
vin.setText("failed to fetch vin");
55+
}
56+
@Override public void onNext(String s) {
57+
vin.setText("VIN: " + s);
58+
}
59+
}));
60+
61+
return rootView;
62+
}
63+
64+
@Override public void onResume() {
65+
super.onResume();
66+
67+
final TextView rpm = (TextView) getView().findViewById(R.id.rpm);
68+
mVisibleSubscriptions.add(AndroidObservable.bindFragment(this, mDi.observe(Pid.Rpm))
69+
.subscribe(new Observer<Float>() {
70+
@Override public void onCompleted() {}
71+
@Override public void onError(Throwable e) {
72+
rpm.setText("failed to get rpm");
73+
}
74+
@Override public void onNext(Float f) {
75+
rpm.setText("rpm: " + f);
76+
}
77+
}));
78+
79+
final TextView speedMph = (TextView) getView().findViewById(R.id.speed_mph);
80+
mVisibleSubscriptions.add(AndroidObservable.bindFragment(this, mDi.observe(Pid.Speed_Mph))
81+
.subscribe(new Observer<Integer>() {
82+
@Override public void onCompleted() {}
83+
@Override public void onError(Throwable e) {
84+
speedMph.setText("failed to get speed Mph");
85+
}
86+
@Override public void onNext(Integer i) {
87+
speedMph.setText("speed Mph: " + i);
88+
}
89+
}));
90+
}
91+
92+
@Override public void onPause() {
93+
super.onPause();
94+
unsubscribe(mVisibleSubscriptions);
95+
}
96+
97+
@Override public void onDestroyView () {
98+
super.onDestroyView();
99+
unsubscribe(mCreatedSubscriptions);
100+
}
101+
102+
private static void unsubscribe(List<Subscription> subs) {
103+
for (Subscription s : subs) {
104+
s.unsubscribe();
105+
}
106+
subs.clear();
107+
}
108+
}

android/general/02_net.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Net SDK
2+
========
3+
4+
The Vinli Net SDK provides access to all of the same Vinli backend services as provided by the web API. The benefit of using the Vinli Net SDK is that we will provide all of the networking, authentication, parsing, and pagination, helping to make Vinli Android app development even easier.
5+
6+
The primary interface provided by the Vinli Net SDK is the `VinliApp`. `VinliApp` instances are created using the developer's app ID and secret.
7+
8+
For requests that return non-paginated content, an `Observable<ContentType>` is returned.
9+
10+
11+
private final VinliApp app = VinliApp.create("appId", "appSecret");
12+
app.diagnoseDtcCode("P0300").subscribe(new Observer<Dtc>() {
13+
@Override public void onCompleted() {}
14+
@Override public void onError(Throwable e) {
15+
Log.e("DtcCodesObservable", "failed to fetch DTC Code", e);
16+
}
17+
18+
@Override public void onNext(Dtc dtc) {
19+
Log.d("DtcCodesObservable", "got DTC Code: " + dtc);
20+
}
21+
});
22+
23+
24+
For requests that return paginated content, an `Observable<Page<ContentType>>` is returned. Each `Page<ContentType>` provides access to the content of the page as well as the ability to load the next and previous pages. To make displaying Android `ListView`s of paginated content easier, the Vinli Net SDK provides the utility `PageAdapter<ContentType>` class. To load all of a user's devices:
25+
26+
27+
private final VinliApp app = VinliApp.create("appId", "appSecret");
28+
final PageAdapter<li.vin.net.Device> adapter = new DeviceAdapter(activity);
29+
AndroidObservable.bindFragment(this, app.getDevices()).subscribe(adapter);
30+

0 commit comments

Comments
 (0)