Examples - krishnabangalore/webinos-api-vehicle GitHub Wiki
Although you will need to have a car that supports it (like the BMW's prototype), you can see a working example on our travel manager application
In order to get a reference to the API, you will have to discover the API. You can use the dashboard to allow the user pick the service for you, but you can also do this manually in code (see the API description for the dashboard use).
Find Services (Discovery)
This is the list of URIs used to declare this API's features, for use in the widget config.xml and as identifier for service type in service discovery functionality. For each URI, the list of functions covered is provided.
webinos.discovery.findServices(new ServiceType('http://webinos.org/api/vehicle'), {
onFound: function (service) {
//Stores the Service in a local variable
foundService = service
}
From this point we will refer to the found service as if it was stored in the foundService variable.
Bind
Before using a service, you need to bind to it. Binding is similar on all services. The following code shows how to bind to the vehicle API. Bind to the found and select a service and use. This is required to make calls possible on the webinos service that we created.
// Without bind, functions cannot be invoked
onBind: function (service) {
// 'Connection to Vehicle Service has been established.
$('#vt_addListener').removeAttr('disabled');
$('#vt_getData').removeAttr('disabled');
$('#vt_startPdc').removeAttr('disabled');
$('#vt_vehicleDataId').removeAttr('disabled');
}
##get Method allows to request vehicle data in a non-recurring way and is independent from value changes (that are obtained by events). The same identifiers are used for vehicle data as well as for the different vehicle events (ClimateControlEvent, ControlEvent, NavigationEvent, ParkSensorsEvent, ShiftEvent and so on).
function getMessageHandler(type) {
//add all the VehicleDataId here
vehicle = null;
listeners = new Array(); //FOR VEHICLE EVENTS
_vehicleDataIds = [{
type: 'climateall',
supported: true
}, {
type: 'climatedriver',
supported: true
}
##addEventListener Vehicle event types defines the possible vehicle data, which can be retrieved using the addEventListener or the get method.
foundService.addEventListener(‘window’, getMessageHandler($('#vt_vehicleDataId').val()), false);
//add all the VehicleDataId here
##removeEventListener Vehicle event types defines the possible vehicle data, which can be removed using the removeEventListener or the get method.
foundService.removeEventListener(‘window’, getMessageHandler($('#vt_vehicleDataId').val()), false);
//remove all the VehicleDataId here