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

Method subscriberGetConfig

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

* @brief Returns the subscriber driver configuration; password is never included. */

Source from the content-addressed store, hash-verified

453 * @brief Returns the subscriber driver configuration; password is never included.
454 */
455API::CommandResponse API::Handlers::MqttHandler::subscriberGetConfig(const QString& id,
456 const QJsonObject& params)
457{
458 Q_UNUSED(params)
459
460 const auto* d = subscriber();
461 if (!d)
462 return CommandResponse::makeError(
463 id, ErrorCode::ExecutionError, QStringLiteral("MQTT subscriber driver unavailable"));
464
465 MQTT::CredentialVault vault;
466 const bool hasCreds = vault.hasCredentials(d->hostname(), d->port());
467
468 QJsonObject result;
469 result[QStringLiteral("hostname")] = d->hostname();
470 result[QStringLiteral("port")] = d->port();
471 result[QStringLiteral("clientId")] = d->clientId();
472 result[QStringLiteral("username")] = d->username();
473 result[QStringLiteral("hasCredentials")] = hasCreds;
474 result[QStringLiteral("topicFilter")] = d->topicFilter();
475 result[QStringLiteral("cleanSession")] = d->cleanSession();
476 result[QStringLiteral("autoKeepAlive")] = d->autoKeepAlive();
477 result[QStringLiteral("keepAlive")] = d->keepAlive();
478 result[QStringLiteral("mqttVersion")] = d->mqttVersion();
479 result[QStringLiteral("sslEnabled")] = d->sslEnabled();
480 result[QStringLiteral("sslProtocol")] = d->sslProtocol();
481 result[QStringLiteral("peerVerifyMode")] = d->peerVerifyMode();
482 result[QStringLiteral("peerVerifyDepth")] = d->peerVerifyDepth();
483
484 result[QStringLiteral("mqttVersions")] = QJsonArray::fromStringList(d->mqttVersions());
485 result[QStringLiteral("sslProtocols")] = QJsonArray::fromStringList(d->sslProtocols());
486 result[QStringLiteral("peerVerifyModes")] = QJsonArray::fromStringList(d->peerVerifyModes());
487 return CommandResponse::makeSuccess(id, result);
488}
489
490/**
491 * @brief Applies endpoint + credential + topic fields to the subscriber.

Callers

nothing calls this directly

Calls 15

subscriberFunction · 0.85
hasCredentialsMethod · 0.80
topicFilterMethod · 0.80
autoKeepAliveMethod · 0.80
hostnameMethod · 0.45
portMethod · 0.45
clientIdMethod · 0.45
usernameMethod · 0.45
cleanSessionMethod · 0.45
keepAliveMethod · 0.45
mqttVersionMethod · 0.45
sslEnabledMethod · 0.45

Tested by

no test coverage detected