Abstract

This specification defines a high level API for accessing to vehicle signals and data attributes.

The purpose of the specification is to promote a client implementation with a standard API that enables application development in a consistent manner across participating automotive manufacturers.

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 https://www.w3.org/TR/.

This document was published by the Automotive Working Group as a Working Draft. This document is intended to become a W3C Recommendation. Comments regarding this document are welcome. Please send them to public-automotive@w3.org (subscribe, archives).

Publication as a 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 March 2017 W3C Process Document.

1. Introduction

This section is non-normative.

The following documents the specification required for a high level API designed to interface with vehicle signals. This specification is responsible for the following:

In general, the client should strive for the following goals:

This API specification is designed assuming to communicate with in-vehicle data servers which provide vehicle signals and data attributes. A server conforms to definition in Vehicle Information Service Specification (hereafter VISS) is a typical example of in-vehicle data server, however servers of other types which have appropriate functions should also be applicable.

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 SHOULD are to be interpreted as described in [RFC2119].

3. Terminology

The term 'VISS' is used to refer to the 'Vehicle Information Service Specification' (see here) which is in the process of developed in W3C Automotive Working Group along with this specification. The term 'VIS Server' is used to refer to a server which conforms to the 'VISS' specification.

The term 'VIAS' is used to refer to the 'Vehicle Information API Specification' which is this document.

The term 'VSS' is used to refer to the 'Vehicle Signal Specification' (see here) which is defined in Genivi alliance activity.

The term 'WebSocket' when used in this document, is as defined in the W3C WebSocket API (see here) and the WebSocket Protocol (see RFC6455).

4. Security and Privacy Considerations

This specification defines an interface to the underling server and does not expose any platform capabilities by itself. The underling server is responsible for managing privileges of each client connection and the VIAS implementation is responsible for passing requests and responses securely between clients and the server.

One of possible implementation methods of VIAS would be as a form of JavaScript library.
In that case, as a necessary security consideration, the JavaScript library SHOULD be provided from a trusted origin. Otherwise a malicious library could be loaded instead and any data goes through the library could be eavesdropped or tampered. Authorization tokens may goes through the library as well and if token leaking happens, security of the underlying server could be damaged. The underlying server itself should be considered as one of trusted origins from the VIAS JavaScript library implementation.

Some part of vehicle data is considered as privacy sensitive and client programs SHOULD treat these data with respect to the user's right. As a privacy protection enforcer, the VIAS implementation MUST obtain user's permision for exposing vehicle data to a client program. If the implementation have an exceptional behavior to treat private information in emergent cases, the behavior also SHOULD be covered by the permission.

5. VISClient Interface

[Constructor(optional VISClientOptions options)]
interface VISClient {
    readonly attribute DOMString?      host;
    readonly attribute DOMString?      protocol;
    readonly attribute unsigned short? port;

    void            connect(ConnectCallback connectCallback,
                            ErrorCallback errorCallback);
    void            authorize(object tokens,
                              AuthorizeCallback authorizeCallback,
                              ErrorCallback errorCallback);
    void            getVSS(DOMString path,
                           GetVSSCallback getVSSCallback,
                           ErrorCallback errorCallback);
    void            get(DOMString path,
                        GetCallback getCallback,
                        ErrorCallback errorCallback);
    void            set(DOMString path,
                        any value,
                        SetCallback setCallback,
                        ErrorCallback errorCallback);
    VISSubscription subscribe(DOMString path,
                              SubscriptionCallback subscriptionCallback,
                              ErrorCallback errorCallback,
                              optional SubscribeFilters filters);
    void            unsubscribe(VISSubscription subscription,
                                UnsubscribeCallback unsubscribeCallback,
                                ErrorCallback errorCallback);
    void            unsubscribeAll(UnsubscribeCallback unsubscribeCallback,
                                   ErrorCallback errorCallback);
    void            disconnect(DisconnectCallback disconnectCallback,
                               ErrorCallback errorCallback);
};

interface VISClientOptions {
    attribute DOMString?      host;
    attribute DOMString?      protocol;
    attribute unsigned short? port;
};

interface VISValue {
    attribute any          value;
    attribute DOMTimeStamp timeStamp;
};

interface VISError {
    attribute unsigned short number;
    attribute DOMString?     reason;
    attribute DOMString?     message;
    attribute DOMTimeStamp   timeStamp;
};

Constructor

The VISClient constructor, when invoked, must return a new VISClient object.
This constructor takes VISClientOptions object as a parameter. The parameter is optional and the necessity depends on underlying communication type.

Example 1
const client = new VISClient({ /* VISClientOptions object */ });

VISClientOptions Interface

VISClientOptions interface is designed assuming a connection to a vehicle signal server which is specifiable by protocol, host and port. In case the underlying connection requires other parameters, implementer can add parameters according to the requirement.
These values are set at initialization only and cannot be changed after a connection has established.

Parameter Type Default Description
host String wwwivi hostname of the server
protocol String wss protocol for the connection to a vehicle signal server. All the communications between the client and server MUST be appropriately encrypted. Therefore, in case of WebSocket, 'wss' is required and in case of http, 'https' is required. Non encrypted communication is not supported.
port Integer 443 TCP port for the connection to a vehicle signal server.

Methods

Once created, a client provides several functions for interacting with the server.

Many of the functions listed below require a `path` string to be passed that identifies the portion of the VSS that is being referenced. See VSS below for how to generate this string based on traversing the VSS tree.

callback ConnectCallback = void ();

callback DisconnectCallback = void ();

callback ErrorCallback = void (VISError error);

callback AuthorizeCallback = void (unsigned long TTL);

callback GetVSSCallback = void (VSS vss);

callback GetCallback = void (VISValue value);

callback SetCallback = void ();

callback SubscriptionCallback = void (VISValue value);

callback UnsubscribeCallback = void ();
Method Description Paramters
connect(connectCallback, errorCallback) Initializes the connection with the server.
When underlying network is `connectionless` type(e.g. http), establishing connection with this method is not necessary.
In such case, this method could be implemented as empty function which returns `501 not implemented` error when executed.
  • connectCallback (ConnectCallback) - A function called when the connection is successfully established.
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
authorize(tokens, authorizeCallback, errorCallback) Request access to signals and data attributes that are under access control.
  • tokens (object) - Tokens provided by authorization authority. Structure of tokens depend on underlying server's specification.
  • authorizeCallback (AuthorizeCallback) - A function called when the operation is completed
    • TTL (unsigned long) - The time-to-live value of the authorization, passed when authorization succeed.
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
getVSS(path, getVSSCallback, errorCallback) Requests the VSS from the server and calls the callback function with a VSS object as described below.
  • path (DOMString)- a String representing a location within the VSS
  • getVSSCallback (GetVSSCallback) - A function called when the operation is completed
    • vss (VSS) - A VSS object built from the server response
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
get(path, getCallback, errorCallback) Receives a single value from the server.
  • path (DOMString)- a String representing a location within the VSS
  • getCallback (GetCallback) - A function called when the operation is completed
    • value (VISValue) - the value for the requested path.
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
set(path, value, setCallback, errorCallback) Sends a single value to the server.
  • path (DOMString) - a String representing a location within the VSS
  • value (any) - the value to pass to the server. This must match the type as specified in the VSS.
  • setCallback (SetCallback) - A function called when the operation is completed
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
subscribe(path, subscriptionCallback, errorCallback, filters) subscribes to the given path with the filters provided and returns a VISSubscription as the return value.
After that, continuously returns the value of signals specified by 'path' with timing condition specified in 'filters'.
  • path (DOMString) - a String representing a location within the VSS
  • subscriptionCallback (SubscriptionCallback) - A function called each time subscribed value is notified from the server.
    This function will be passed:
    • value (VISValue) - the value for the subscribed path
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
  • filters (SubscribeFilters) - applies a server-side filter to data sent. The structure of this option depends on underlying server's specification.
unsubscribe(subscription, unsubscribeCallback, errorCallback) Unsubscribe from the subscription passed.
  • subscription (VISSubscription) - the subscription object is obtained from callback function for `subscribe()` method
  • unsubscribeCallback (UnsubscribeCallback) - A function called when the operation is completed
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
unsubscribeAll(unsubscribeCallback, errorCallback) Unsubscribe all the subscriptions.
  • unsubscribeCallback (UnsubscribeCallback) - A function called when the operation is completed
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.
disconnect(disconnectCallback, errorCallback) Closes the connection.
The same VISClient object can be used again by calling the `connect()` method, but subscriptions, authorization, and other state will not persist after a disconnection.
When underlying network is `connectionless` type(e.g. http(s)), use of this method is not necessary.
In such case, this method could be implemented as empty function which returns '501 not implemented' error when executed.
  • disconnectCallback (DisconnectCallback) - A function called when the connection is successfully closed.
  • errorCallback (ErrorCallback) - A function called when an error relevant to this method has been occurred.
    • error (VISError) - Error information is passed here.

VISValue Interface

VISValue conveys a vehicle signal or attribute value.

Parameter Type Description
value any The type of 'value' varies according to the target signal or attribute. For detail, refer VSS spec.
timeStamp DOMTimeStamp The Coordinated Universal Time (UTC) time that the server returned the response (expressed as number of milliseconds.)

VISError Interface

Error number, reason, message represents both of client-side and server-side error. Server-side error difinition depends on underlying server. Client-side error definition is implementation dependent and not defined in this document.

Parameter Type Description
number unsigned short Error number (error code).
reason DOMString Error reason. Optional.
message DOMString Error message. Optional.
timeStamp DOMTimeStamp The Coordinated Universal Time (UTC) time that the server returned the response (expressed as number of milliseconds.)

