📄 at_cgclass.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;
/**
*
* <p>用途:设置移动终端的类别</p>
* <p>用法:</p>
* <p>参照:<br />
* GPRS Mobile Station Class +CGCLASS
* <ul>
* <li>Description</li>
* <ul>
* <li>This command is used to set the MT to operate according to the specified GPRS mobile class.</li>
* </ul>
* <li>Syntax</li>
* <ul>
* <li>Action command</li>
* <ul>
* <li>AT+CGCLASS=<class></li>
* <li>OK</li>
* </ul>
* <li>Read command</li>
* <ul>
* <li>AT+CGCLASS?</li>
* <li>+CGCLASS: <class></li>
* <li>OK</li>
* </ul>
* <li>Test command</li>
* <ul>
* <li>AT+CGCLASS=?</li>
* <li>+CGCLASS: (list of supported <class>s)</li>
* <li>OK</li>
* </ul>
* </ul>
* <li>Parameters and Defined Values</li>
* <ul>
* <li><class>: GPRS mobile class (in descending order of functionality)</li>
* <ul>
* <li>"B" class B</li>
* <li>"CG" class C in GPRS only mode</li>
* <li>"CC" class C in circuit switched only mode (lowest)</li>
* </p>
*
* @author xujian
* @version 2.0
* @see com.jzl.sirius.at.ATCommand
* @see com.jzl.sirius.at.command.ATCommandBase
*
*/
public class AT_CGCLASS extends ATCommandBase {
private int commandType;
private StringBuffer command = new StringBuffer();
private String clazz;
private String supportedClasses;
public AT_CGCLASS() {
this(false);
}
public AT_CGCLASS(boolean tested) {
super(new StringMatch(ATConstants.CRLF + "+CGCLASS:"));
commandType = tested ? COMMAND_TYPE_TEST : COMMAND_TYPE_READ;
command.append(tested ? "AT+CGCLASS=?" : "AT+CGCLASS?");
command.append(ATConstants.CR);
}
public AT_CGCLASS(String clazz) {
commandType = COMMAND_TYPE_ACTION;
command.append("AT+CGCLASS=\"");
command.append(clazz);
command.append("\"");
command.append(ATConstants.CR);
}
public String buildCommand() {
return command.toString();
}
protected void decodeOkResponse(CharBuffer response) {
String str = response.toString();
try {
if (commandType == COMMAND_TYPE_READ) {
// format:<CR><LF>+CGCLASS: <class><CR><LF><CR><LF>OK<CR><LF>
clazz = StringUtils.substring(str, "+CGCLASS:", ATConstants.CRLF).trim();
} else if (commandType == COMMAND_TYPE_TEST) {
// format:<CR><LF>+CGCLASS: (list of supported <class>s)<CR><LF><CR><LF>OK<CR><LF>
supportedClasses = StringUtils.substring(str, "+CGCLASS:", ATConstants.CRLF).trim();
}
}
catch(Exception ex) {
}
}
public String getClazz() {
return clazz;
}
public String getSupportedClasses() {
return supportedClasses;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -