Browse Source

feat(iot): 更新 WebSocket 编解码器为 Alink,实现更标准的协议支持

YunaiV 4 months ago
parent
commit
867ec8c070

+ 1 - 1
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/codec/alink/IotAlinkDeviceMessageCodec.java

@@ -18,7 +18,7 @@ import org.springframework.stereotype.Component;
 @Component
 public class IotAlinkDeviceMessageCodec implements IotDeviceMessageCodec {
 
-    private static final String TYPE = "Alink";
+    public static final String TYPE = "Alink";
 
     @Data
     @NoArgsConstructor

+ 2 - 2
yudao-module-iot/yudao-module-iot-gateway/src/main/java/cn/iocoder/yudao/module/iot/gateway/protocol/websocket/router/IotWebSocketUpstreamHandler.java

@@ -16,7 +16,7 @@ import cn.iocoder.yudao.module.iot.core.topic.IotDeviceIdentity;
 import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO;
 import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterRespDTO;
 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
-import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
+import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
 import cn.iocoder.yudao.module.iot.gateway.protocol.websocket.IotWebSocketUpstreamProtocol;
 import cn.iocoder.yudao.module.iot.gateway.protocol.websocket.manager.IotWebSocketConnectionManager;
 import cn.iocoder.yudao.module.iot.gateway.service.device.IotDeviceService;
@@ -37,7 +37,7 @@ public class IotWebSocketUpstreamHandler implements Handler<ServerWebSocket> {
     /**
      * 默认消息编解码类型
      */
-    private static final String CODEC_TYPE = IotWebSocketJsonDeviceMessageCodec.TYPE;
+    private static final String CODEC_TYPE = IotAlinkDeviceMessageCodec.TYPE;
 
     private static final String AUTH_METHOD = "auth";
 

+ 2 - 2
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/websocket/IotDirectDeviceWebSocketProtocolIntegrationTest.java

@@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO;
 import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
-import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
+import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
 import io.vertx.core.Vertx;
 import io.vertx.core.http.WebSocket;
 import io.vertx.core.http.WebSocketClient;
@@ -59,7 +59,7 @@ public class IotDirectDeviceWebSocketProtocolIntegrationTest {
 
     // ===================== 编解码器选择 =====================
 
-    private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
+    private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
 
     // ===================== 直连设备信息(根据实际情况修改,从 iot_device 表查询) =====================
 

+ 2 - 2
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/websocket/IotGatewayDeviceWebSocketProtocolIntegrationTest.java

@@ -14,7 +14,7 @@ import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoDeleteReqDTO;
 import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoGetReqDTO;
 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
-import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
+import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
 import io.vertx.core.Vertx;
 import io.vertx.core.http.WebSocket;
 import io.vertx.core.http.WebSocketClient;
@@ -67,7 +67,7 @@ public class IotGatewayDeviceWebSocketProtocolIntegrationTest {
 
     // ===================== 编解码器选择 =====================
 
-    private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
+    private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
 
     // ===================== 网关设备信息(根据实际情况修改,从 iot_device 表查询网关设备) =====================
 

+ 2 - 2
yudao-module-iot/yudao-module-iot-gateway/src/test/java/cn/iocoder/yudao/module/iot/gateway/protocol/websocket/IotGatewaySubDeviceWebSocketProtocolIntegrationTest.java

@@ -10,7 +10,7 @@ import cn.iocoder.yudao.module.iot.core.topic.event.IotDeviceEventPostReqDTO;
 import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
-import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
+import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
 import io.vertx.core.Vertx;
 import io.vertx.core.http.WebSocket;
 import io.vertx.core.http.WebSocketClient;
@@ -60,7 +60,7 @@ public class IotGatewaySubDeviceWebSocketProtocolIntegrationTest {
 
     // ===================== 编解码器选择 =====================
 
-    private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
+    private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
 
     // ===================== 网关子设备信息(根据实际情况修改,从 iot_device 表查询子设备) =====================