Skip to content

SpokeZoneConfig

#include <mrx/spoke-zone/config/SpokeZoneConfig.hpp>
class mrx::spokezone::SpokeZoneConfig

Inherits: QObject

Owns the validated Spoke.Zone state associated with one caller-owned configuration store.

The caller retains ownership of the ConfigStore and must keep it alive longer than this wrapper. The wrapper begins unloaded, replaces its immutable Config snapshot and canonical path only after a successful load, and preserves the last valid state when a later load or replacement fails. Accessors read only from this snapshot and return their schema defaults (or empty required values) while unloaded.

Construct the wrapper, inspect its v3 schema and canonical path, and load a validated snapshot from disk.

ReturnNameDescription
mrx::core::ConfigResultResultResult returned by schema validation and file loading.
SpokeZoneConfig explicit
ResultloadLoads and validates the INI file bound through the configuration store.
mrx::core::ConfigSchemaschema staticFetches the current Spoke.Zone configuration schema.
QStringpath staticReturns the canonical path to the config file.

using Result = mrx::core::ConfigResult

Result returned by schema validation and file loading.


explicit
explicit SpokeZoneConfig(QObject* parent = nullptr)

Result load()

Loads and validates the INI file bound through the configuration store.

The exact Core validation result for this attempt.

A successful load replaces the stored immutable Config snapshot and canonical path. A failed initial load leaves the wrapper unloaded, while a failed reload preserves the last successful snapshot and path.


static
static mrx::core::ConfigSchema schema()

Fetches the current Spoke.Zone configuration schema.

Module-owned schema declaration.


static
static QString path()

Returns the canonical path to the config file.

Canonical INI path, or an empty string while the wrapper is unloaded.

Settings for the Spoke.Zone API identity and shared token.

The token is also used as the MQTT username.

ReturnNameDescription
boolreplaceTokenReplaces the shared token in the loaded v3 INI file.
QStringmqttUsername constDerives the MQTT username from the stored shared token.
QStringapiServer constReads the configured Spoke.Zone API server URL.
QStringdeviceId constReads the configured device identifier.
QStringdeviceUuid constReads the configured device UUID.

bool replaceToken(const QString& newToken)

Replaces the shared token in the loaded v3 INI file.

True only after the complete staged INI has been verifiably committed.

A successful call updates the stored validated snapshot after the file commit.

NameTypeDescription
newTokenconst QString&Proposed non-empty shared token; the literal is never put in an error message.

const
QString mqttUsername() const

Derives the MQTT username from the stored shared token.

The token value supplied as the MQTT username at the adapter boundary.

A successful load() is a precondition for this accessor.


const
QString apiServer() const

Reads the configured Spoke.Zone API server URL.

The configured API server, or the schema default when omitted.


const
QString deviceId() const

Reads the configured device identifier.

The required device identifier stored in the validated configuration.


const
QString deviceUuid() const

Reads the configured device UUID.

The required device UUID stored in the validated configuration.

Broker credentials and transport parameters used when the device connects to Spoke.Zone over MQTT.

ReturnNameDescription
QStringmqttPassword constReads the configured literal MQTT password from the stored snapshot.
QStringmqttHost constReads the configured MQTT broker host.
quint16mqttPort constReads the configured MQTT broker port.
quint32mqttKeepAlive constReads the configured MQTT keep-alive interval.

const
QString mqttPassword() const

Reads the configured literal MQTT password from the stored snapshot.

The configured password, including the schema default when omitted.

A successful load() is a precondition for this accessor.


const
QString mqttHost() const

Reads the configured MQTT broker host.

The configured MQTT host, or the schema default when omitted.


const
quint16 mqttPort() const

Reads the configured MQTT broker port.

The configured MQTT port, or the schema default when omitted.


const
quint32 mqttKeepAlive() const

Reads the configured MQTT keep-alive interval.

The configured keep-alive interval, or the schema default when omitted.

Local filenames for alert-event data and the downloaded model definition; these are not MQTT model settings.

ReturnNameDescription
QStringalertsFile constReads the configured alerts data filename.
QStringmodelFile constReads the configured model data filename.

const
QString alertsFile() const

Reads the configured alerts data filename.

The configured alerts filename, or the schema default when omitted.


const
QString modelFile() const

Reads the configured model data filename.

The configured model filename, or the schema default when omitted.

Values from the Live Data section of the Spoke.Zone model.

They control live CAN/GPS broadcasts and how much data around an event trigger is included. MQTT values are persisted under their exact topic suffixes in [model].

ReturnNameDescription
boolliveCanDataEnabled constReads whether the device should publish live CAN data from the model’s Live Data section (live_can_data).
boolsetLiveCanDataEnabledPersists the model’s Live Data section live_can_data MQTT setting.
boolliveGpsDataEnabled constReads whether the device should publish live GPS data from the model’s Live Data section (live_gps_data).
boolsetLiveGpsDataEnabledPersists the model’s Live Data section live_gps_data MQTT setting.
quint32canPublishIntervalSeconds constReads the CAN publish frequency from the model’s Live Data section (publish_freq).
boolsetCanPublishIntervalSecondsPersists the model’s Live Data section publish_freq MQTT setting.
quint32locationPublishIntervalSeconds constReads the location publish frequency from the model’s Live Data section (location_freq).
boolsetLocationPublishIntervalSecondsPersists the model’s Live Data section location_freq MQTT setting.
quint32eventCaptureBeforeSeconds constReads the pre-trigger capture interval from the model’s Live Data section (event_capture_before).
boolsetEventCaptureBeforeSecondsPersists the model’s Live Data section event_capture_before setting, in seconds.
quint32eventCaptureAfterSeconds constReads the post-trigger capture interval from the model’s Live Data section (event_capture_after).
boolsetEventCaptureAfterSecondsPersists the model’s Live Data section event_capture_after setting, in seconds.

const
bool liveCanDataEnabled() const

Reads whether the device should publish live CAN data from the model’s Live Data section (live_can_data).

The configured state, or false until Spoke.Zone sends the setting.


bool setLiveCanDataEnabled(bool enabled)

Persists the model’s Live Data section live_can_data MQTT setting.


const
bool liveGpsDataEnabled() const

Reads whether the device should publish live GPS data from the model’s Live Data section (live_gps_data).

The configured state, or false until Spoke.Zone sends the setting.


bool setLiveGpsDataEnabled(bool enabled)

Persists the model’s Live Data section live_gps_data MQTT setting.


const
quint32 canPublishIntervalSeconds() const

Reads the CAN publish frequency from the model’s Live Data section (publish_freq).

Seconds between live CAN data broadcasts, or the schema default when omitted.


bool setCanPublishIntervalSeconds(quint32 seconds)

Persists the model’s Live Data section publish_freq MQTT setting.

True only when the value validates and is successfully persisted.

NameTypeDescription
secondsquint32Seconds between live CAN data broadcasts.

const
quint32 locationPublishIntervalSeconds() const

Reads the location publish frequency from the model’s Live Data section (location_freq).

Seconds between location broadcasts, or the schema default when omitted.


bool setLocationPublishIntervalSeconds(quint32 seconds)

Persists the model’s Live Data section location_freq MQTT setting.

True only when the value validates and is successfully persisted.

NameTypeDescription
secondsquint32Seconds between location broadcasts.

const
quint32 eventCaptureBeforeSeconds() const

Reads the pre-trigger capture interval from the model’s Live Data section (event_capture_before).

The configured interval in seconds, or zero until Spoke.Zone sends the setting.


bool setEventCaptureBeforeSeconds(quint32 seconds)

Persists the model’s Live Data section event_capture_before setting, in seconds.


const
quint32 eventCaptureAfterSeconds() const

Reads the post-trigger capture interval from the model’s Live Data section (event_capture_after).

The configured interval in seconds, or zero until Spoke.Zone sends the setting.


bool setEventCaptureAfterSeconds(quint32 seconds)

Persists the model’s Live Data section event_capture_after setting, in seconds.

Values from the Logging section of the Spoke.Zone model.

They control log uploads, file size and rotation, recording cadence, and the optional UTC upload schedule. MQTT values use their exact topic suffixes in [model].

