forked from w3c/automotive-bg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vehicle_spec.html
446 lines (387 loc) · 19 KB
/
vehicle_spec.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
<!DOCTYPE html>
<html>
<head>
<title>Vehicle Information Access API</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<script src='https://www.w3.org/Tools/respec/respec-w3c-common'
class='remove'></script>
<script class="remove">
var respecConfig = {
specStatus: "BG-DRAFT",
shortName: "vehicle-information-api",
publishDate: "",
previousPublishDate: "2014-11-24",
previousMaturity: "BG-FINAL",
edDraftURI: "",
// lcEnd: "",
crEnd: "",
editors: [
{ name: "Kevron Rees", company: "Intel",
companyURL: "http://www.intel.com" },
{ name: "Justin (Jong Seon) Park", company: "LG Electronics",
companyURL: "http://www.lg.com"}
],
inlineCSS: true,
noIDLIn: true,
wg: "Automotive and Web Platform Business Group",
wgURI: "http://www.w3.org/community/autowebplatform/",
wgPublicList: "public-autowebplatform",
wgPatentURI: "",
localBiblio: {
"VIN": {
title: "Vehicle Identification Number"
, href: "http://en.wikipedia.org/wiki/Vehicle_Identification_Number#World_Manufacturer_Identifier"
, publisher: "Wikipedia"
}
}
};
</script>
</head>
<body>
<!------------------------------ Abstract ------------------------------------>
<section id="abstract">
<p>
The W3C Vehicle Information API is a proposal that aims to enables connectivity through in-vehicle infotainment systems and vehicle data access protocols. This API can also be leveraged by web applications running on mobile devices that access the data resources of a connected passenger vehicle.</p>
<p>
This specification does not dictate or describe the access protocol or transport method used for the data connection. Data may come from numerous sources including OBD-II, CAN, LIN, etc. Bluetooth, WiFi, or cloud connections are all possible.</p>
<p>
The purpose of this specification is to promote an API that enables application development in a consistent manner across participating automotive manufacturers. It is recognized, however, that the mechanisms required for access or control of vehicle Properties may differ between automobile manufacturers, makes and models. Furthermore, different automobile manufacturers can expose different Properties that can be read or set by an application.</p>
<p>
As a result of these constraints, this specification shall allow for automobile manufacturer-specific extensions or restrictions. Extensions are only permitted for interfaces that are not already described by this API, and must be implemented to conform within the format and guidelines existing in this specification. If a Property is restricted, the automobile manufacturer would omit the optional feature in their implementation (see the <a>Availability</a> Section).
</p>
<p>
The target platform supported by the specification is exclusively passenger vehicles. Use of this specification for non-passenger applications (transportation, heavy machinery, marine, airline infotainment, military, etc.) is not prohibited, but is not covered in the design or content of the API and therefore may be insufficient.
</p>
<p>
Initially, a typical use case of Vehicle Information might be the implementation of a 'Virtual Mechanic' application that provides vehicle status information such as tire pressure, engine oil level, washer fluid level, battery status, etc. Future use case innovations in transportation, safety, navigation, smart energy grid and consumer infotainment and customization are all possible through this specification.
</p>
<p>
Web developers building interoperable applications based upon this API, will help empower a common web platform across consumer devices and passenger vehicles consistent with the Web of Things.
</p>
</section>
<!----------------------- Status of this document ---------------------------->
<section id="sotd">
</section>
<!----------------------------- Introduction --------------------------------->
<section class="informative">
<h2>Introduction</h2>
<p>
The Vehicle Information API provides operations to get access to the vehicle data
(henceforth "properties") available from vehicle systems and also to change (write) a number of
properties. Vehicle data types are available in the <a href="data_spec.html">Vehicle Data specification</a>.
<p>
An example of use is provided below:
<pre class="example highlight">
var vehicle = navigator.vehicle;
vehicle.vehicleSpeed.get().then(function(vehicleSpeed) {
console.log("vehicle speed: " + vehicleSpeed.speed);
},
function(error) {
console.log("There was an error");
});
var vehicleSpeedSub = vehicle.vehicleSpeed.subscribe(function(vehicleSpeed) {
console.log("vehicle speed changed to: " + vehicleSpeed.speed);
vehicle.vehicleSpeed.unsubscribe(vehicleSpeedSub);
});
var zone = new Zone;
var zones = vehicle.climateControl.zones;
for(var i in zones)
{
if(i.equals(zone.driver))
{
var value = {};
value["acStatus"] = true;
vehicle.climateControl.set(value, zone.driver).then(function(){
console.log("successfully set acStatus");
},
function(error) {
console.log("there was an error");
});
}
}
</pre>
</section>
<!---------------------------- Conformance ----------------------------------->
<section id="conformance">
<p>This specification defines conformance criteria that apply to a single
product: the <dfn>user agent</dfn> that implements the interfaces that it
contains.
<p>Implementations that use ECMAScript to implement the APIs defined in this
specification MUST implement them in a manner consistent with the ECMAScript
Bindings defined in the Web IDL specification [[!WEBIDL]], as this
specification uses that specification and terminology.
</section>
<!----------------------------- Terminology ---------------------------------->
<section id="terminology">
<h2>Terminology</h2> <p>The <code><a
href="http://www.w3.org/TR/2013/WD-dom-20131107/#promises">
Promise</a></code> provide a convenient way to get access to the result of an operation.</p>
</section>
<!------------------------ Security and privacy ------------------------------>
<section id="security">
<h2>Security and privacy considerations</h2>
<p>
It is expected that security of vehicle APIs described in this document is based on permissions dictated by:
</p>
<ul>
<li>The JavaScript runtime under which the APIs are used – in some cases</li>
<li>The underlying operating system – always</li>
</ul>
<p>No separate permission or access control model will be defined for vehicle APIs. Depending on a specific platform, the user agent used may have to provide tools to generate permissions for application descriptors as required by the OS. Android is an example under which such a descriptor (Android app manifest) has to be generated if the runtime maps its apps to OS-level apps.
</p>
</section>
<!---------------------- Extended interface Navigator ------------------------>
<section>
<h3><a>Navigator</a> Interface</h3>
<dl title="partial interface Navigator" class="idl">
<dt>readonly attribute Vehicle vehicle</dt>
<dd>The object that exposes the interface to vehicle information services.</dd>
</dl>
</section>
<!------------------------ Interface Vehicle ------------------------------->
<section>
<h3><a>Vehicle</a> Interface</h3> <p>The <a>Vehicle</a> interface
represents the initial entry point for getting access to the vehicle information
services, i.e. Engine Speed and Tire Pressure. </p>
<dl title="[NoInterfaceObject] interface Vehicle" class="idl">
</dl>
</section>
<!------------------------ Interface Zone ------------------------>
<section>
<h3><a>Zone</a> Interface</h3> <p>The <a>Zone</a>
interface contains the constants that represent physical zones and logical zones</p>
<dl title="enum ZonePosition" class="idl">
<dt>front</dt>
<dt>middle</dt>
<dd>the middle position of a row.
<dt>right</dt>
<dt>left</dt>
<dt>rear</dt>
<dt>center</dt>
<dd>the center row</dd>
</dl>
<dl title="interface Zone"
class="idl">
<dt>attribute DOMString[] value</dt><dd>MUST return array of physical zones</dd>
<dt>readonly attribute Zone driver</dt><dd>MUST return physical zone for logical driver</dd>
<dt>boolean equals(Zone zone)</dt><dd>MUST return true if zone.value matches the contents of this.value.
Ordering of elements within Zone.value does not matter.</dd>
<dt>boolean contains(Zone zone)</dt><dd>MUST return true if zone.value can be found within this.value</dd>
</dl>
</section>
<!------------------------ Callback VehicleInterfaceCallback------------------------------>
<section>
<h3><a>VehicleInterfaceCallback</a> Callback</h3>
<p>The <a>VehicleInterfaceCallback</a> </p>
<dl title="callback VehicleInterfaceCallback = void(object value);" class="idl"></dl>
</section>
<!------------------------ Callback AvailableCallback------------------------------>
<section>
<h3><a>AvailableCallback</a> Callback</h3>
<p>The <a>AvailableCallback</a> </p>
<dl title="callback AvailableCallback = void (Availability available)" class="idl"></dl>
</section>
<!------------------------ Interface VehicleInterfaceError ------------------------>
<section>
<h3><a>VehicleInterfaceError</a> Interface</h3>
<p>VehicleInterfaceError is used to identify the type of error encountered during an operation</p>
<dl title="enum VehicleError" class="idl">
<dt>permission_denied</dt>
<dd>Indicates that the user does not have permission to perform the operation. More details can be obtained through the <a href="#data-availability">Data Availability</a> API.</dd>
<dt>invalid_operation</dt>
<dd>Indicates that the operation is not valid. This can be because it isn't supported or has invalid arguments</dd>
<dt>timeout</dt>
<dd>Operation timed out. Timeout length depends upon the implementation</dd>
<dt>invalid_zone</dt>
<dd>Indicates the zone argument is not valid</dd>
<dt>unknown</dt>
<dd>Indicates an error that is not known</dd>
</dl>
<dl title="[NoInterfaceObject] interface VehicleInterfaceError"
class="idl">
<dt>readonly attribute VehicleError error</dt>
<dd>MUST return VehicleError</dd>
<dt>readonly attribute DOMString message</dt>
<dd>MUST return user-readable error message</dd>
</dl>
</section>
<!------------------------ Interface VehicleInterface ------------------------>
<section>
<h3><a>VehicleInterface</a> Interface</h3> <p>The <a>VehicleInterface</a>
interface represents the base interface to get all vehicle properties.</p>
<dl title="interface VehicleInterface"
class="idl">
<dt>Promise get(optional Zone zone)</dt>
<dd>MUST return the <a href="http://www.w3.org/TR/2013/WD-dom-20131107/#promises">Promise</a>. The "resolve" callback in the promise is used to pass the vehicle data type that corresponds to the specific VehicleInterface instance.
For example, "vehicle.vehicleSpeed" corresponds to the "VehicleSpeed" data type. <a>VehicleInterfaceError</a> is passed to the 'reject' callback in the promise.</dd>
<dt>readonly attribute Zone[] zones</dt>
<dd>MUST return all zones supported for this type.</dd>
</dl>
<pre class="example highlight">
vehicle.vehicleSpeed.get().then(resolve);
function resolve(data)
{
//data is of type VehicleSpeed
console.log("Speed: " + data.speed);
console.log("Time Stamp: " + data.timestamp);
}
</pre>
</section>
<!------------------------ Interface VehicleConfigurationInterface ------------------------>
<section>
<h3><a>VehicleConfigurationInterface</a> Interface</h3> <p>The <a>VehicleConfigurationInterface</a>
interface is to be used to provide access to static vehicle information that never changes: external dimensions, identification, transmission type etc... </p>
<dl title="[NoInterfaceObject] interface VehicleConfigurationInterface : VehicleInterface"
class="idl">
</dl>
</section>
<!------------------------ Interface VehicleSignalInterface ------------------------>
<section>
<h3><a>VehicleSignalInterface</a> Interface</h3> <p>The <a>VehicleSignalInterface</a>
interface represents vehicle signals that, as a rule, and unlike vehicle configurations, can change values, either programmatically
(necessitating support for set method) or due to external events and occurrences, as reflected by subscription management.</p>
<dl title="[NoInterfaceObject] interface VehicleSignalInterface : VehicleInterface"
class="idl">
<dt>Promise set(object value, optional Zone zone)</dt>
<dd>MUST return <a href="http://www.w3.org/TR/2013/WD-dom-20131107/#promises">Promise</a>. The "resolve" callback indicates the set was successful. No data is passed to resolve. If there was an error,
"reject" will be called with a <a>VehicleInterfaceError</a> object</dd>
<dt>unsigned short subscribe(VehicleInterfaceCallback callback, optional Zone zone)</dt>
<dd>MUST return handle to subscription or 0 if error</dd>
<dt>void unsubscribe(unsigned short handle)</dt>
<dd>MUST return void. unsubscribes to value changes on this interface.</dd>
</dl>
<pre class="example highlight">
var zone = Zone
vehicle.door.set({"lock" : true}, zone.driver).then(resolve, reject);
function resolve()
{
/// success
}
function reject(errorData)
{
console.log("Error occurred during set: " + errorData.message + " code: " + errorData.error);
}
</pre>
</section>
<!------------------------ Availability ------------------------>
<section>
<h2>Data Availability</h2>
<p>The availability API allows for developers to determine what attributes are available or not and if not, why. It also allows for notifications when the availability
changes.</p>
<dl title="enum Availability"
class="idl">
<dt>available</dt>
<dd>data is available</dd>
<dt>not_supported</dt>
<dd>not supported by this vehicle</dd>
<dt>not_supported_yet</dt>
<dd>not supported at this time, but may become supported later.</dd>
<dt>not_supported_security_policy</dt>
<dd>not supported because of security policy</dd>
<dt>not_supported_business_policy</dt>
<dd>not supported because of business policy</dd>
<dt>not_supported_other</dt>
<dd>not supported for other reasons</dd>
</dl>
<dl title="partial interface VehicleInterface" class="idl">
<dt>Availability availableForRetrieval(DOMString attributeName)</dt>
<dd>MUST return whether a not this attribute is available for get() or not</dd>
<dt>readonly attribute boolean supported</dt>
<dd>MUST return true if this attribute is supported and available</dd>
<dt>short availabilityChangedListener( AvailableCallback callback )</dt>
<dd>MUST return handle for listener.</dd>
<dt>void removeAvailabilityChangedListener( short handle )</dt>
</dl>
<pre class="example highlight">
if( ( var a = vehicle.vehicleSpeed.availableForRetrieval("speed") ) === "available" )
{
// we can use it.
}
else
{
// tell us why:
console.log(a);
}
</pre>
<dl title="partial interface VehicleSignalInterface" class="idl">
<dt>Availability availableForSubscription(DOMString attributeName)</dt>
<dd>MUST return whether a not this attribute is available for subscribe() or not</dd>
<dt>Availability availableForSetting(DOMString attributeName)</dt>
<dd>MUST return whether a not this attribute is available for set() or not</dd>
</dl>
<pre class="example highlight">
var canHasVehicleSpeed = vehicle.vehicleSpeed.availableForSubscription("speed") === "available";
vehicle.vehicleSpeed.availabilityChangedListener( function (available) {
canHasVehicleSpeed = available === "available";
checkVehicleSpeed();
});
function checkVehicleSpeed()
{
if(canHasVehicleSpeed)
{
vehicle.vehicleSpeed.get().then(callback);
}
}
</pre>
</section>
<!------------------------ History ------------------------>
<section>
<h2>History</h2>
<p> The History API provides a way for applications to access logged data from the vehicle. What data is available and how much is up to the implementation. This section is OPTIONAL.</p>
<dl title="interface HistoryItem" class="idl">
<dt>readonly attribute any value</dt>
<dd>MUST return value. This is ANY Vehicle Data Type.</dd>
<dt>readonly attribute DOMTimeStamp timestamp</dt>
<dd>MUST return time in which 'value' was read by the system.</dd>
</dl>
<dl title="partial interface VehicleInterface" class="idl">
<dt>readonly attribute History? history</dt>
<dd>MUST return History interface if the platform supports the History API</dd>
</dl>
<dl title="interface History" class="idl">
<dt>Promise get(Date begin, Date end, optional Zone zone)</dt>
<dd>MUST return Promise. The "resolve" callback in the promise is used to pass an array of <a>HistoryItem</a>s.</dd>
<dt>readonly attribute boolean isLogged</dt>
<dd>MUST return true if this attribute is logged</dd>
<dt>readonly attribute Date? from</dt>
<dd>MUST return Date in which logging started from. Returns null if <a>isLogged</a> is false.</dd>
<dt>readonly attribute Date? to</dt>
<dd>MUST return Date in which logging of this attribute ends. Returns null if <a>isLogged</a> is false.</dd>
</dl>
<pre class="example highlight">
/// check if there is data being logged for vehicleSpeed:
if(vehicle.vehicleSpeed.history.isLogged)
{
/// get all vehicleSpeed since it was first logged:
vehicle.vehicleSpeed.history.get(vehicle.vehicleSpeed.history.from, vehicle.vehicleSpeed.history.to).then( function ( data ) {
console.log(data.length);
});
}
</pre>
</section>
<section class="use-cases">
<h2>Use-Cases</h2>
<section>
<p>The primary purpose of this specification is to provide web developers the ability to access and set vehicle
information through a simple common set of operations including get, set, subscribe, and unsubscribe. Thus
normative use cases pertain to this access and do not cover higher application of business level use cases.</p>
<section>
<h4>Get </h4>
Get a single value once from the vehicle.
</section>
<section>
<h4>Set </h4>
Set a single value once in the vehicle.
</section>
<section>
<h4>Subscribe </h4>
Subscribe to single value until unsubscribed.
</section>
<section>
<h4>Set </h4>
Unsubscribe to single value.
</section>
</section>
</section>
</body>
</html>