📄 at_speaker.java
字号:
package com.jzl.sirius.at.command;
import java.nio.CharBuffer;
import com.jzl.sirius.at.ATConstants;
import com.jzl.sirius.at.util.StringMatch;
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_SPEAKER extends ATCommandBase {
private int commandType;
private StringBuffer command = new StringBuffer();
private int activeConfig = -1;
private String supportedActiveConfigs = "";
public AT_SPEAKER() {
this(false);
}
public AT_SPEAKER(boolean tested) {
super(new StringMatch(ATConstants.CRLF + "+SPEAKER:"));
commandType = tested ? COMMAND_TYPE_TEST : COMMAND_TYPE_READ;
command.append(tested ? "AT+SPEAKER=?" : "AT+SPEAKER?");
command.append(ATConstants.CR);
}
public AT_SPEAKER(int activeConfig) {
commandType = COMMAND_TYPE_ACTION;
command.append("AT+SPEAKER=");
command.append(activeConfig);
command.append(ATConstants.CR);
}
public String buildCommand() {
return command.toString();
}
protected void decodeOkResponse(CharBuffer response) {
if (commandType == COMMAND_TYPE_READ) {
String activeConfigStr = StringUtils.substring(response.toString(), "+SPEAKER:", ATConstants.CRLF);
try {
activeConfig = Integer.parseInt(activeConfigStr.trim());
}
catch(Exception ex) {
}
}
else if (commandType == COMMAND_TYPE_TEST) {
supportedActiveConfigs = StringUtils.substring(response.toString(), "+SPEAKER:", ATConstants.CRLF).trim();
}
}
public int getActiveConfig() {
return activeConfig;
}
public String getSupportedActiveConfigs() {
return supportedActiveConfigs;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -