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

Method connect

app/src/API/Handlers/IOManagerHandler.cpp:247–269  ·  view source on GitHub ↗

* @brief Connect to the configured device */

Source from the content-addressed store, hash-verified

245 * @brief Connect to the configured device
246 */
247API::CommandResponse API::Handlers::IOManagerHandler::connect(const QString& id,
248 const QJsonObject& params)
249{
250 Q_UNUSED(params)
251
252 auto& manager = IO::ConnectionManager::instance();
253
254 if (manager.isConnected()) {
255 return CommandResponse::makeError(
256 id, ErrorCode::ExecutionError, QStringLiteral("Already connected"));
257 }
258
259 if (!manager.configurationOk()) {
260 return CommandResponse::makeError(
261 id, ErrorCode::ExecutionError, QStringLiteral("Device configuration is invalid"));
262 }
263
264 manager.connectDevice();
265
266 QJsonObject result;
267 result[QStringLiteral("connected")] = manager.isConnected();
268 return CommandResponse::makeSuccess(id, result);
269}
270
271/**
272 * @brief Disconnect from the current device

Callers

nothing calls this directly

Calls 3

connectDeviceMethod · 0.80
isConnectedMethod · 0.45
configurationOkMethod · 0.45

Tested by

no test coverage detected