* @brief Applies a partial config patch to the publisher; rejects out-of-range values. */
| 397 | * @brief Applies a partial config patch to the publisher; rejects out-of-range values. |
| 398 | */ |
| 399 | API::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). |
nothing calls this directly
no test coverage detected