Commit 867ec8c07083a1c1834ead944dc7e1f3d2542358

Authored by YunaiV
1 parent 0072482a

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

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;
18 18 @Component
19 19 public class IotAlinkDeviceMessageCodec implements IotDeviceMessageCodec {
20 20  
21   - private static final String TYPE = "Alink";
  21 + public static final String TYPE = "Alink";
22 22  
23 23 @Data
24 24 @NoArgsConstructor
... ...
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;
16 16 import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterReqDTO;
17 17 import cn.iocoder.yudao.module.iot.core.topic.auth.IotDeviceRegisterRespDTO;
18 18 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
19   -import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
  19 +import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
20 20 import cn.iocoder.yudao.module.iot.gateway.protocol.websocket.IotWebSocketUpstreamProtocol;
21 21 import cn.iocoder.yudao.module.iot.gateway.protocol.websocket.manager.IotWebSocketConnectionManager;
22 22 import cn.iocoder.yudao.module.iot.gateway.service.device.IotDeviceService;
... ... @@ -37,7 +37,7 @@ public class IotWebSocketUpstreamHandler implements Handler<ServerWebSocket> {
37 37 /**
38 38 * 默认消息编解码类型
39 39 */
40   - private static final String CODEC_TYPE = IotWebSocketJsonDeviceMessageCodec.TYPE;
  40 + private static final String CODEC_TYPE = IotAlinkDeviceMessageCodec.TYPE;
41 41  
42 42 private static final String AUTH_METHOD = "auth";
43 43  
... ...
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;
11 11 import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
12 12 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
13 13 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
14   -import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
  14 +import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
15 15 import io.vertx.core.Vertx;
16 16 import io.vertx.core.http.WebSocket;
17 17 import io.vertx.core.http.WebSocketClient;
... ... @@ -59,7 +59,7 @@ public class IotDirectDeviceWebSocketProtocolIntegrationTest {
59 59  
60 60 // ===================== 编解码器选择 =====================
61 61  
62   - private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
  62 + private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
63 63  
64 64 // ===================== 直连设备信息(根据实际情况修改,从 iot_device 表查询) =====================
65 65  
... ...
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;
14 14 import cn.iocoder.yudao.module.iot.core.topic.topo.IotDeviceTopoGetReqDTO;
15 15 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
16 16 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
17   -import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
  17 +import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
18 18 import io.vertx.core.Vertx;
19 19 import io.vertx.core.http.WebSocket;
20 20 import io.vertx.core.http.WebSocketClient;
... ... @@ -67,7 +67,7 @@ public class IotGatewayDeviceWebSocketProtocolIntegrationTest {
67 67  
68 68 // ===================== 编解码器选择 =====================
69 69  
70   - private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
  70 + private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
71 71  
72 72 // ===================== 网关设备信息(根据实际情况修改,从 iot_device 表查询网关设备) =====================
73 73  
... ...
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;
10 10 import cn.iocoder.yudao.module.iot.core.topic.property.IotDevicePropertyPostReqDTO;
11 11 import cn.iocoder.yudao.module.iot.core.util.IotDeviceAuthUtils;
12 12 import cn.iocoder.yudao.module.iot.gateway.codec.IotDeviceMessageCodec;
13   -import cn.iocoder.yudao.module.iot.gateway.codec.websocket.IotWebSocketJsonDeviceMessageCodec;
  13 +import cn.iocoder.yudao.module.iot.gateway.codec.alink.IotAlinkDeviceMessageCodec;
14 14 import io.vertx.core.Vertx;
15 15 import io.vertx.core.http.WebSocket;
16 16 import io.vertx.core.http.WebSocketClient;
... ... @@ -60,7 +60,7 @@ public class IotGatewaySubDeviceWebSocketProtocolIntegrationTest {
60 60  
61 61 // ===================== 编解码器选择 =====================
62 62  
63   - private static final IotDeviceMessageCodec CODEC = new IotWebSocketJsonDeviceMessageCodec();
  63 + private static final IotDeviceMessageCodec CODEC = new IotAlinkDeviceMessageCodec();
64 64  
65 65 // ===================== 网关子设备信息(根据实际情况修改,从 iot_device 表查询子设备) =====================
66 66  
... ...