Vehicle management

If the Fleet Client is enabled in Oden, the list of vehicles as well as connecting and disconnecting from vehicles can be managed from the web.

List online vehicles

Getting the list of online vehicles is done in two steps, sending a "fleet_list_vehicles" and then listening to the "fleet_online_vehicles" message.

const odenClient = getOrCreateOdenLayoutClient();

const printOnlineVehicles = (vehicles) => {
  // {[
  //    {
  //        "id": string,
  //        "name": string,
  //        "availability": string // Can be Controlled, Monitored, Available
  //    }
  // ]}
    console.log("Vehicles online:", vehicles);
};

odenClient.registerUserMessageCallback("fleet_online_vehicles", printOnlineVehicles);

// Unregister callback
odenClient.unregisterUserMessageCallback("fleet_online_vehicles", printOnlineVehicles);

// Sends message to Oden that it should send back a list of vehicles that are online.
odenClient.sendNamedUserMessage("fleet_list_vehicles", {});

Connect to vehicle

Connecting to a vehicle is done by sending its name with the "fleet_connect" message.

const odenClient = getOrCreateOdenLayoutClient();
odenClient.sendNamedUserMessage("fleet_connect", { vehicle_name: "vehicle_name" });
It is easy to confuse the "id" and "name" fields, the "name" field is the one to use.

Disconnect from vehicle

Disconnecting from a vehicle is done by sending its name with the "fleet_disconnect" message.

const odenClient = getOrCreateOdenLayoutClient();
odenClient.sendNamedUserMessage("fleet_disconnect", { vehicle_name: "vehicle_name" });