From 77039ce073412e7f58f7d4692f97c2aff404432c Mon Sep 17 00:00:00 2001 From: LSF <695944503@qq.com> Date: Tue, 20 Aug 2024 10:46:57 +0800 Subject: [PATCH] =?UTF-8?q?add:=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maku/iot/communication/dto/BaseDeviceID.java | 6 +- .../net/maku/iot/communication/dto/TcpMsgDTO.java | 6 +- .../communication/service/BaseCommunication.java | 5 +- .../service/CommunicationServiceFactory.java | 6 +- .../iot/communication/service/MQTTService.java | 8 +- .../maku/iot/communication/service/TCPService.java | 6 +- .../net/maku/iot/communication/tcp/TcpGateway.java | 9 -- .../tcp/config/DeviceClientStartupConfig.java | 41 +++++++++ .../tcp/config/DeviceEmulatorConfig.java | 97 ++++++++++++++++++++++ .../tcp/config/NettyClientConfig.java | 89 -------------------- .../tcp/config/NettyClientStartupConfig.java | 36 -------- .../tcp/config/NettyServerConfig.java | 8 +- .../iot/communication/tcp/config/TcpClient.java | 42 ---------- .../tcp/handler/ConnectionHandler.java | 6 +- .../DeviceCommandResponseTCPMessageHandler.java | 9 +- .../handler/DevicePropertyTCPMessageHandler.java | 6 +- 16 files changed, 172 insertions(+), 208 deletions(-) create mode 100644 maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceClientStartupConfig.java create mode 100644 maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceEmulatorConfig.java delete mode 100644 maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientConfig.java delete mode 100644 maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientStartupConfig.java delete mode 100644 maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/TcpClient.java diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/BaseDeviceID.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/BaseDeviceID.java index cf51887..5b32337 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/BaseDeviceID.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/BaseDeviceID.java @@ -4,9 +4,9 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/14 17:24 + * 设备ID + * + * @author LSF maku_lsf@163.com */ @Data @Schema(description = "设备ID") diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/TcpMsgDTO.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/TcpMsgDTO.java index b2fdf66..adf7658 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/TcpMsgDTO.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/dto/TcpMsgDTO.java @@ -4,9 +4,9 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/14 19:31 + * tcp通讯数据包 + * + * @author LSF maku_lsf@163.com */ @Data @Schema(description = "tcp通讯数据包装类") diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/BaseCommunication.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/BaseCommunication.java index 15882ac..0707cf4 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/BaseCommunication.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/BaseCommunication.java @@ -4,8 +4,11 @@ import net.maku.iot.entity.IotDeviceEntity; import net.maku.iot.enums.DeviceCommandEnum; import net.maku.iot.communication.dto.DeviceCommandResponseDTO; + /** - * 基础通信协议具备功能 + * 通信协议具备功能 + * + * @author LSF maku_lsf@163.com */ public interface BaseCommunication { diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/CommunicationServiceFactory.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/CommunicationServiceFactory.java index 4d34019..b05cb41 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/CommunicationServiceFactory.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/CommunicationServiceFactory.java @@ -5,9 +5,9 @@ import net.maku.framework.common.exception.ServerException; import org.springframework.stereotype.Service; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/9 14:53 + * 设备协议服务工厂 + * + * @author LSF maku_lsf@163.com */ @Service @AllArgsConstructor diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/MQTTService.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/MQTTService.java index 50c654b..fda0226 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/MQTTService.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/MQTTService.java @@ -5,10 +5,10 @@ import cn.hutool.json.JSONUtil; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import net.maku.framework.common.exception.ServerException; -import net.maku.iot.communication.mqtt.MqttGateway; import net.maku.iot.communication.dto.CommandResponseChan; import net.maku.iot.communication.dto.DeviceCommandDTO; import net.maku.iot.communication.dto.DeviceCommandResponseDTO; +import net.maku.iot.communication.mqtt.MqttGateway; import net.maku.iot.dto.DeviceClientDTO; import net.maku.iot.entity.IotDeviceEntity; import net.maku.iot.enums.DeviceCommandEnum; @@ -19,9 +19,9 @@ import org.springframework.stereotype.Component; import java.util.UUID; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/9 14:21 + * MQTT协议服务类 + * + * @author LSF maku_lsf@163.com */ @Slf4j @Component diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/TCPService.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/TCPService.java index dc166f7..12f36e3 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/TCPService.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/service/TCPService.java @@ -20,9 +20,9 @@ import org.springframework.stereotype.Component; import java.util.UUID; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/9 14:21 + * TCP协议服务类 + * + * @author LSF maku_lsf@163.com */ @Slf4j @Component diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/TcpGateway.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/TcpGateway.java index d2fdaee..b620344 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/TcpGateway.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/TcpGateway.java @@ -29,15 +29,6 @@ public class TcpGateway { } /** - * 获取设备通道 - * - * @return - */ - public ConcurrentMap getTcpDeviceChannels() { - return deviceChannels; - } - - /** * 发送命令到设备 * @param deviceId 设备ID * @param commandTopic 命令主题 diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceClientStartupConfig.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceClientStartupConfig.java new file mode 100644 index 0000000..bd3ad61 --- /dev/null +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceClientStartupConfig.java @@ -0,0 +1,41 @@ +package net.maku.iot.communication.tcp.config; + +import io.netty.bootstrap.Bootstrap; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.context.ApplicationListener; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.event.ContextRefreshedEvent; + +/** + * Netty启动顺序配置 + * + * @author LSF maku_lsf@163.com + */ +@Configuration +@Slf4j +public class DeviceClientStartupConfig implements ApplicationListener { + + private final ObjectProvider deviceClientProvider; + private final DeviceEmulatorConfig deviceEmulatorConfig; + + public DeviceClientStartupConfig(ObjectProvider deviceClientProvider, DeviceEmulatorConfig deviceEmulatorConfig) { + this.deviceClientProvider = deviceClientProvider; + this.deviceEmulatorConfig = deviceEmulatorConfig; + } + + @Override + public void onApplicationEvent(ContextRefreshedEvent event) { + try { + Thread.sleep(5000); // 延迟5秒以确保服务器启动 + Bootstrap deviceClientBootstrap = deviceClientProvider.getIfAvailable(); + if (deviceClientBootstrap != null) { + deviceEmulatorConfig.configureBootstrap(deviceClientBootstrap); + deviceClientBootstrap.connect("127.0.0.1", 8888).sync(); + log.info("Connected to Netty server on port 8888"); + } + } catch (InterruptedException e) { + log.error("Failed to connect to Netty server", e); + } + } +} diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceEmulatorConfig.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceEmulatorConfig.java new file mode 100644 index 0000000..8f4b4b0 --- /dev/null +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/DeviceEmulatorConfig.java @@ -0,0 +1,97 @@ +package net.maku.iot.communication.tcp.config; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import io.netty.bootstrap.Bootstrap; +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.ChannelOption; +import io.netty.channel.SimpleChannelInboundHandler; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.channel.socket.SocketChannel; +import io.netty.channel.socket.nio.NioSocketChannel; +import io.netty.handler.codec.string.StringDecoder; +import io.netty.handler.codec.string.StringEncoder; +import lombok.extern.slf4j.Slf4j; +import net.maku.framework.common.utils.JsonUtils; +import net.maku.iot.communication.dto.DevicePropertyDTO; +import net.maku.iot.communication.dto.TcpMsgDTO; +import net.maku.iot.dto.DeviceClientDTO; +import net.maku.iot.entity.IotDeviceEntity; +import net.maku.iot.enums.DevicePropertyEnum; +import net.maku.iot.enums.DeviceRunningStatusEnum; +import net.maku.iot.enums.DeviceTopicEnum; +import net.maku.iot.service.IotDeviceService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 设备模拟器配置,用于启动模拟设备,方便调试,默认启动系统所有的TCP设备 + * + * @author LSF maku_lsf@163.com + */ +@Slf4j +@Configuration +public class DeviceEmulatorConfig { + + @Autowired + private IotDeviceService deviceService; + + @Bean + public Bootstrap nettyClient() { + Bootstrap nettyClient = new Bootstrap(); + nettyClient.group(new NioEventLoopGroup()) + .channel(NioSocketChannel.class) + .option(ChannelOption.SO_KEEPALIVE, true) // 设置为长连接 + .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60*1000); // 设置连接超时时间 + return nettyClient; + } + + public void configureBootstrap(Bootstrap bootstrap) { + List devices = deviceService.list(new LambdaQueryWrapper().eq(IotDeviceEntity::getProtocolType, "TCP")); + for (IotDeviceEntity device : devices) { + bootstrap.handler(new ChannelInitializer() { + @Override + protected void initChannel(SocketChannel ch) { + ch.pipeline().addLast(new StringDecoder(), new StringEncoder(), new SimpleChannelInboundHandler() { + @Override + public void channelActive(ChannelHandlerContext ctx) { + //模拟设备认证 + Map authenticateMap = new HashMap(); + authenticateMap.put("authenticate", device.getId().toString()); + String authenticateMapJson = JsonUtils.toJsonString(authenticateMap); + log.info("------------------------> 发送认证信息到服务端: {}", authenticateMapJson); + ctx.writeAndFlush(authenticateMapJson); + } + + @Override + protected void channelRead0(ChannelHandlerContext ctx, String msg) { + log.info("设备 {} 接收到服务端消息: {}", device.getId(), msg); + //模拟属性上报 + if(msg.contains("authenticate passed")){ + String commandTopic = DeviceTopicEnum.PROPERTY.buildTopic(DeviceClientDTO.from(device)); + + DevicePropertyDTO devicePropertyDTO = new DevicePropertyDTO(); + devicePropertyDTO.setDeviceId(device.getId().toString()); + devicePropertyDTO.setPropertyType(DevicePropertyEnum.RUNNING_STATUS); + devicePropertyDTO.setPayload(String.valueOf(DeviceRunningStatusEnum.ONLINE.getValue())); + + TcpMsgDTO tcpMsgDTO = new TcpMsgDTO(); + tcpMsgDTO.setTopic(commandTopic); + tcpMsgDTO.setMsg(devicePropertyDTO); + + String runningStatusjson = JsonUtils.toJsonString(tcpMsgDTO); + log.info("------------------------> 设备发送上线文本:{}",runningStatusjson); + ctx.writeAndFlush(runningStatusjson); + } + } + }); + } + }); + } + } +} diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientConfig.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientConfig.java deleted file mode 100644 index 4422f34..0000000 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientConfig.java +++ /dev/null @@ -1,89 +0,0 @@ -package net.maku.iot.communication.tcp.config; - -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.*; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.codec.string.StringDecoder; -import io.netty.handler.codec.string.StringEncoder; -import lombok.extern.slf4j.Slf4j; -import net.maku.framework.common.utils.JsonUtils; -import net.maku.iot.communication.dto.DevicePropertyDTO; -import net.maku.iot.communication.dto.TcpMsgDTO; -import net.maku.iot.dto.DeviceClientDTO; -import net.maku.iot.entity.IotDeviceEntity; -import net.maku.iot.enums.DevicePropertyEnum; -import net.maku.iot.enums.DeviceRunningStatusEnum; -import net.maku.iot.enums.DeviceTopicEnum; -import net.maku.iot.service.IotDeviceService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Slf4j -@Configuration -public class NettyClientConfig { - - @Autowired - private IotDeviceService deviceService; - - @Bean - public Bootstrap nettyClient() { - Bootstrap nettyClient = new Bootstrap(); - nettyClient.group(new NioEventLoopGroup()) - .channel(NioSocketChannel.class) - .option(ChannelOption.SO_KEEPALIVE, true) // 设置为长连接 - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 60*1000); // 设置连接超时时间 - return nettyClient; - } - - public void configureBootstrap(Bootstrap bootstrap) { - List devices = deviceService.list(new LambdaQueryWrapper().eq(IotDeviceEntity::getProtocolType, "TCP")); - for (IotDeviceEntity device : devices) { - bootstrap.handler(new ChannelInitializer() { - @Override - protected void initChannel(SocketChannel ch) { - ch.pipeline().addLast(new StringDecoder(), new StringEncoder(), new SimpleChannelInboundHandler() { - @Override - public void channelActive(ChannelHandlerContext ctx) { - //模拟设备认证 - Map authenticateMap = new HashMap(); - authenticateMap.put("authenticate", device.getId().toString()); - String authenticateMapJson = JsonUtils.toJsonString(authenticateMap); - log.info("------------------------> 发送认证信息到服务端: {}", authenticateMapJson); - ctx.writeAndFlush(authenticateMapJson); - } - - @Override - protected void channelRead0(ChannelHandlerContext ctx, String msg) { - log.info("设备 {} 接收到服务端消息: {}", device.getId(), msg); - //模拟属性上报 - if(msg.contains("authenticate passed")){ - String commandTopic = DeviceTopicEnum.PROPERTY.buildTopic(DeviceClientDTO.from(device)); - - DevicePropertyDTO devicePropertyDTO = new DevicePropertyDTO(); - devicePropertyDTO.setDeviceId(device.getId().toString()); - devicePropertyDTO.setPropertyType(DevicePropertyEnum.RUNNING_STATUS); - devicePropertyDTO.setPayload(String.valueOf(DeviceRunningStatusEnum.ONLINE.getValue())); - - TcpMsgDTO tcpMsgDTO = new TcpMsgDTO(); - tcpMsgDTO.setTopic(commandTopic); - tcpMsgDTO.setMsg(devicePropertyDTO); - - String runningStatusjson = JsonUtils.toJsonString(tcpMsgDTO); - log.info("------------------------> 设备发送上线文本:{}",runningStatusjson); - ctx.writeAndFlush(runningStatusjson); - } - } - }); - } - }); - } - } -} diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientStartupConfig.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientStartupConfig.java deleted file mode 100644 index bcaae48..0000000 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyClientStartupConfig.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.maku.iot.communication.tcp.config; - -import io.netty.bootstrap.Bootstrap; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.ObjectProvider; -import org.springframework.context.ApplicationListener; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.event.ContextRefreshedEvent; - -@Configuration -@Slf4j -public class NettyClientStartupConfig implements ApplicationListener { - - private final ObjectProvider nettyClientProvider; - private final NettyClientConfig nettyClientConfig; - - public NettyClientStartupConfig(ObjectProvider nettyClientProvider, NettyClientConfig nettyClientConfig) { - this.nettyClientProvider = nettyClientProvider; - this.nettyClientConfig = nettyClientConfig; - } - - @Override - public void onApplicationEvent(ContextRefreshedEvent event) { - try { - Thread.sleep(5000); // 延迟5秒以确保服务器启动 - Bootstrap nettyClient = nettyClientProvider.getIfAvailable(); - if (nettyClient != null) { - nettyClientConfig.configureBootstrap(nettyClient); - nettyClient.connect("127.0.0.1", 8888).sync(); - log.info("Connected to Netty server on port 8888"); - } - } catch (InterruptedException e) { - log.error("Failed to connect to Netty server", e); - } - } -} diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyServerConfig.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyServerConfig.java index e190ce9..0add88c 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyServerConfig.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/NettyServerConfig.java @@ -10,9 +10,7 @@ import io.netty.channel.socket.SocketChannel; import io.netty.channel.socket.nio.NioServerSocketChannel; import io.netty.handler.codec.string.StringDecoder; import io.netty.handler.codec.string.StringEncoder; -import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; -import net.maku.iot.communication.mqtt.factory.MqttMessageHandlerFactory; import net.maku.iot.communication.tcp.factory.TcpMessageHandlerFactory; import net.maku.iot.communication.tcp.handler.ConnectionHandler; import org.springframework.beans.factory.annotation.Autowired; @@ -22,7 +20,11 @@ import org.springframework.context.annotation.Configuration; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; - +/** + * Netty服务配置 + * + * @author LSF maku_lsf@163.com + */ @Configuration @Slf4j public class NettyServerConfig { diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/TcpClient.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/TcpClient.java deleted file mode 100644 index 9c3ec6d..0000000 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/config/TcpClient.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.maku.iot.communication.tcp.config; - -import cn.hutool.json.JSONUtil; -import net.maku.iot.communication.dto.DevicePropertyDTO; -import net.maku.iot.communication.dto.TcpMsgDTO; -import net.maku.iot.enums.DevicePropertyEnum; -import net.maku.iot.enums.DeviceTopicEnum; - -import java.io.OutputStream; -import java.io.PrintWriter; -import java.net.Socket; - -public class TcpClient { - public static void main(String[] args) { - String serverAddress = ""; // 服务端的地址 - int port = 8888; // 服务端的端口号 - - try (Socket socket = new Socket(serverAddress, port); - OutputStream outputStream = socket.getOutputStream(); - PrintWriter writer = new PrintWriter(outputStream, true)) { - - DevicePropertyDTO dto = new DevicePropertyDTO(); - dto.setDeviceId("123456"); - dto.setPropertyType(DevicePropertyEnum.TEMPERATURE); - dto.setPayload("60"); - - - TcpMsgDTO tcpMsgDTO = new TcpMsgDTO(); - tcpMsgDTO.setMsg(dto); - tcpMsgDTO.setTopic(DeviceTopicEnum.PROPERTY.getTopic()); - - - writer.println(JSONUtil.toJsonStr(tcpMsgDTO)); // 发送消息到服务端 - - System.out.println("Message sent: " + JSONUtil.toJsonStr(tcpMsgDTO)); - - Thread.sleep(100000); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/ConnectionHandler.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/ConnectionHandler.java index f9be014..344df9d 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/ConnectionHandler.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/ConnectionHandler.java @@ -15,9 +15,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; /** - * @Description TCP服务器连接处理器 - * @Author LSF - * @Date 2024/8/14 16:52 + * TCP服务器连接处理器 + * + * @author LSF maku_lsf@163.com */ @Slf4j public class ConnectionHandler extends ChannelInboundHandlerAdapter { diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DeviceCommandResponseTCPMessageHandler.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DeviceCommandResponseTCPMessageHandler.java index e8e00ef..2ddf1d1 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DeviceCommandResponseTCPMessageHandler.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DeviceCommandResponseTCPMessageHandler.java @@ -13,9 +13,9 @@ import org.springframework.stereotype.Component; import java.util.Optional; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/14 19:23 + * 设备命令响应处理器 + * + * @author LSF maku_lsf@163.com */ @Slf4j @Component @@ -52,9 +52,6 @@ public class DeviceCommandResponseTCPMessageHandler implements TCPMessageHandler log.error(StrUtil.format("调用设备命令响应响应处理器出错,topic:{}, message:{}", topic, message), e); } }); - - - } private DeviceCommandResponseDTO parseCommandReplyMessage(String topic, Object message) { diff --git a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DevicePropertyTCPMessageHandler.java b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DevicePropertyTCPMessageHandler.java index 8d7d048..0307d3a 100644 --- a/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DevicePropertyTCPMessageHandler.java +++ b/maku-boot-module/maku-module-iot/src/main/java/net/maku/iot/communication/tcp/handler/DevicePropertyTCPMessageHandler.java @@ -12,9 +12,9 @@ import org.springframework.stereotype.Component; import java.util.Optional; /** - * @Description TODO - * @Author LSF - * @Date 2024/8/14 19:24 + * 设备属性上报消息处理器 + * + * @author LSF maku_lsf@163.com */ @Slf4j @Component