ReturnNameDescription
boollogFileUploadEnabled constReads the Logging section’s “Upload Log Files” setting (log_file).
boolsetLogFileUploadEnabledPersists the model’s Logging section log_file MQTT setting.
quint32logUploadPeriodMinutes constReads the log upload cadence from the model’s Logging section (log_upload_period).
boolsetLogUploadPeriodMinutesPersists the model’s Logging section log_upload_period setting, in minutes.
quint32logSizeMegabytes constReads the maximum log file size from the model’s Logging section (log_size).
boolsetLogSizeMegabytesPersists the model’s Logging section log_size setting, in megabytes.
quint32logRotations constReads the Logging section’s “Log Rotations” setting (log_count).
boolsetLogRotationsPersists the model’s Logging section log_count MQTT setting.
booluploadScheduleEnabled constReads the Logging section’s upload-schedule toggle (enable_upload_schedule).
boolsetUploadScheduleEnabledPersists the model’s Logging section enable_upload_schedule MQTT setting.
QJsonObjectuploadSchedule constReads allowed upload days and UTC time from the model’s Logging section (upload_schedule).
boolsetUploadSchedulePersists the Logging section’s upload_schedule object with string days_of_week and start_time fields.
quint32logDataFrequencySeconds constReads the CAN recording cadence from the model’s Logging section (log_freq).
boolsetLogDataFrequencySecondsPersists the model’s Logging section log_freq setting, in seconds.
quint32logGpsFrequencySeconds constReads the GPS recording cadence from the model’s Logging section (log_gps_freq).
boolsetLogGpsFrequencySecondsPersists the model’s Logging section log_gps_freq setting, in seconds.

const
bool logFileUploadEnabled() const

Reads the Logging section’s “Upload Log Files” setting (log_file).

The configured state, or false until Spoke.Zone sends the setting.


bool setLogFileUploadEnabled(bool enabled)

Persists the model’s Logging section log_file MQTT setting.


const
quint32 logUploadPeriodMinutes() const

Reads the log upload cadence from the model’s Logging section (log_upload_period).

The configured interval in minutes, or zero until Spoke.Zone sends the setting.


bool setLogUploadPeriodMinutes(quint32 minutes)

Persists the model’s Logging section log_upload_period setting, in minutes.


const
quint32 logSizeMegabytes() const

Reads the maximum log file size from the model’s Logging section (log_size).

The configured size in megabytes, or zero until Spoke.Zone sends the setting.


bool setLogSizeMegabytes(quint32 megabytes)

Persists the model’s Logging section log_size setting, in megabytes.


const
quint32 logRotations() const

Reads the Logging section’s “Log Rotations” setting (log_count).

The configured rotation count, or zero until Spoke.Zone sends the setting.


bool setLogRotations(quint32 count)

Persists the model’s Logging section log_count MQTT setting.


const
bool uploadScheduleEnabled() const

Reads the Logging section’s upload-schedule toggle (enable_upload_schedule).

The configured state, or false until Spoke.Zone sends the setting.


bool setUploadScheduleEnabled(bool enabled)

Persists the model’s Logging section enable_upload_schedule MQTT setting.


const
QJsonObject uploadSchedule() const

Reads allowed upload days and UTC time from the model’s Logging section (upload_schedule).

The JSON object with string days_of_week and start_time fields, or an empty object until configured.


bool setUploadSchedule(const QJsonObject& schedule)

Persists the Logging section’s upload_schedule object with string days_of_week and start_time fields.

True only when the object has the expected fields and the typed store write succeeds.

NameTypeDescription
scheduleconst QJsonObject&Schedule payload from Spoke.Zone.

const
quint32 logDataFrequencySeconds() const

Reads the CAN recording cadence from the model’s Logging section (log_freq).

The configured interval in seconds, or zero until Spoke.Zone sends the setting.


bool setLogDataFrequencySeconds(quint32 seconds)

Persists the model’s Logging section log_freq setting, in seconds.


const
quint32 logGpsFrequencySeconds() const

Reads the GPS recording cadence from the model’s Logging section (log_gps_freq).

The configured interval in seconds, or zero until Spoke.Zone sends the setting.


bool setLogGpsFrequencySeconds(quint32 seconds)

Persists the model’s Logging section log_gps_freq setting, in seconds.

Controls whether incoming commands are handled and exposes the configured command-topic list.

