From 11ef555eeadc0c4a0643c64e1b9d5daa771c1ac1 Mon Sep 17 00:00:00 2001 From: yarnom Date: Tue, 28 Oct 2025 15:55:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=9D=E8=AF=95=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=96=AD=E8=81=94=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../executor/D331RtcmMessageExecutor.java | 15 +++++++++++---- .../sideslope/ntrip/RtkrcvConfigService.java | 14 ++++++++++++++ .../sideslope/rtkcluster/RtkClusterService.java | 11 +++++++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java index e8bf4a19..90120cd9 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/executor/D331RtcmMessageExecutor.java @@ -122,14 +122,21 @@ public class D331RtcmMessageExecutor implements Executor deviceBs.setGeoidSeparation(gga.getGeoidSeparation()); } - // 添加NTRIP处理 + // 添加NTRIP处理 + rtkCluster 推送 if(deviceBs.getForwardToNtrip()) { byte[] srcdata = message.getSrcData(); - String rtcm = ByteUtil.bytesToHexString(srcdata); - sendToNtrip(id, rtcm); + String hex = ByteUtil.bytesToHexString(srcdata); + // 1) NTRIP:发送提取后的 RTCM 帧 + sendToNtrip(id, hex); + // 2) rtkCluster:优先发送干净的 RTCM 帧(去除任何封装),退化时发送原始数据 try { - rtkClusterService.sendRtcm(id, rtcm); + String rtcmsHex = RtcmGgaUtil.getRtcms(hex).toString(); + if (rtcmsHex != null && !rtcmsHex.isEmpty()) { + rtkClusterService.sendRtcmBytes(id, ByteUtil.hexStringTobyte(rtcmsHex)); + } else { + rtkClusterService.sendRtcmBytes(id, srcdata); + } } catch (Exception e) { logger.debug("send to rtkCluster failed for {}: {}", id, e.getMessage()); } diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/ntrip/RtkrcvConfigService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/ntrip/RtkrcvConfigService.java index fafbaa14..e4615615 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/ntrip/RtkrcvConfigService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/ntrip/RtkrcvConfigService.java @@ -55,6 +55,13 @@ public class RtkrcvConfigService { replaced = replaceValueLine(replaced, "inpstr2-path", nz(profile.getInpstr2Path())); replaced = replaceValueLine(replaced, "inpstr3-path", nz(profile.getInpstr3Path())); replaced = replaceValueLine(replaced, "outstr1-path", nz(profile.getOutstr1Path())); + // If local tcp endpoints are used (e.g., 127.0.0.1:port), force type to tcpcli + if (looksLikeTcpEndpoint(profile.getInpstr1Path())) { + replaced = replaceValueLine(replaced, "inpstr1-type", "tcpcli"); + } + if (looksLikeTcpEndpoint(profile.getOutstr1Path())) { + replaced = replaceValueLine(replaced, "outstr1-type", "tcpcli"); + } Integer outHeight = profile.getOutHeight(); int heightValue = (outHeight == null) ? 1 : (outHeight == 0 ? 0 : 1); replaced = replaceValueLine(replaced, "out-height", String.valueOf(heightValue)); @@ -94,6 +101,13 @@ public class RtkrcvConfigService { return s == null ? "" : s; } + private boolean looksLikeTcpEndpoint(String path) { + if (path == null) return false; + String p = path.trim(); + // Plain host:port without '@' credentials or path '/' considered tcp endpoint + return p.contains(":") && !p.contains("@") && !p.contains("/"); + } + /** * Replace the value of a line like: "key = value # comment" while preserving spacing and comment. */ diff --git a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/rtkcluster/RtkClusterService.java b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/rtkcluster/RtkClusterService.java index 6e4b833d..4a76f87e 100644 --- a/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/rtkcluster/RtkClusterService.java +++ b/sec-beidou-rtcm/src/main/java/com/imdroid/sideslope/rtkcluster/RtkClusterService.java @@ -156,6 +156,13 @@ public class RtkClusterService implements ApplicationRunner { ep.enqueueRtcm(data); } + public void sendRtcmBytes(String deviceId, byte[] data) { + if (data == null || data.length == 0) return; + DeviceEndpoint ep = endpoints.get(deviceId); + if (ep == null) return; + ep.enqueueRtcm(data); + } + static class DeviceEndpoint { private final int port; private final ExecutorService exec; @@ -215,12 +222,16 @@ public class RtkClusterService implements ApplicationRunner { if (n > 0 && isLikelyText(probe, n)) { // OUT connection (NMEA etc.) closeQuietly(outConn); + s.setTcpNoDelay(true); + s.setKeepAlive(true); outConn = s; LOGGER.debug("Endpoint {} OUT connected", port); pumpOut(outConn, probe, n); } else { // IN connection (RTCM sink) closeQuietly(inConn); + s.setTcpNoDelay(true); + s.setKeepAlive(true); inConn = s; LOGGER.debug("Endpoint {} IN connected", port); }