From e4270b51b8a4940e60041605cfd5abc86247abec Mon Sep 17 00:00:00 2001 From: HuangXin Date: Mon, 14 Aug 2023 20:48:18 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E6=8E=A7=E5=88=B6=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=B0=83=E8=AF=95=E6=8E=A5=E5=8F=A3=202.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E5=99=A8=E6=8E=A7=E5=88=B6=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=8D=8F=E8=AE=AE=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application-local.properties | 2 +- config/application-user.properties | 1 + config/logback.xml | 4 +- .../adapter/impl/netty/ChannelInit.java | 15 +- .../netty/decode/YuanRongProtocolDecode.java | 137 +++++++++++------- .../common/impl/BeidouStatusName.java | 40 +++++ .../common/impl/SendStatusName.java | 41 ++++++ .../common/impl/TelphoneStatusName.java | 40 +++++ .../common/impl/WirelessStatusName.java | 40 +++++ .../config/NettySocketConfigure.java | 2 + .../beidouservice/controller/AuthUser.java | 91 +++++++----- .../pojo/vo/ControlAdapterSocketCtx.java | 2 +- .../pojo/vo/binary/SensorCotrolAck.java | 19 +++ .../impl/BaidouSocketAdapterServiceImpl.java | 15 +- 14 files changed, 346 insertions(+), 103 deletions(-) create mode 100644 src/main/java/com/zjyr/beidouservice/common/impl/BeidouStatusName.java create mode 100644 src/main/java/com/zjyr/beidouservice/common/impl/SendStatusName.java create mode 100644 src/main/java/com/zjyr/beidouservice/common/impl/TelphoneStatusName.java create mode 100644 src/main/java/com/zjyr/beidouservice/common/impl/WirelessStatusName.java create mode 100644 src/main/java/com/zjyr/beidouservice/pojo/vo/binary/SensorCotrolAck.java diff --git a/config/application-local.properties b/config/application-local.properties index b018519..be39675 100644 --- a/config/application-local.properties +++ b/config/application-local.properties @@ -31,4 +31,4 @@ mybatis.configuration.default-enum-type-handler=com.zjyr.beidouservice.common.Co #mybatis.configuration.log-impl=lombok.extern.slf4j.Slf4j #config log logging.config=file:config/logback.xml -log4j.logger.org.mybatis=debug \ No newline at end of file +#log4j.logger.org.mybatis=debug \ No newline at end of file diff --git a/config/application-user.properties b/config/application-user.properties index 802bc3f..c5eb6b9 100644 --- a/config/application-user.properties +++ b/config/application-user.properties @@ -1,3 +1,4 @@ socket.server-host=localhost socket.server-port=10000 socket.server-mode=tcp +socket.heart-timeout=60 diff --git a/config/logback.xml b/config/logback.xml index 64a24bd..9312957 100644 --- a/config/logback.xml +++ b/config/logback.xml @@ -4,8 +4,6 @@ - - @@ -48,7 +46,7 @@ - + diff --git a/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/ChannelInit.java b/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/ChannelInit.java index 4a4b2a5..a0ba98c 100644 --- a/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/ChannelInit.java +++ b/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/ChannelInit.java @@ -3,6 +3,7 @@ package com.zjyr.beidouservice.adapter.impl.netty; import com.zjyr.beidouservice.adapter.impl.netty.decode.YuanRongProtocolDecode; import com.zjyr.beidouservice.adapter.impl.netty.encode.ProtocolStartEncode; import com.zjyr.beidouservice.adapter.impl.netty.encode.YuanRongProtocolEncode; +import com.zjyr.beidouservice.config.NettySocketConfigure; import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol; import io.netty.channel.ChannelInitializer; import io.netty.channel.socket.SocketChannel; @@ -53,19 +54,21 @@ public class ChannelInit extends ChannelInitializer { @Resource private MessageHandler messageHandler; + @Resource + private NettySocketConfigure nettySocketConfigure; + @Override protected void initChannel(SocketChannel channel) { channel.pipeline() - .addLast("idle", new IdleStateHandler(0, 0, 60, TimeUnit.SECONDS)) - .addLast("decode", - new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH, + .addLast(new IdleStateHandler(0, 0, nettySocketConfigure.getHeartTimeout(), TimeUnit.SECONDS)) + .addLast(new LengthFieldBasedFrameDecoder(MAX_FRAME_LENGTH, LENGTH_FIELD_OFFSET, LENGTH_FIELD_LENGTH, LENGTH_ADJUSTMENT, INITIAL_BYTES_TO_STRIP)) - .addLast("decodeProtocol", new YuanRongProtocolDecode()) - .addLast("startFlag", new ProtocolStartEncode(2)) - .addLast("encode", new YuanRongProtocolEncode()) + .addLast(new YuanRongProtocolDecode()) + .addLast(new ProtocolStartEncode(2)) + .addLast(new YuanRongProtocolEncode()) .addLast("message", messageHandler); } } diff --git a/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/decode/YuanRongProtocolDecode.java b/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/decode/YuanRongProtocolDecode.java index 113f317..5e9287e 100644 --- a/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/decode/YuanRongProtocolDecode.java +++ b/src/main/java/com/zjyr/beidouservice/adapter/impl/netty/decode/YuanRongProtocolDecode.java @@ -1,11 +1,16 @@ package com.zjyr.beidouservice.adapter.impl.netty.decode; import com.zjyr.beidouservice.common.CommonEnumHandler; +import com.zjyr.beidouservice.common.impl.BeidouStatusName; import com.zjyr.beidouservice.common.impl.ControlCommandName; +import com.zjyr.beidouservice.common.impl.SendStatusName; import com.zjyr.beidouservice.common.impl.SensorStatusName; +import com.zjyr.beidouservice.common.impl.TelphoneStatusName; +import com.zjyr.beidouservice.common.impl.WirelessStatusName; import com.zjyr.beidouservice.pojo.vo.binary.BaseBinaryProtocol; import com.zjyr.beidouservice.pojo.vo.binary.ControllerStatus; import com.zjyr.beidouservice.pojo.vo.binary.MessageContent; +import com.zjyr.beidouservice.pojo.vo.binary.SensorCotrolAck; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.channel.ChannelHandlerContext; @@ -24,61 +29,95 @@ import java.util.List; @Slf4j public class YuanRongProtocolDecode extends ByteToMessageDecoder { @Override - protected void decode(ChannelHandlerContext channelHandlerContext, - ByteBuf buf, - List list) throws Exception { + protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf buf, List list) { log.info("\n{}", ByteBufUtil.prettyHexDump(buf)); - short msgLength = buf.readShort(); - byte version = buf.readByte(); - int recvMajorId = buf.readInt(); - int recvMinorId = buf.readInt(); - int sendMajorId = buf.readInt(); - int sendMinorId = buf.readInt(); - byte cryptCytp = buf.readByte(); - int timeStamp = buf.readInt(); - int statusCode = buf.readInt(); - byte msgType = buf.readByte(); - short msgSize = buf.readShort(); + try { + short msgLength = buf.readShort(); + byte version = buf.readByte(); + int recvMajorId = buf.readInt(); + int recvMinorId = buf.readInt(); + int sendMajorId = buf.readInt(); + int sendMinorId = buf.readInt(); + byte cryptCytp = buf.readByte(); + int timeStamp = buf.readInt(); + int statusCode = buf.readInt(); + byte msgType = buf.readByte(); + short msgSize = buf.readShort(); - ControlCommandName cmd = CommonEnumHandler.codeOf(ControlCommandName.class, msgType); - if (cmd != null) { - switch (cmd) { - case COMMAND_REPORT_HEART -> { - byte[] beidouSignal = new byte[10]; - buf.readBytes(beidouSignal, 0, 10); - SensorStatusName wireStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte()); - SensorStatusName phoneStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte()); + ControlCommandName cmd = CommonEnumHandler.codeOf(ControlCommandName.class, msgType); + if (cmd != null) { + switch (cmd) { + case COMMAND_REPORT_HEART -> { + byte[] beidouSignal = new byte[10]; + buf.readBytes(beidouSignal, 0, 10); + SensorStatusName wireStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte()); + SensorStatusName phoneStatus = CommonEnumHandler.codeOf(SensorStatusName.class, buf.readByte()); - ControllerStatus status = ControllerStatus.builder() - .beidouSignalStrength(beidouSignal) - .wirelessStatus(wireStatus) - .telphoneStatus(phoneStatus) - .build(); - MessageContent msgCtx = MessageContent.builder() - .msgType(msgType) - .msgSize(msgSize) - .msgBody(status) - .build(); + ControllerStatus status = ControllerStatus.builder() + .beidouSignalStrength(beidouSignal) + .wirelessStatus(wireStatus) + .telphoneStatus(phoneStatus) + .build(); + MessageContent msgCtx = MessageContent.builder().msgType( + msgType).msgSize(msgSize).msgBody(status).build(); - list.add(BaseBinaryProtocol.builder() - .msgLength(msgLength) - .version(version) - .recvMajorId(recvMajorId) - .recvMinorId(recvMinorId) - .sendMajorId(sendMajorId) - .sendMinorId(sendMinorId) - .cryptoType(cryptCytp) - .timeStamp(timeStamp) - .statusCode(statusCode) - .msgContent(msgCtx) - .build()); + list.add(BaseBinaryProtocol.builder() + .msgLength(msgLength) + .version(version) + .recvMajorId(recvMajorId) + .recvMinorId(recvMinorId) + .sendMajorId(sendMajorId) + .sendMinorId(sendMinorId) + .cryptoType(cryptCytp) + .timeStamp(timeStamp) + .statusCode(statusCode) + .msgContent(msgCtx) + .build()); + } + case COMMAND_REPORT_SENSOR -> { + SendStatusName sendStatus = CommonEnumHandler.codeOf(SendStatusName.class, buf.readByte()); + BeidouStatusName beidouStatus = CommonEnumHandler.codeOf(BeidouStatusName.class, + buf.readByte()); + WirelessStatusName wireStatus = CommonEnumHandler.codeOf(WirelessStatusName.class, + buf.readByte()); + TelphoneStatusName phoneStatus = CommonEnumHandler.codeOf(TelphoneStatusName.class, + buf.readByte()); + byte[] beidouSignle = new byte[3]; + buf.readBytes(beidouSignle, 0, 3); + + SensorCotrolAck ack = SensorCotrolAck.builder() + .sendStatus(sendStatus) + .beidouStatus(beidouStatus) + .wirelessStatus(wireStatus) + .telphoneStatus(phoneStatus) + .beidouFreq(beidouSignle) + .build(); + + MessageContent msgCtx = MessageContent.builder().msgType( + msgType).msgSize(msgSize).msgBody(ack).build(); + list.add(BaseBinaryProtocol.builder() + .msgLength(msgLength) + .version(version) + .recvMajorId(recvMajorId) + .recvMinorId(recvMinorId) + .sendMajorId(sendMajorId) + .sendMinorId(sendMinorId) + .cryptoType(cryptCytp) + .timeStamp(timeStamp) + .statusCode(statusCode) + .msgContent(msgCtx) + .build()); + } + case COMMAND_REPORT_QUERY_SENSOR -> { + } + default -> log.error("Unsupport Command: {}({})", cmd, msgType); } - case COMMAND_REPORT_SENSOR -> { - } - case COMMAND_REPORT_QUERY_SENSOR -> { - } - default -> log.error("Unsupport Command: {}({})", cmd, msgType); } + } catch (Exception ex) { + log.error("Clear buffer because error data"); + buf.resetReaderIndex(); + buf.resetWriterIndex(); } + } } diff --git a/src/main/java/com/zjyr/beidouservice/common/impl/BeidouStatusName.java b/src/main/java/com/zjyr/beidouservice/common/impl/BeidouStatusName.java new file mode 100644 index 0000000..850305a --- /dev/null +++ b/src/main/java/com/zjyr/beidouservice/common/impl/BeidouStatusName.java @@ -0,0 +1,40 @@ +package com.zjyr.beidouservice.common.impl; + +import com.zjyr.beidouservice.common.EnumerationBase; + +public enum BeidouStatusName implements EnumerationBase { + BEIDOU_NORMAL(0, "BEIDOU_NORMAL"), + BEIDOU_MODULE_EXCEPTION(1, "BEIDOU_MODULE_EXCEPTION"), + BEIDOU_SATELLITE_EXCEPTION(2, "BEIDOU_SATELLITE_EXCEPTION"), + ; + + /** + * The Code. + */ + private final Integer code; + /** + * The Desc. + */ + private final String desc; + + /** + * Instantiates a new Beidou adapter type name. + * + * @param val the val + * @param desc the desc + */ + BeidouStatusName(int val, String desc) { + this.code = val; + this.desc = desc; + } + + @Override + public Integer getValue() { + return this.code; + } + + @Override + public String getDescription() { + return this.desc; + } +} diff --git a/src/main/java/com/zjyr/beidouservice/common/impl/SendStatusName.java b/src/main/java/com/zjyr/beidouservice/common/impl/SendStatusName.java new file mode 100644 index 0000000..274df6b --- /dev/null +++ b/src/main/java/com/zjyr/beidouservice/common/impl/SendStatusName.java @@ -0,0 +1,41 @@ +package com.zjyr.beidouservice.common.impl; + +import com.zjyr.beidouservice.common.EnumerationBase; + +public enum SendStatusName implements EnumerationBase { + SEND_SUCCESS(0, "SEND_SUCCESS"), + SEND_WAIT_IDLE(1, "SEND_WAIT_IDLE"), + SEND_DEVICE_UNEXISTS(2, "SEND_DEVICE_UNEXISTS"), + SEND_CONTROL_LOCKED(3, "SEND_CONTROL_LOCKED"), + ; + + /** + * The Code. + */ + private final Integer code; + /** + * The Desc. + */ + private final String desc; + + /** + * Instantiates a new Beidou adapter type name. + * + * @param val the val + * @param desc the desc + */ + SendStatusName(int val, String desc) { + this.code = val; + this.desc = desc; + } + + @Override + public Integer getValue() { + return this.code; + } + + @Override + public String getDescription() { + return this.desc; + } +} diff --git a/src/main/java/com/zjyr/beidouservice/common/impl/TelphoneStatusName.java b/src/main/java/com/zjyr/beidouservice/common/impl/TelphoneStatusName.java new file mode 100644 index 0000000..0fb5f17 --- /dev/null +++ b/src/main/java/com/zjyr/beidouservice/common/impl/TelphoneStatusName.java @@ -0,0 +1,40 @@ +package com.zjyr.beidouservice.common.impl; + +import com.zjyr.beidouservice.common.EnumerationBase; + +public enum TelphoneStatusName implements EnumerationBase { + TELPHONE_NORMAL(0, "TELPHONE_NORMAL"), + TELPHONE_NOT_DETECTION(1, "TELPHONE_NOT_DETECTION"), + TELPHONE_BREAKDOWN(2, "TELPHONE_BREAKDOWN"), + ; + + /** + * The Code. + */ + private final Integer code; + /** + * The Desc. + */ + private final String desc; + + /** + * Instantiates a new Beidou adapter type name. + * + * @param val the val + * @param desc the desc + */ + TelphoneStatusName(int val, String desc) { + this.code = val; + this.desc = desc; + } + + @Override + public Integer getValue() { + return this.code; + } + + @Override + public String getDescription() { + return this.desc; + } +} diff --git a/src/main/java/com/zjyr/beidouservice/common/impl/WirelessStatusName.java b/src/main/java/com/zjyr/beidouservice/common/impl/WirelessStatusName.java new file mode 100644 index 0000000..3db9a55 --- /dev/null +++ b/src/main/java/com/zjyr/beidouservice/common/impl/WirelessStatusName.java @@ -0,0 +1,40 @@ +package com.zjyr.beidouservice.common.impl; + +import com.zjyr.beidouservice.common.EnumerationBase; + +public enum WirelessStatusName implements EnumerationBase { + + WIRELESS_NORMAL(0, "WIRELESS_NORMAL"), + WIRELESS_BREAKDOWN(0, "WIRELESS_BREAKDOWN"), + ; + + /** + * The Code. + */ + private final Integer code; + /** + * The Desc. + */ + private final String desc; + + /** + * Instantiates a new Beidou adapter type name. + * + * @param val the val + * @param desc the desc + */ + WirelessStatusName(int val, String desc) { + this.code = val; + this.desc = desc; + } + + @Override + public Integer getValue() { + return this.code; + } + + @Override + public String getDescription() { + return this.desc; + } +} diff --git a/src/main/java/com/zjyr/beidouservice/config/NettySocketConfigure.java b/src/main/java/com/zjyr/beidouservice/config/NettySocketConfigure.java index 2eb5f9d..2eb4728 100644 --- a/src/main/java/com/zjyr/beidouservice/config/NettySocketConfigure.java +++ b/src/main/java/com/zjyr/beidouservice/config/NettySocketConfigure.java @@ -27,6 +27,8 @@ public class NettySocketConfigure { */ private String serverMode; + private Integer heartTimeout; + /** * Init global value. */ diff --git a/src/main/java/com/zjyr/beidouservice/controller/AuthUser.java b/src/main/java/com/zjyr/beidouservice/controller/AuthUser.java index f72462c..0913de2 100644 --- a/src/main/java/com/zjyr/beidouservice/controller/AuthUser.java +++ b/src/main/java/com/zjyr/beidouservice/controller/AuthUser.java @@ -1,11 +1,26 @@ package com.zjyr.beidouservice.controller; +import com.zjyr.beidouservice.common.impl.SensorControlActionName; +import com.zjyr.beidouservice.common.impl.SensorControlModeName; +import com.zjyr.beidouservice.common.impl.SensorControlTunnelName; import com.zjyr.beidouservice.pojo.dto.BaseProtocolDTO; import com.zjyr.beidouservice.pojo.dto.GetUserConfig; +import com.zjyr.beidouservice.pojo.po.BeidouAdapterControlContent; +import com.zjyr.beidouservice.pojo.vo.binary.SensorControlProtocol; +import com.zjyr.beidouservice.service.AdapterProtocolService; +import com.zjyr.beidouservice.service.BaidouAdapterService; +import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.ResponseBody; + +import java.util.ArrayList; +import java.util.List; /** * The type Auth user. @@ -14,6 +29,12 @@ import org.springframework.web.bind.annotation.*; //@RequestMapping(value = "/auth") @Slf4j public class AuthUser { + @Resource + BaidouAdapterService baidouAdapterService; + + @Resource + AdapterProtocolService adapterProtocolService; + /** * Third string. * @@ -35,46 +56,38 @@ public class AuthUser { * @param headers the headers * @return the user config */ - @PostMapping("/getuserconfig") + @PostMapping("/sensor/control") @ResponseBody public String getUserConfig(@RequestBody BaseProtocolDTO mr, @RequestHeader HttpHeaders headers) { - return """ - { - "ver": 1, - "cryptoType": 0, - "timeStamp": 1688954003, - "code": 0, - "msgContent": { - "scgCtrlAppId": 7, - "scgTunnelAppId": 8, - "cliPrivateKey": "WGAlqvys3O83VmWug6Z8NzUrxGr/PNHSeOVFnKLSe2k=", - "cliPublicKey": "6BWnmkCJqJC5iNoCEZWTxwGNG7qwkxFoVgAk4DoIKCk=", - "cliAddress": "10.10.10.1/32", - "vmConfig": [ - { - "vmId": 1, - "vmName": "Windows10_1", - "svrPublicKey": "8KEaqtWM5U35SR8S3QJriGHPr0VIqvk8A7BEuOjjp1M=", - "vmNetwork": "10.0.4.16/30", - "scgGateway": "101.35.234.160:10010" - }, - { - "vmId": 2, - "vmName": "Windows10_2", - "svrPublicKey": "q3ep8hN2v3VpHbcru+rTmvyBt13iH0DkEsVAyT2LpVo=", - "vmNetwork": "192.168.100.210/24", - "scgGateway": "efc.xajhuang.com:10000" - }, - { - "vmId": 3, - "vmName": "Windows10_3", - "svrPublicKey": "q3ep8hN2v3VpHbcru+rTmvyBt13iH0DkEsVAyT2LpVo=", - "vmNetwork": "172.18.2.152/26", - "scgGateway": "localhost:10000" - } - ] - } - }"""; + List adapterInfo = new ArrayList<>(); + + for (int i = 0; i < 2; i++) { + adapterInfo.add(BeidouAdapterControlContent.builder() + .districtsCode(0x10 + i) + .sensorId(0x3f00 + i) + .controlAction(SensorControlActionName.ACTION_DISTRICTS_BASED) + .build()); + } + + SensorControlProtocol sp = + adapterProtocolService.createSensorControlProtocol(SensorControlTunnelName.TUNNEL_BEIDOU, + new byte[]{0x01, 0x02, 0x03}, + 8, + 14, + 20, + 35, + 3, + 5, + SensorControlModeName.CONTROL_TYPE_QUIET, + 0, + adapterProtocolService.createSensorCtrlInfo( + adapterInfo)); + Long id = baidouAdapterService.getAllAdapter().get(0).getId(); + if (id != null) { + baidouAdapterService.sendCommond(id, sp); + } + + return "{\"result\": 0}"; } /** diff --git a/src/main/java/com/zjyr/beidouservice/pojo/vo/ControlAdapterSocketCtx.java b/src/main/java/com/zjyr/beidouservice/pojo/vo/ControlAdapterSocketCtx.java index c0555f1..717c78d 100644 --- a/src/main/java/com/zjyr/beidouservice/pojo/vo/ControlAdapterSocketCtx.java +++ b/src/main/java/com/zjyr/beidouservice/pojo/vo/ControlAdapterSocketCtx.java @@ -23,6 +23,6 @@ public class ControlAdapterSocketCtx { public ControlAdapterSocketCtx(Long id, Channel ch) { this.controlAdapterId = id; - this.channel = ch; + this.channel = ch; } } diff --git a/src/main/java/com/zjyr/beidouservice/pojo/vo/binary/SensorCotrolAck.java b/src/main/java/com/zjyr/beidouservice/pojo/vo/binary/SensorCotrolAck.java new file mode 100644 index 0000000..ab85273 --- /dev/null +++ b/src/main/java/com/zjyr/beidouservice/pojo/vo/binary/SensorCotrolAck.java @@ -0,0 +1,19 @@ +package com.zjyr.beidouservice.pojo.vo.binary; + +import com.zjyr.beidouservice.common.impl.BeidouStatusName; +import com.zjyr.beidouservice.common.impl.SendStatusName; +import com.zjyr.beidouservice.common.impl.TelphoneStatusName; +import com.zjyr.beidouservice.common.impl.WirelessStatusName; +import lombok.Builder; +import lombok.Data; + +@Data +@Builder +public class SensorCotrolAck { + private byte[] beidouFreq; + + private SendStatusName sendStatus; + private BeidouStatusName beidouStatus; + private WirelessStatusName wirelessStatus; + private TelphoneStatusName telphoneStatus; +} diff --git a/src/main/java/com/zjyr/beidouservice/service/impl/BaidouSocketAdapterServiceImpl.java b/src/main/java/com/zjyr/beidouservice/service/impl/BaidouSocketAdapterServiceImpl.java index 7282f7b..760e0b8 100644 --- a/src/main/java/com/zjyr/beidouservice/service/impl/BaidouSocketAdapterServiceImpl.java +++ b/src/main/java/com/zjyr/beidouservice/service/impl/BaidouSocketAdapterServiceImpl.java @@ -9,7 +9,7 @@ import com.zjyr.beidouservice.pojo.entry.ControlDevice; import com.zjyr.beidouservice.pojo.po.BeidouAdapterDevice; import com.zjyr.beidouservice.pojo.vo.ControlAdapterSocketCtx; import com.zjyr.beidouservice.pojo.vo.binary.ControllerStatus; -import com.zjyr.beidouservice.pojo.vo.binary.HeartProtocol; +import com.zjyr.beidouservice.pojo.vo.binary.SensorCotrolAck; import com.zjyr.beidouservice.service.AdapterProtocolService; import com.zjyr.beidouservice.service.BaidouAdapterService; import io.netty.channel.Channel; @@ -59,9 +59,9 @@ public class BaidouSocketAdapterServiceImpl implemen @Override public void sendCommond(Channel ch, Object command) { - if (command instanceof HeartProtocol heart) { - tcpServer.sendData(ch, adapterProtocolService.createTransmissionProtocol(heart)); - } + //if (command instanceof HeartProtocol heart) { + tcpServer.sendData(ch, adapterProtocolService.createTransmissionProtocol(command)); + //} } @Override @@ -99,6 +99,13 @@ public class BaidouSocketAdapterServiceImpl implemen status.getWirelessStatus(), status.getTelphoneStatus(), HelperUtils.bytesToHexString(status.getBeidouSignalStrength())); + } else if (event.getEvtMessage() instanceof SensorCotrolAck ack) { + log.info("+++{}, {}, {}, {}, {}", + ack.getSendStatus(), + ack.getBeidouStatus(), + ack.getWirelessStatus(), + ack.getTelphoneStatus(), + HelperUtils.bytesToHexString(ack.getBeidouFreq())); } } }