EC20TCPIPAT指令(安卓串口通信开发)

更新时间:2023-07-13 03:15:22 阅读: 评论:0

EC20TCPIPAT指令(安卓串⼝通信开发)指令过程
1.等待串⼝接收字符串"RDY"模块系统启动成功。
2.发送"AT+CPIN?\r",等待"+CPIN: READY",SIM准备就绪。
3.发送" AT+CSQ\r",等待"+CSQ: 25",⽹络信号值要⼤于10通信才稳定。
4.发送" AT+CREG?\r",等待" +CREG: 0,1",⽹络注册成功后才能上⽹。
5.发送"AT+QIACT=1\r",等待" ok",激活移动场景。
6. AT+QIACT?\r",等待"+QIACT:1,1,1,",是否获取到了IP地址如:“+QIACT: 1,1,1,"10.189.40.187"”。
7.发送" AT+QWWAN=1",等待" OK",启⽤有线⽹络。
/安卓代码过程/
//接收信息
String receivedMsg =HexString(bytes);
String receivedString =StringUtils.hexStringToString(receivedMsg);
ains("RDY")){
//查询SIM卡是否正常,返回ready则表⽰SIM卡正常
Message msg =new Message();
msg.obj ="RDY==模块系统启动成功";
msg.what=0;
myHandler.ndMessage(msg);
mreceivedMsg="RDY";
String ndMsg =vertStringToHex("AT+CPIN?");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
}el ains("CPIN: READY")){
ains("OK")){
//成功,下⼀步发送AT+CSQ检测信号
Message msg =new Message();
msg.obj ="CPIN: READY==SIM准备就绪";
msg.what=0;
myHandler.ndMessage(msg);
Log.d(TAG,"onDataReceived: SIM准备就绪");
String ndMsg =vertStringToHex("AT+CSQ");贪吃的小狗
byte[] ndBytes =ByteArray(ndMsg);
晚上泡妞
mSerialPortManager.ndBytes(ndBytes);
mreceivedMsg="CPIN: READY";
}el{
//失败,需要重新发送
String ndMsg =vertStringToHex("AT+CPIN?");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
}
}
el ains("CSQ")){
ains("OK")){
String  numStr="99";
String regex ="\\d*";
Pattern p = pile(regex);
Matcher m = p.placeAll("\n",""));
while(m.find()){
if(!"".up())){
up();
break;
}}
int num=Integer.parInt(numStr);
//检测信号在11~31之间则发送AT+CREG? 等待CREG: 0,1
if(num>10&&num<32){
Message msg =new Message();
msg.obj ="⽹络信号值"+receivedString;
msg.obj ="⽹络信号值"+receivedString;
msg.what=0;
myHandler.ndMessage(msg);
String ndMsg =vertStringToHex("AT+CREG?");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);辅料采购
mreceivedMsg=receivedString;
}el{
Message msg =new Message();
msg.obj ="AT+CSQ值==="+numStr;
msg.what=0;
myHandler.ndMessage(msg);
String ndMsg =vertStringToHex("AT+CSQ");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
}
}el{
String ndMsg =vertStringToHex("AT+CSQ");
品三国byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
}
}
el ains("CREG")){
ains("OK")&&ains("CREG: 0,1")){
// 收到 CREG: 0,1,则⽹络注册成功发送AT+QIACT=1 激活移动场景
Message msg =new Message();
msg.obj ="⽹络注册成功:"+receivedString;
msg.what=0;
myHandler.ndMessage(msg);
String ndMsg =vertStringToHex("AT+QIACT=1");
byte[] ndBytes =ByteArray(ndMsg);
六年级体育教案mSerialPortManager.ndBytes(ndBytes);
mreceivedMsg=receivedString;
mreceivedMsg="CREG";
}el{
String ndMsg =vertStringToHex("AT+CREG?");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
mreceivedMsg=receivedString;
}
}
el ains("AT+QIACT=1")){
mreceivedMsg="AT+QIACT=1";
}
el ains("AT+QIACT?")){
//是否获取到了IP地址如:“+QIACT: 1,1,1,"10.189.40.187"”
ains("OK")&&ains("QIACT: 1,1,1,")){                        Message msg =new Message();
msg.obj ="获取到了IP地址"+receivedString;
msg.what=0;
myHandler.ndMessage(msg);
String ndMsg =vertStringToHex("AT+QWWAN=1");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
mreceivedMsg="AT+QIACT?";
}el{
try{
Thread.sleep(100);
}catch(InterruptedException e){
e.printStackTrace();
}
String ndMsg =vertStringToHex("AT+QIACT?");
byte[] ndBytes =ByteArray(ndMsg);
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
}
}
el ains("AT+QWWAN=1")){
mreceivedMsg="AT+QWWAN=1";
}el ains("POWERED DOWN")){
mreceivedMsg="POWERED DOWN";
tvInfo="============开始==================";
Message msg =new Message();
msg.obj ="关闭电源:===="+receivedString;
msg.what=0;
myHandler.ndMessage(msg);
}
el ains("PB DONE")){
//结束通信
Message msg =new Message();
msg.obj ="PB DONE";
番茄红素的作用msg.what=0;
myHandler.ndMessage(msg);
}
甘油是什么油el{
ains("AT+QIACT=1")&&ains("OK")){
//激活移动场景
深刻检讨
Message msg =new Message();
msg.obj ="AT+QIACT=1";
msg.what=0;
myHandler.ndMessage(msg);
String ndMsg =vertStringToHex("AT+QIACT?");
byte[] ndBytes =ByteArray(ndMsg);
mSerialPortManager.ndBytes(ndBytes);
mreceivedMsg="AT+QIACT?";
}
ains("AT+QWWAN=1")&&ains("OK")){                        Log.d(TAG,"onDataReceived: ================QWWAN");
//启⽤有线⽹络。
Message msg =new Message();
msg.obj ="OK==启⽤4g⽹络成功";
msg.what=0;
myHandler.ndMessage(msg);
Log.d(TAG,"onDataReceived:启⽤有线⽹络。");
mreceivedMsg="OK";
}
}

本文发布于:2023-07-13 03:15:22,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1079329.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:是否   发送   过程   接收   字符串   信号   检测   获取
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图