MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / publisherSetConfig

Method publisherSetConfig

app/src/API/Handlers/MqttHandler.cpp:399–419  ·  view source on GitHub ↗

* @brief Applies a partial config patch to the publisher; rejects out-of-range values. */

Source from the content-addressed store, hash-verified

397 * @brief Applies a partial config patch to the publisher; rejects out-of-range values.
398 */
399API::CommandResponse API::Handlers::MqttHandler::publisherSetConfig(const QString& id,
400 const QJsonObject& params)
401{
402 auto& p = MQTT::Publisher::instance();
403
404 if (auto err = applyPublisherEndpoint(p, params); err)
405 return CommandResponse::makeError(id, ErrorCode::InvalidParam, *err);
406
407 if (auto err = applyPublisherTopics(p, params); err)
408 return CommandResponse::makeError(id, ErrorCode::InvalidParam, *err);
409
410 if (auto err = applyPublisherSessionAndTls(p, params); err)
411 return CommandResponse::makeError(id, ErrorCode::InvalidParam, *err);
412
413 if (params.contains(QStringLiteral("enabled")))
414 p.setEnabled(params.value(QStringLiteral("enabled")).toBool());
415
416 QJsonObject result;
417 result[QStringLiteral("updated")] = true;
418 return CommandResponse::makeSuccess(id, result);
419}
420
421/**
422 * @brief Snapshots publisher live state (connection, broker endpoint, counters).

Callers

nothing calls this directly

Calls 6

applyPublisherEndpointFunction · 0.85
applyPublisherTopicsFunction · 0.85
containsMethod · 0.45
setEnabledMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected