* @brief Configures and connects a TCP socket from a CLI host:port string. */
| 491 | * @brief Configures and connects a TCP socket from a CLI host:port string. |
| 492 | */ |
| 493 | void CLI::setupTcpConnection(const QString& tcpAddress) |
| 494 | { |
| 495 | const QStringList parts = tcpAddress.split(':'); |
| 496 | if (parts.size() != 2) { |
| 497 | qWarning() << "Invalid TCP address format. Expected: host:port"; |
| 498 | return; |
| 499 | } |
| 500 | |
| 501 | bool ok = false; |
| 502 | const quint16 port = parts[1].toUInt(&ok); |
| 503 | if (!ok || port == 0) { |
| 504 | qWarning() << "Invalid TCP port:" << parts[1]; |
| 505 | return; |
| 506 | } |
| 507 | |
| 508 | IO::ConnectionManager::instance().setBusType(SerialStudio::BusType::Network); |
| 509 | IO::ConnectionManager::instance().network()->setTcpSocket(); |
| 510 | IO::ConnectionManager::instance().network()->setRemoteAddress(parts[0]); |
| 511 | IO::ConnectionManager::instance().network()->setTcpPort(port); |
| 512 | IO::ConnectionManager::instance().connectDevice(); |
| 513 | } |
| 514 | |
| 515 | /** |
| 516 | * @brief Applies the optional --udp-remote spec to the active network driver. |
nothing calls this directly
no test coverage detected