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

📄 at_wind.java

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

import java.nio.CharBuffer;

import com.jzl.sirius.at.ATConstants;
import com.jzl.sirius.at.util.StringUtils;

/**
 * @author xujian
 * @version 2.0
 * @see com.jzl.sirius.at.ATCommand
 * @see com.jzl.sirius.at.command.ATCommandBase
 */
public class AT_WIND extends ATCommandBase {

	private int commandType;

	private StringBuffer command = new StringBuffer();

	private int indLevel = -1;

	private String supportedIndLevels = "";

	public AT_WIND() {
		this(false);
	}

	public AT_WIND(boolean tested) {
		commandType = tested ? COMMAND_TYPE_TEST : COMMAND_TYPE_READ;

		command.append(tested ? "AT+WIND=?" : "AT+WIND?");
		command.append(ATConstants.CR);
	}

	public AT_WIND(int indLevel) {
		commandType = COMMAND_TYPE_ACTION;

		command.append("AT+WIND=");
		command.append(indLevel);
		command.append(ATConstants.CR);
	}
    
    public String buildCommand() {
        return command.toString();
    }
    
    protected void decodeOkResponse(CharBuffer response) {
        if (commandType == COMMAND_TYPE_READ) {
            String str = StringUtils.substring(response.toString(), "+WIND:", ATConstants.CRLF);
            try {
                indLevel = Integer.parseInt(str.trim());
            }
            catch(Exception ex) {
            }
        } else if (commandType == COMMAND_TYPE_TEST) {
            supportedIndLevels = StringUtils.substring(response.toString(), "+WIND:", ATConstants.CRLF).trim();
        }
    }


	public int getIndLevel() {
		return indLevel;
	}

	public String getSupportedIndLevels() {
		return supportedIndLevels;
	}

}

⌨️ 快捷键说明

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