From d539e06b4f9e1ebec87047d14aba6b1565e38502 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Fri, 24 Apr 2026 13:15:07 -0700 Subject: [PATCH] [wpinet] DsClient: Use new port which provides IP in dotted quad format (#8807) --- wpinet/src/main/native/cpp/DsClient.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/wpinet/src/main/native/cpp/DsClient.cpp b/wpinet/src/main/native/cpp/DsClient.cpp index 05b8a8c9be..eb306b0a87 100644 --- a/wpinet/src/main/native/cpp/DsClient.cpp +++ b/wpinet/src/main/native/cpp/DsClient.cpp @@ -5,6 +5,7 @@ #include "wpi/net/DsClient.hpp" #include +#include #include @@ -62,7 +63,7 @@ void DsClient::Connect() { }; WPI_DEBUG4(m_logger, "Starting DS connection attempt"); - m_tcp->Connect("127.0.0.1", 1742, connreq); + m_tcp->Connect("127.0.0.1", 6770, connreq); } void DsClient::HandleIncoming(std::string_view in) { @@ -92,21 +93,18 @@ void DsClient::HandleIncoming(std::string_view in) { void DsClient::ParseJson() { WPI_DEBUG4(m_logger, "DsClient JSON: {}", m_json); - unsigned int ip = 0; + std::string ip; try { - ip = wpi::util::json::parse_or_throw(m_json).at("robotIP").get_int(); + ip = wpi::util::json::parse_or_throw(m_json).at("robotIP").get_string(); } catch (std::logic_error& e) { WPI_INFO(m_logger, "DsClient JSON error: {}", e.what()); return; } - if (ip == 0) { + if (ip.empty()) { clearIp(); } else { - // Convert number into dotted quad - auto newip = fmt::format("{}.{}.{}.{}", (ip >> 24) & 0xff, - (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); - WPI_INFO(m_logger, "DS received server IP: {}", newip); - setIp(newip); + WPI_INFO(m_logger, "DS received server IP: {}", ip); + setIp(ip); } }