Example

Example 2
const client = new VISClient({
  host: 'wwwivi',
  protocol: 'wss',
  port: 443,
});

const connectCallback = () => {
  console.log(`Connected to ${client.protocol}://${client.host}:${client.port}`);
  client.authorize(/* TOKEN */, (ttl) => {
    console.log(`Authorize succeeded. TTL: ${ttl}`);

    /* do other things here */
  }, (err) => {
    console.err('Authorize failed with provided token.');
    return;
  })
};

const errorCallback = (error) => {
  console.err(`Error : ${error.number}`);
};

client.connect(connectCallback, errorCallback);

6. VISSubscription Interface

[Constructor]
interface VISSubscription {
    readonly attribute DOMString            path;
    readonly attribute VISSubscribeFilters? filters;
};

interface VISSubscribeFilters {
    attribute unsigned long?     interval;
    attribute VISSubscribeRange? range;
    attribute unsigned long?     minChange;
};

interface VISSubscribeRange {
    attribute long? below;
    attribute long? above;
};

The VISSubscription object is obtained as return value of the subscribe() method. Once created the object can be used to access the original options and to pass to the unsubscribe() method. The Subscription object does not expose any functions directly, but contains the following properties:

VISSubscriptions are immutable once created.

Parameter Type Description
path DOMString the path String used when creating the Subscription
filters SubscribeFilters object containing the filter conditions passed to the subscribe() method. Structure of this object depends on underlying server's specification.
The following attributes are defined for the case of connecting to VIS Server and not mandatory.
  • interval
  • range
  • minChange

Example

Example 3
const client = new VISClient({ host: 'wwwivi' });

const connectCallback = () => {
  const filters = {
    interval: 100,
    range: { above: 100, below: 200 },
    minChange: 50
  };

  var subscription = client.subscribe('body.mirrors.left', (val) => {
    if (val) {
      console.log(`Value received: ${val}`);
    }

    /* ... after some time or some event, unsubscribe from the subscription: */
    client.unsubscribe(subscription, () => {
      console.log(`Unsubscribe succeeded`);
    }, (err) => {
      if (err) {
        console.err(`Error while unsubscribing: ${err.number}`);
      }
    });
  }, (err) => {
      console.err(`Error while subscribing: ${err.number}`);
  }, filters);
};

client.connect(connectCallback);

7. VSS Interface

[Constructor]
interface VSS {
    sequence<DOMString> pathsByCSS(DOMString cssSelector);
    boolean             pathExistsByCSS(DOMString cssSelector);
    boolean             canGet(DOMString path);
    boolean             canSet(DOMString path);
    object              at(DOMString? path);
};

The VSS object returned by the getVSS() method above should provide APIs sufficient to fully traverse the VSS tree and determine what signals are available at the current permission level. Traversing the VSS tree can be accomplished using any of a number of query languages (i.e. CSS path selectors, XPath, etc.); CSS-based querying is shown in the functions below, but additional query languages may be added in the future. It is out of scope here to define the exact traversal methods and feature set, but these function SHOULD follow standards protocols such as CSS or XPATH.

Function Description
pathsByCSS(cssSelector) Returns array of paths that match the given selector.
pathExistsByCSS(cssSelector) Returns a boolean as to whether or not there exist any path that matches the given selector.
canGet(path) Returns a boolean as to whether or not the current socket (given the tokens provided up to this point) has permission to read the given path.
canSet(path) Returns a boolean as to whether or not the current socket (given the tokens provided up to this point) has permission to set the given path.
at([path]) Returns the raw VSS tree object rooted at path (if provided), otherwise returns the entire tree. Regarding raw VSS object definition, refer VSS spec document.

Example

Example 4
const client = new VISClient({
  host: 'wwwivi',
});

const openWindow = () => {
  client.getVSS('Signal.Cabin' ,(vss) => {
    const paths = vss.pathsByCSS('Row1 Left Window > Position');
    if (!paths.length) {
      console.err('Could not find front-left window in VSS');
      return;
    }

    if (vss.canSet(paths[0])) {
      client.set(paths[0], 0, () => {
        console.log(`Set window ${paths[0]} to open succeeded`);
      }, (err) => {
        console.err(`Set window ${paths[0]} to open failed: ${err.number}`);
      });
    } else {
      console.err('Not authorized to open front-left window');
    }
  }, (err) => {
      console.err(`Error while getVSS: ${err.number}`);
  });
}

client.connect(openWindow);

A. References

A.1 Normative references

[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL: https://tools.ietf.org/html/rfc2119

A.2 Informative references

[WEBIDL]
Web IDL. Cameron McCormack; Boris Zbarsky; Tobie Langel. W3C. 15 December 2016. W3C Editor's Draft. URL: https://heycam.github.io/webidl/