[7.0.0] ADAS LIB 修改心跳协议

This commit is contained in:
xinfengkun
2025-04-01 11:01:23 +08:00
parent c2483fb577
commit 93f4c88249
3 changed files with 33 additions and 1 deletions

View File

@@ -100,6 +100,7 @@ enum MessageType
MsgTypePowerUnit = 0x1012e;//电源模块通信
MsgTypeSSMFuncMsg = 0x1012f;//SSM功能(上下行)
MsgTypeSSMFuncStatusQuery = 0x10130;//SSM功能状态查询及返回(上下行)
// MsgTypeHeartbeat = 0x10131;//PAD给域控下发心跳 1Hz 空数据 TODO 废弃,改用发送"6e 68 6f 69"数据作为心跳
MsgTypeCaptureImgReqOnTakeOver = 0x10132;//人工接管时PAD请求前后摄像头数据
MsgTypeEzhouCloud = 0x10133;//NED pad通信不仅限于鄂州 bus ros1 MAP500版本支持 bus ros2 MAP480版本支持taxi 还没有上
MsgTypeCopyBag = 0x10134;//数据落盘(上下行)

View File

@@ -70,6 +70,9 @@ import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import bag_manager.BagManagerOuterClass;
@@ -146,6 +149,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
*/
private SubscribeInterface subscribeInterface;
private Timer carConfigReqTimer;//车辆基础信息请求 多次请求防止无法收到基础信息情况出现
private ScheduledExecutorService heartbeatScheduler;//心跳发送
private OnAdasListener mAdasListener;
//连接状态listener
@@ -868,6 +872,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
AutopilotAbilityManager.getInstance().start();
ParallelDrivingManager.getInstance().start();
// startCheckCompatibility();
startSendHeartbeat();
//更新连接成功状态之后再根据是否认证进行认证检查
if (adasOptions.isCertification()) {
//启动认证超时
@@ -884,6 +889,7 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
ParallelDrivingManager.getInstance().stop();
AdasManager.getInstance().setCarConfig(null);
// stopCheckCompatibility();
stopSendHeartbeat();
stopDispatchHandler();
isInitConfigure.set(false);
stopCarConfigReq();
@@ -925,6 +931,26 @@ public class AdasChannel implements IAdasNetCommApi, FpgaSocket.IWebSocketConnec
}
}
//车辆基础信息请求
private synchronized void startSendHeartbeat() {
if (heartbeatScheduler == null || heartbeatScheduler.isShutdown()) {
heartbeatScheduler = Executors.newSingleThreadScheduledExecutor();
heartbeatScheduler.scheduleWithFixedDelay(() -> {
if (mSocket != null && mSocket.isConnected()) {
mSocket.sendDataWebSocket(Constants.RAW_HEART_BEAT);
}
}, 100, 1000, TimeUnit.MILLISECONDS);
}
}
private synchronized void stopSendHeartbeat() {
if (heartbeatScheduler != null) {
heartbeatScheduler.shutdownNow();
heartbeatScheduler = null;
}
}
// /**
// * 检查兼容性
// */

View File

@@ -4,6 +4,8 @@ import com.google.gson.reflect.TypeToken;
import java.util.HashSet;
import okio.ByteString;
/**
* @ProjectName: lib-adas-fpga
* @Package: PACKAGE_NAME
@@ -33,11 +35,14 @@ public class Constants {
* 数据协议头
*/
public static final byte[] RAW_MG = new byte[]{(byte) 0x6d, 0x67};
/**
* 心跳协议
*/
public static final ByteString RAW_HEART_BEAT = ByteString.of((byte) 0x6e, (byte) 0x68, (byte) 0x6f, (byte) 0x69);
public static final String DEFAULT_PING_ADDRESS_LIST = "[\"192.168.1.102\", \"192.168.8.102\"]";
/**
* 终端角色类型
*/