2 <h1>Hello,Vehicle API!</h1>
5 <pre id="console"></pre>
6 <script src="js/js-test-pre.js"></script>
9 vehicle = navigator.vehicle;
11 function get(objName) {
13 vehicle[objName].get().then(function(data) {
15 debug("get " + objName + ": " + JSON.stringify(data));
17 debug("error " + error.message);
21 debug("error getting " + objName + ": " + error.message);
25 debug("testing zones...");
28 debug('Driver zone: ' + zone.driver.value);
30 var zone1 = new Zone(["Front", "Left"]);
31 var zone2 = new Zone(["Left", "Front"]);
32 var zone3 = new Zone(["Front", "Right"]);
33 var zone4 = new Zone([]);
35 debug("zone1 == zone2 ? " + zone1.equals(zone2));
36 debug("zone1 == zone3 ? " + zone1.equals(zone3));
37 debug("zone1 == zone1 ? " + zone1.equals(zone1));
38 debug("zone1 == empty zone ? " + zone1.equals(zone4));
41 debug("testing supported");
42 debug("vehicle speed supported? " + vehicle.vehicleSpeed.supported;
44 debug("testing subscribe()");
47 var handle = vehicle.vehicleSpeed.subscribe(function(data) {
48 console.log("got subscribe callback");
49 debug("Vehicle speed changed: " + data.speed);
52 if (subReplies === 5) {
53 debug("unsubscribing");
54 vehicle.vehicleSpeed.unsubscribe(handle);
58 debug("test invalid zone error");
59 vehicle.vehicleSpeed.get("invalidzone").then(function() { },
60 function(error) { debug("Invalid zone: " + error.message); });
63 debug("testing set()");
65 vehicle.lightStatus.set({"fog" : false}).then(function() {
66 debug("set success!");
68 debug("set fail! " + error.message);
71 debug("testing running status api's");
72 debug("vehicle.vehicleSpeed " + vehicle.vehicleSpeed);
73 debug("vehicle.engineSpeed " + vehicle.engineSpeed);
74 debug("vehicle.powertrainTorque " + vehicle.powertrainTorque);
75 debug("vehicle.acceleratorPedalPosition " + vehicle.acceleratorPedalPosition);
76 debug("vehicle.throttlePosition " + vehicle.throttlePosition);
77 debug("vehicle.transmission " + vehicle.transmission);
78 debug("vehicle.cruiseControlStatus " + vehicle.cruiseControlStatus);
79 debug("vehicle.lightStatus " + vehicle.lightStatus);
80 debug("vehicle.horn " + vehicle.horn);
81 debug("vehicle.chime " + vehicle.chime);
82 debug("vehicle.fuel " + vehicle.fuel);
83 debug("vehicle.engineOil " + vehicle.engineOil);
84 debug("vehicle.acceleration " + vehicle.acceleration);
85 debug("vehicle.engineCoolant " + vehicle.engineCoolant);
86 debug("vehicle.steeringWheel " + vehicle.steeringWheel);
87 debug("vehicle.wheelTick " + vehicle.wheelTick);
88 debug("vehicle.ignitionTime " + vehicle.ignitionTime);
89 debug("vehicle.yawRate " + vehicle.yawRate);
90 debug("vehicle.brakeOperation " + vehicle.brakeOperation);
91 debug("vehicle.buttonEvent " + vehicle.buttonEvent);
92 debug("vehicle.nightMode " + vehicle.nightMode);
93 debug("vehicle.drivingMode " + vehicle.drivingMode);
95 debug("getting data from running status attributes");
99 get("powertrainTorque");
100 get("acceleratorPedalPosition");
101 get("throttlePosition");
103 get("cruiseControlStatus");
110 get("engineCoolant");
111 get("steeringWheel");
115 get("brakeOperation");
120 <script src="js/js-test-post.js"></script>