⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 atcommand.java

📁 自己实现的基于串口通讯发送短消息的低层协议JAVA代码
💻 JAVA
字号:
package com.jzl.sirius.at;

public abstract class ATCommand implements ATResponse {
    public static final int COMMAND_TYPE_READ   = 0;
    public static final int COMMAND_TYPE_TEST   = 1;
    public static final int COMMAND_TYPE_ACTION = 2;
    
    private boolean finished  = false;
    private int resultCode   = -1;
    private int cmeErrorCode = -1;
    private int cmsErrorCode = -1;
    
    private boolean hasCmeErrorCode = false;
    private boolean hasCmsErrorCode = false;
    
    
    protected ATEngine engine;
    
    public abstract String buildCommand();
    
    public void execute(ATEngine engine, long timeout) throws ATException {
        this.engine = engine;
        engine.execute(this, timeout);
    }
    
    public void execute(ATEngine engine) throws ATException {
        this.engine = engine;
        engine.execute(this);
    }

    public boolean isTimeout() {
        return !finished;
    }
    
    public boolean isFinished() {
        return finished;
    }
    
    public void finish() {
        finished = true;
    }

//    public void setTimeout(boolean timeout) {
//        this.timeout = timeout;
//    }

    public int getResultCode() {
        return resultCode;
    }

    protected void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public int getCmeErrorCode() {
        return cmeErrorCode;
    }

    protected void setCmeErrorCode(int cmeErrorCode) {
        this.cmeErrorCode = cmeErrorCode;
        hasCmeErrorCode = true;
    }

    public int getCmsErrorCode() {
        return cmsErrorCode;
    }

    protected void setCmsErrorCode(int cmsErrorCode) {
        this.cmsErrorCode = cmsErrorCode;
        hasCmsErrorCode = true;
    }

    public boolean hasCmeErrorCode() {
        return hasCmeErrorCode;
    }

    public boolean hasCmsErrorCode() {
        return hasCmsErrorCode;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -