Abstract

The W3C Vehicle Information API aims to enable 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.

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.

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.

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 Availability Section).

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.

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.

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.

Status of This Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This document was published by the Automotive Working Group as a First Public Working Draft. This document is intended to become a W3C Recommendation. If you wish to make comments regarding this document, please send them to public-automotive@w3.org (subscribe, archives). All comments are welcome.

Publication as a First Public Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.

This document is governed by the 1 August 2014 W3C Process Document.

Table of Contents

1. Introduction

This section is non-normative.

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 Vehicle Data specification.

An example of use is provided below:

Example 1
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 = 0, zone; zone = zones[i]; i++) {
  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");
    });
  }
}

2. Conformance

As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.

The key words MUST and OPTIONAL are to be interpreted as described in [RFC2119].

This specification defines conformance criteria that apply to a single product: the user agent that implements the interfaces that it contains.

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.

3. Terminology

The Promise provide a convenient way to get access to the result of an operation.

4. Security and privacy considerations

It is expected that security of vehicle APIs described in this document is based on permissions dictated by:

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.

6. Vehicle Interface

The Vehicle interface represents the initial entry point for getting access to the vehicle information services, i.e. Engine Speed and Tire Pressure.

[NoInterfaceObject]
interface Vehicle {
};

7. Zone Interface

The Zone interface contains the constants that represent physical zones and logical zones

enum ZonePosition {
    "front",
    "middle",
    "right",
    "left",
    "rear",
    "center"
};
Enumeration description
frontmiddle
middlethe middle position of a row.
rightleft
leftrear
rearcenter
centerthe center row
interface Zone {
                attribute ZonePosition[] value;
    readonly    attribute Zone           driver;
    boolean equals (Zone zone);
    boolean contains (Zone zone);
};

7.1 Attributes

driver of type Zone, readonly
MUST return physical zone for logical driver
value of type array of ZonePosition,
MUST return array of physical zones

7.2 Methods

contains
MUST return true if zone.value can be found within this.value
ParameterTypeNullableOptionalDescription
zoneZone
Return type: boolean
equals
MUST return true if zone.value matches the contents of this.value. Ordering of elements within Zone.value does not matter.
ParameterTypeNullableOptionalDescription
zoneZone
Return type: boolean

8. VehicleInterfaceCallback Callback

The VehicleInterfaceCallback

callback VehicleInterfaceCallback = void(object value) ();

9. AvailableCallback Callback

The AvailableCallback

callback AvailableCallback = void (Availability available) ();

10. VehicleInterfaceError Interface

VehicleInterfaceError is used to identify the type of error encountered during an operation

enum VehicleError {
    "permission_denied",
    "invalid_operation",
    "timeout",
    "invalid_zone",
    "unknown"
};
Enumeration description
permission_deniedIndicates that the user does not have permission to perform the operation. More details can be obtained through the Data Availability API.
invalid_operationIndicates that the operation is not valid. This can be because it isn't supported or has invalid arguments
timeoutOperation timed out. Timeout length depends upon the implementation
invalid_zoneIndicates the zone argument is not valid
unknownIndicates an error that is not known
[NoInterfaceObject]
interface VehicleInterfaceError {
    readonly    attribute VehicleError error;
    readonly    attribute DOMString    message;
};

10.1 Attributes

error of type VehicleError, readonly
MUST return VehicleError
message of type DOMString, readonly
MUST return user-readable error message

11. VehicleInterface Interface

The VehicleInterface interface represents the base interface to get all vehicle properties.

interface VehicleInterface {
    Promise get (optional Zone zone);
    readonly    attribute Zone[] zones;
};

11.1 Attributes

zones of type array of Zone, readonly
MUST return all zones supported for this type.

11.2 Methods

get
MUST return the Promise. 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. VehicleInterfaceError is passed to the 'reject' callback in the promise.
ParameterTypeNullableOptionalDescription
zoneZone
Return type: Promise
Example 2
vehicle.vehicleSpeed.get().then(resolve);

function resolve(data)
{
  //data is of type VehicleSpeed
  console.log("Speed: " + data.speed);
  console.log("Time Stamp: " + data.timestamp);
}

12. VehicleConfigurationInterface Interface

The VehicleConfigurationInterface interface is to be used to provide access to static vehicle information that never changes: external dimensions, identification, transmission type etc...

[NoInterfaceObject]
interface VehicleConfigurationInterface : VehicleInterface {
};

13. VehicleSignalInterface Interface

The VehicleSignalInterface 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.

[NoInterfaceObject]
interface VehicleSignalInterface : VehicleInterface {
    Promise        set (object value, optional Zone zone);
    unsigned short subscribe (VehicleInterfaceCallback callback, optional Zone zone);
    void           unsubscribe (unsigned short handle);
};

13.1 Methods

set
MUST return Promise. 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 VehicleInterfaceError object
ParameterTypeNullableOptionalDescription
valueobject
zoneZone
Return type: Promise
subscribe
MUST return handle to subscription or 0 if error
ParameterTypeNullableOptionalDescription
callbackVehicleInterfaceCallback
zoneZone
Return type: unsigned short
unsubscribe
MUST return void. unsubscribes to value changes on this interface.
ParameterTypeNullableOptionalDescription
handleunsigned short
Return type: void
Example 3
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);
}

14. Data Availability

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.

enum Availability {
    "available",
    "not_supported",
    "not_supported_yet",
    "not_supported_security_policy",
    "not_supported_business_policy",
    "not_supported_other"
};
Enumeration description
availabledata is available
not_supportednot supported by this vehicle
not_supported_yetnot supported at this time, but may become supported later.
not_supported_security_policynot supported because of security policy
not_supported_business_policynot supported because of business policy
not_supported_othernot supported for other reasons
partial interface VehicleInterface {
    Availability availableForRetrieval (DOMString attributeName);
    readonly    attribute boolean supported;
    short        availabilityChangedListener (AvailableCallback callback);
    void         removeAvailabilityChangedListener (short handle);
};

14.1 Attributes

supported of type boolean, readonly
MUST return true if this attribute is supported and available

14.2 Methods

availabilityChangedListener
MUST return handle for listener.
ParameterTypeNullableOptionalDescription
callbackAvailableCallback
Return type: short
availableForRetrieval
MUST return whether a not this attribute is available for get() or not
ParameterTypeNullableOptionalDescription
attributeNameDOMString
Return type: Availability
removeAvailabilityChangedListener
ParameterTypeNullableOptionalDescription
handleshort
Return type: void
Example 4
if( ( var a = vehicle.vehicleSpeed.availableForRetrieval("speed") ) === "available" )
{
  // we can use it.
}
else
{
  // tell us why:
  console.log(a);
}
partial interface VehicleSignalInterface {
    Availability availableForSubscription (DOMString attributeName);
    Availability availableForSetting (DOMString attributeName);
};

14.3 Methods

availableForSetting
MUST return whether a not this attribute is available for set() or not
ParameterTypeNullableOptionalDescription
attributeNameDOMString
Return type: Availability
availableForSubscription
MUST return whether a not this attribute is available for subscribe() or not
ParameterTypeNullableOptionalDescription
attributeNameDOMString
Return type: Availability
Example 5
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);
  }
}

15. History

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.

interface HistoryItem {
    readonly    attribute any          value;
    readonly    attribute DOMTimeStamp timestamp;
};

15.1 Attributes

timestamp of type DOMTimeStamp, readonly
MUST return time in which 'value' was read by the system.
value of type any, readonly
MUST return value. This is ANY Vehicle Data Type.
partial interface VehicleInterface {
    readonly    attribute History? history;
};

15.2 Attributes

history of type History, readonly , nullable
MUST return History interface if the platform supports the History API
interface History {
    Promise get (Date begin, Date end, optional Zone zone);
    readonly    attribute boolean isLogged;
    readonly    attribute Date?   from;
    readonly    attribute Date?   to;
};

15.3 Attributes

from of type Date, readonly , nullable
MUST return Date in which logging started from. Returns null if isLogged is false.
isLogged of type boolean, readonly
MUST return true if this attribute is logged
to of type Date, readonly , nullable
MUST return Date in which logging of this attribute ends. Returns null if isLogged is false.

15.4 Methods

get
MUST return Promise. The "resolve" callback in the promise is used to pass an array of HistoryItems.
ParameterTypeNullableOptionalDescription
beginDate
endDate
zoneZone
Return type: Promise
Example 6
/// 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);
  });
}

16. Use-Cases

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.

Get

Get a single value once from the vehicle.

Set

Set a single value once in the vehicle.

Subscribe

Subscribe to single value until unsubscribed.

Set

Unsubscribe to single value.

A. References

A.1 Normative references

[RFC2119]
S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119
[WEBIDL]
Cameron McCormack. Web IDL. 19 April 2012. W3C Candidate Recommendation. URL: http://www.w3.org/TR/WebIDL/