senzhi
2026-03-03 904c59168f06f878052729b137ffcc5da28de7e7
src/main/java/com/eternal/rfid/service/UF3RFIDReader.java
@@ -40,6 +40,7 @@
    private int readerType;
    private int readerLogOn_Off;
    private String mode;
    private boolean isConnect = false;
    @Setter
    private Consumer<ApplicationEvent> eventConsumer;
@@ -66,22 +67,23 @@
    public void start() {
        log.info("ip:{},port:{},readerType:{},log:{}", ip, port, readerType, readerLogOn_Off);
        log.info("ip:{},port:{},readerType:{},log:{}", this.ip, this.port, this.readerType, this.readerLogOn_Off);
        reader = new CReader(ip, port, readerType, readerLogOn_Off);
        int conn = reader.Connect();
        if (conn != 0) {
            log.error("连接UF3设备失败,返回码={}", conn);
            this.isConnect = false;
            return;
        }
        log.info("UF3 Reader设备连接成功:{}:{}", ip, props.getPort());
        this.isConnect = true;
        //0x00关闭蜂鸣器,0x01打开蜂鸣器
        reader.SetBeepNotification(0x00);
        ReaderParameter param = new ReaderParameter();
        try {
            param.SetAntenna(0x09);
            param.SetSession(0);
            param.SetReadType(0);
            reader.SetInventoryParameter(param);
        } catch (Exception e) {
@@ -122,12 +124,13 @@
            } catch (Exception e) {
                log.warn("断开连接异常:{}", e.getMessage());
            }
            this.isConnect = false;
            log.info("已停止并断开UF3设备连接");
        }
    }
    public boolean isOnline() {
        return reader != null;
        return reader != null && isConnect;
    }
    @Override