# updateVehicleStatuses

Command (Messages and statuses).

Pushes the set of selectable vehicle statuses (id, localised names, icon)

Gives the driver a way to tell the client application what they are doing, without leaving
navigation. The client application defines a set of statuses; BeNav shows them on a floating button
over the map, and reports every change back as [`onVehicleStatusChanged`](https://docs.benomad.com/benav-rnc/notifications/on-vehicle-status-changed.md).

**The statuses carry no meaning for BeNav.** It stores an id, a label per language and
an icon, displays them, and reports which one is selected. What a status means, and what happens when
it changes, is entirely the client application's business. That is deliberate: the same mechanism
serves operations that have nothing in common.

**Worth knowing**

- The set is replaced wholesale on every call: send the complete list, not a delta.
- Sending the command with no parameters clears the set and hides the button, which is how the
  feature is switched off.
- Icons are downloaded and cached. The new set is applied only if **every** icon
  downloads successfully.
- Labels are supplied per language; BeNav shows the one matching the device, falling back to
  English and then to the first entry.

**Examples: the same command, two unrelated uses**

**A taxi fleet.** Statuses are *Available*, *Unavailable* and *With a
passenger*. The driver taps one as the shift goes on; the dispatch application uses
[`onVehicleStatusChanged`](https://docs.benomad.com/benav-rnc/notifications/on-vehicle-status-changed.md) to know who can be offered the next fare.

**A haulage fleet.** Statuses are *Loaded* and *Empty*. When the driver
switches to *Loaded*, the client application reacts by sending
[`selectVehicleProfile`](https://docs.benomad.com/benav-rnc/commands/select-vehicle-profile.md) to activate a profile carrying the right dangerous-goods
restrictions and a lower maximum speed, so the route BeNav computes changes with the load.

## Command

```json
{
  "jsonrpc": "2.0",
  "method": "updateVehicleStatuses",
  "params": {
    "basicAuth": "dXNlcjpwYXNzd29yZA==",
    "vehicleStatuses": [
      {
        "id": 1,
        "names": [
          { "lang": "ENG", "val": "Available" },
          { "lang": "FRE", "val": "Disponible" }
        ],
        "icon": "https://example.com/icons/available.png"
      },
      {
        "id": 2,
        "names": [ { "lang": "ENG", "val": "On break" } ],
        "icon": "https://example.com/icons/break.png"
      }
    ]
  },
  "id": "1"
}
```

- `vehicleStatuses` The complete new set - it **replaces** the previous one. Omit `params` entirely (or send an empty list) to clear the set and disable the feature.
- `id` Unique integer identifier, used later by [`setVehicleStatus`](https://docs.benomad.com/benav-rnc/commands/set-vehicle-status.md) and reported by [`onVehicleStatusChanged`](https://docs.benomad.com/benav-rnc/notifications/on-vehicle-status-changed.md).
- `names` Localised labels. `lang` is an alpha-3 code (`ENG`, `FRE`, `ITA`, `SPA`, `GER`), case-insensitive; `val` is the label. The device language is matched first, then English, then the first entry. At least one name is required.
- `icon` URL of a PNG icon, downloaded and cached. Required and non-blank.
- `basicAuth` (Optional) The **already base64-encoded** `user:password`, used verbatim as the `Authorization: Basic` header value when downloading the icons. BeNav does not encode it for you - sending a plain `user:password` produces a malformed header and the download fails with `35 vehicle.status.icon.download.error`.

## Response

### Success

```json
{
  "jsonrpc": "2.0",
  "result": {},
  "id": "1"
}
```

### Error

Generic errors, plus `35 vehicle.status.icon.download.error` when an icon cannot be downloaded - the failing URL is carried in the error message. The new set is applied only if **every** icon downloads successfully. Duplicate ids, a blank icon or an empty `names` list are rejected with `-32700 parse.error`.
