IdentityController

Client facade for querying vehicle identity and configuration from the identity service.

#include <identity_controller.hpp>

Classes

class IdentityController

Retrieves vehicle identity and configuration sections from the identity service.

Note:

Only the client role is exposed here. The identity service itself is not part of the public SDK surface.

struct Identity

Vehicle identity payload returned by FetchIdentity.

FieldTypeDescription
vehicle_id std::string Stable per-vehicle identifier (e.g. serial number)
vehicle_type std::string Vehicle family / model designation
hardware_rev std::string Hardware revision string reported by the vehicle
software_version std::string Firmware / software version string

struct ProfileInfo

Metadata for one available identity profile.

FieldTypeDescription
vehicle_id std::string profile's identity vehicle_id
robot_name std::string human-readable display name for the profile
vehicle_type std::string vehicle family / model designation
hardware_rev std::string hardware revision string
filename std::string profile file name in the catalogue
is_active bool true if this is the running identity

struct ActivateResult

Result of an activation request.

FieldTypeDescription
ok bool true if the profile was activated
message std::string human-readable status from the service
explicit IdentityController(std::string host = kDefaultHost, uint16_t port = kDefaultPort)

Constructs a client targeting the given host and port.

ParameterTypeDescription
host std::string Identity service host address.
port uint16_t Identity service port.

Returns: explicit

static auto Client(std::string host = kDefaultHost, uint16_t port = kDefaultPort) -> IdentityController

Static factory that creates a client targeting the given host and port.

ParameterTypeDescription
host std::string Identity service host address.
port uint16_t Identity service port.

Returns: A new IdentityController instance.

auto FetchIdentity(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) -> std::optional<Identity>

Requests vehicle identity from the service.

ParameterTypeDescription
timeout std::chrono::milliseconds Maximum time to wait for a reply.

Returns: Populated Identity on success, or std::nullopt if the request

auto FetchSection(const std::string& section_name, std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) -> std::optional<std::string>

Fetches a single named configuration section.

ParameterTypeDescription
section_name const std::string& Name of the configuration section to retrieve.
timeout std::chrono::milliseconds Maximum time to wait for a reply.

Returns: JSON text of the section on success, or std::nullopt if the

auto FetchWholeConfig(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) -> std::optional<std::string>

Fetches the entire configuration tree.

ParameterTypeDescription
timeout std::chrono::milliseconds Maximum time to wait for a reply.

Returns: Full configuration as JSON text on success, or std::nullopt if

auto OnIdentityChanged(ChangeCallback cb, const std::string& multicast_addr = kDefaultMulticastAddr, uint16_t multicast_port = kDefaultPort, const std::string& iface_addr = "") -> bool

Subscribes to identity-change notifications pushed by the service.

The callback fires once on the first identity seen, then again only when the identity meaningfully changes — a bumped config_revision or a new boot_id (fresh reboot) — so an app can re-fetch its sections or reset cached state without polling. The callback runs on a background receiver thread; keep it cheap and thread-safe. Calling this again replaces the previous subscription.

ParameterTypeDescription
cb ChangeCallback Invoked with the new Identity on change.
multicast_addr const std::string& Group to join (default 224.0.0.1); must match the
multicast_port uint16_t UDP port (default 14595).
iface_addr const std::string& Interface to join on; empty = let the OS choose.

Returns: true if the socket + group join succeeded; false otherwise.

auto StopWatching() -> void

Stops the change subscription and joins the receiver thread. Idempotent; also called by the destructor.

auto ListProfiles(std::chrono::milliseconds timeout = std::chrono::milliseconds(2000)) -> std::optional<std::vector<ProfileInfo>>

Lists the identity profiles the service has staged (view all supported identities). The one matching the running identity has `is_active == true`.

ParameterTypeDescription
timeout std::chrono::milliseconds

Returns: Profiles on success; std::nullopt on timeout / unreachable.

auto ActivateProfile(const std::string& profile_id, std::chrono::milliseconds timeout = std::chrono::milliseconds(3000)) -> ActivateResult

Requests that a profile become the active identity (change the running robot config). The service swaps its identity and broadcasts a change, which subscribers see via OnIdentityChanged.

ParameterTypeDescription
profile_id const std::string& vehicle_id or filename stem from a ProfileInfo.
timeout std::chrono::milliseconds

Returns: The service's result; ok=false (with a message) if activation is