ReturnNameDescription
boolcommandsEnabled constReads whether command processing is enabled.
boolsetCommandsEnabledPersists whether command processing is enabled.
const QStringListforcedCommandTopics constReads the configured command topics as a normalized list.

const
bool commandsEnabled() const

Reads whether command processing is enabled.

The configured command-processing state, or the schema default when omitted.


bool setCommandsEnabled(bool enabled)

Persists whether command processing is enabled.

True only when a successful load validates the proposal and the typed store write succeeds.

NameTypeDescription
enabledboolProposed command-processing state.

const
const QStringList forcedCommandTopics() const

Reads the configured command topics as a normalized list.

Topics in declaration order, with surrounding whitespace removed.

The configuration file stores these as a scalar string. This accessor returns a detached list so callers cannot mutate the validated snapshot. A successful load() is a precondition.

Controls how often the SDK publishes its own version information.

This cadence is SDK-owned and is not a setting in the Spoke.Zone model editor, so it remains under [telemetry] rather than [model].

ReturnNameDescription
quint32versionsPublishIntervalSeconds constReads the SDK’s version-reporting cadence from [telemetry]; this is not a Spoke.Zone model setting.
boolsetVersionsPublishIntervalSecondsPersists the SDK’s version-reporting cadence under [telemetry], not in the Spoke.Zone model settings.

const
quint32 versionsPublishIntervalSeconds() const

Reads the SDK’s version-reporting cadence from [telemetry]; this is not a Spoke.Zone model setting.

The configured interval in seconds, or the schema default when omitted.


bool setVersionsPublishIntervalSeconds(quint32 seconds)

Persists the SDK’s version-reporting cadence under [telemetry], not in the Spoke.Zone model settings.

True only when a successful load validates the proposal and the typed store write succeeds.

NameTypeDescription
secondsquint32Proposed interval in seconds; it must satisfy the complete v3 schema.
ReturnNameDescription
voidmqttUsernameChangedProperty-change signals are emitted when a successful load after the initial load, or a successful write, changes the corresponding value.
voidserverUrlChanged
voiddeviceIdChanged
voiddeviceUuidChanged
voidmqttPasswordChanged
voidmqttHostChanged
voidmqttPortChanged
voidmqttKeepAliveChanged
voidalertsFileChanged
voidmodelFileChanged
voidliveCanDataEnabledChanged
voidliveGpsDataEnabledChanged
voidcanPublishIntervalSecondsChanged
voidlocationPublishIntervalSecondsChanged
voideventCaptureBeforeSecondsChanged
voideventCaptureAfterSecondsChanged
voidlogFileUploadEnabledChanged
voidlogUploadPeriodMinutesChanged
voidlogSizeMegabytesChanged
voidlogRotationsChanged
voiduploadScheduleEnabledChanged
voiduploadScheduleChanged
voidlogDataFrequencySecondsChanged
voidlogGpsFrequencySecondsChanged
voidcommandsEnabledChanged
voidforcedCommandTopicsChanged
voidversionsPublishIntervalSecondsChanged

void mqttUsernameChanged()

Property-change signals are emitted when a successful load after the initial load, or a successful write, changes the corresponding value.

The initial successful load is silent; before it, accessors return defaults.


void serverUrlChanged()

void deviceIdChanged()

void deviceUuidChanged()

void mqttPasswordChanged()

void mqttHostChanged()

void mqttPortChanged()

void mqttKeepAliveChanged()

void alertsFileChanged()

void modelFileChanged()

void liveCanDataEnabledChanged()

void liveGpsDataEnabledChanged()

void canPublishIntervalSecondsChanged()

void locationPublishIntervalSecondsChanged()

void eventCaptureBeforeSecondsChanged()

void eventCaptureAfterSecondsChanged()

void logFileUploadEnabledChanged()

void logUploadPeriodMinutesChanged()

void logSizeMegabytesChanged()

void logRotationsChanged()

void uploadScheduleEnabledChanged()

void uploadScheduleChanged()

void logDataFrequencySecondsChanged()

void logGpsFrequencySecondsChanged()

void commandsEnabledChanged()

void forcedCommandTopicsChanged()

void versionsPublishIntervalSecondsChanged()