标题:
单片机与GPRS模块通信的问题
[打印本页]
作者:
会飞的大象
时间:
2019-11-19 15:51
标题:
单片机与GPRS模块通信的问题
单片机通过串口与GPRS模块通信时,模块会将单片机发送的数据返回。应该怎么设置才能不让模块返回接收的数据,只返回应答数据。请大神指教
51hei截图20191119154430.png
(5.58 KB, 下载次数: 48)
下载附件
2019-11-19 15:50 上传
作者:
hange_v
时间:
2019-11-19 19:05
GPRS模块有不让回显的AT指令
作者:
jscsd226
时间:
2019-11-19 19:22
您好,这个你需要在程序里面找到返回的那个指令,然后注释掉就可以了。由于你没贴程序,我暂时也没法找。你自己找找,很快的。
作者:
会飞的大象
时间:
2019-11-20 09:40
谢谢,对AT指令不太理解,关了回显,问题解决了
作者:
stmmcu
时间:
2019-11-20 11:45
关闭指令回显 ATE0
打开指令回显 ATE1
作者:
会飞的大象
时间:
2019-11-22 09:54
有没有指令让模块锁定在2G模式下工作,多链路时为什么场景0发不通,请大神指教
作者:
会飞的大象
时间:
2019-11-24 22:21
为什么老检测SIM卡失败 请大神指教
if(cpin_send_flag==0&&cpin_send_frequ!=0) //判断指令发送标识及发送次数
{
//Clr_Rec_buf();
send_string(cpin); //发送检测SIM卡状态指令
wait_2s=3; //等待时间为3秒
t_1s=0;
timing_2s_end_flag=0;
cpin_send_frequ--;
cpin_send_flag=1;
}
if(cpin_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发出及计时是否结束
{
if(strstr(Rec_buf,"READY")!=NULL) //判断返回数据中是否包含‘READY’字符串
{
sim_ready_flag=1; //SIM卡准备就绪标识值1
cpin_send_frequ=0; //发送次数值0
cpin_send_flag=0; //指令发送标识值0
//Clr_Rec_buf(); //清空缓存区
}
else
{
cpin_send_flag=0;
if(cpin_send_frequ==0) //判断发送是否结束
{
sim_ready_flag=0;
net_connect_flag=0; //如何SIM卡未准备就绪,关闭网络连接
gprs_p=0;
}
//Clr_Rec_buf(); //清空缓存区
}
if(cpin_send_frequ==0) //判断发送是否结束
{
sim_test_end_flag=1; //SIM卡检测结束标识值1
for(i=0;i<24;i++)
str[i]=Rec_buf[i];
for(i=0;i<24;i++)
str1[i]=Rec_buf[24+i];
}
Clr_Rec_buf();
}
作者:
会飞的大象
时间:
2019-11-25 08:16
还有一个问题就是单片机在控制GPRS模块联网时有一条指令不发,其他的都很正常,真是不知道是怎么回事了
if(sim_ready_flag==1&&csq_test_end_falg==0) //判断SIM卡是否准备就绪,信号检测结束标识是否是0
{
if(csq_send_flag==0&&csq_send_frequ!=0) //判断指令发送标识及发送次数
{
send_string(csq); //发送网络信号检测指令
csq_send_frequ--;
csq_send_flag=1;
wait_2s=2;
timing_2s_end_flag=0;
}
if(csq_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发出及计时是否结束
{
if(strstr(Rec_buf,"OK")!=NULL) //判断返回数据中是否包含‘OK’字符串
{
if(Rec_buf[8]=='9'&&Rec_buf[9]=='9') //判断检测的信号强度是否是99
{
if(csq_send_frequ==0) //判断发送是否结束
{
csq_test_flag=0; //信号测试标识值0
net_connect_flag=0; //关闭网络连接
}
}
else
{
csq_test_flag=1; //信号测试标识值1
csq_send_frequ=0;
}
csq_send_flag=0;
sig_strength_num[0]=Rec_buf[8]; //提取信号强度值
sig_strength_num[1]=Rec_buf[9];
Clr_Rec_buf();
}
else //如果返回数据中不包含‘OK’字符串,则检测失败
{
csq_send_flag=0;
if(csq_send_frequ==0) //判断发送是否结束
{
csq_test_flag=0; //信号测试标识值0
net_connect_flag=0; //关闭网络连接
gprs_p=0;
}
Clr_Rec_buf();
}
if(csq_send_frequ==0) //判断发送是否结束
{
csq_test_end_falg=1; //信号检测结束标识值1
sim_ready_flag=0;
}
}
}
/************检测网络注册状态************/
if(csq_test_flag==1&&creg_test_end_flag==0) //判断信号检测是否成功,网络状态测试结束标识是否为0
{
if(creg_send_flag==0&&creg_send_frequ!=0) //判断指令是否发出及发送次数
{
send_string(creg); //发送网络注册状态指令
creg_send_frequ--;
creg_send_flag=1;
wait_2s=2;
timing_2s_end_flag=0;
}
if(creg_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发出及计时是否结束
{
if(strstr(Rec_buf,"OK")!=NULL&&(Rec_buf[11]=='1'||Rec_buf[11]=='5')) //判断返回字符串是否包含‘OK’,网络注册状态是‘1’或‘5’
{
creg_succ_flag=1; //注册成功标识值1
creg_send_frequ=0; //发送次数值0
creg_send_flag=0;
Clr_Rec_buf();
}
else
{
creg_send_flag=0;
if(creg_send_frequ==0) //判断发送是否结束
{
creg_succ_flag=0; //注册成功标识值0
net_connect_flag=0; //关闭连接
gprs_p=0;
}
Clr_Rec_buf();
}
if(creg_send_frequ==0) //判断发送是否结束
{
creg_test_end_flag=1; //网络注册状态测试结束标识值1
//csq_test_flag=0;
}
}
}
/************GPRS附着状态************/
if(creg_succ_flag==1&&cgatt_test_end_falg==0) //判断网络注册是否成功,GPRS附着状态检测结束标识是否为0
{
if(cgatt_send_flag==0&&cgatt_send_frequ!=0) //判断指令是否发送及发送次数
{
//Clr_Rec_buf();
send_string(cgatt); //发送测试指令
cgatt_send_frequ--;
cgatt_send_flag=1;
wait_2s=4;
timing_2s_end_flag=0;
}
if(cgatt_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发出及计时是否结束
{
if(strstr(Rec_buf,"OK")!=NULL&&Rec_buf[10]=='1')
{
cgatt_test_flag=1; //GPRS附着检测标识值1
cgatt_send_frequ=0; //发送次数值0
cgatt_send_flag=0;
Clr_Rec_buf();
}
else
{
cgatt_send_flag=0;
if(cgatt_send_frequ==0) //判断发送是否结束
{
cgatt_test_flag=0; //GPRS附着检测标识值0
net_connect_flag=0; //关闭网络连接
gprs_p=0;
}
Clr_Rec_buf();
}
if(cgatt_send_frequ==0)
{
creg_succ_flag=0;
cgatt_test_end_falg=1; //GPRS附着检测结束标识值1
}
}
}
/************设置APN************/
if(cgatt_test_flag==1&&cstt_set_end_falg==0) //判断GPRS附着检测标识值
{
if(cstt_send_flag==0&&cstt_send_frequ!=0) //判断指令是否发送及发送次数
{
send_string(cstt); //发送设置APN指令
cstt_send_frequ--;
cstt_send_flag=1;
wait_2s=3;
timing_2s_end_flag=0;
;
}
if(cstt_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发送及计时是否结束
{
if(strstr(Rec_buf,"OK")!=NULL) //判断返回字符串是否包含“OK”
{
cstt_set_flag=1; //APN设置标识值1
cstt_send_frequ=0;
cstt_send_flag=0;
Clr_Rec_buf();
}
else
{
cstt_send_flag=0;
if(cstt_send_frequ==0) //判断发送是否结束
{
cstt_set_flag=0; //APN设置标识值0
net_connect_flag=0;
gprs_p=0;
}
Clr_Rec_buf();
}
if(cstt_send_frequ==0)
{
cgatt_test_flag=0; //GPRS附着检测标识值0
cstt_set_end_falg=1;
}
}
}
/*****建立无线链路(GPRS或者CSD)*****/
if(cstt_set_flag==1&&ciicr_set_end_falg==0) //判断APN设置状态标识
{
if(ciicr_send_flag==0&&ciicr_send_frequ!=0) //判断指令是否发送及发送次数
{
send_string(ciicr); //发送建立无线链路指令
ciicr_send_frequ--;
ciicr_send_flag=1;
wait_2s=3;
t_1s=0;
timing_2s_end_flag=0;
}
if(ciicr_send_flag==1&&timing_2s_end_flag==1) //判断指令是否发送及计时是否结束
{
if(strstr(Rec_buf,"OK")!=NULL)
{
ciicr_set_flag=1; //无线链路设置标识值1
ciicr_send_frequ=0;
cstt_set_flag=0; //APN设置状态标识值0
ciicr_set_end_falg=1;
ciicr_send_flag=0;
for(i=0;i<24;i++)
str2[i]=Rec_buf[i];
Clr_Rec_buf();
}
else
{
n++;
if(n<4)
{
wait_2s=3;
t_1s=0;
timing_2s_end_flag=0;
}
if(n==4) //判断发送是否结束
{
ciicr_send_flag=0;
//Clr_Rec_buf();
n=0;
}
if(ciicr_send_frequ==0)
{
ciicr_set_flag=0; //无线链路设置标识值0
cstt_set_flag=0; //APN设置状态标识值0
ciicr_set_end_falg=1;
net_connect_flag=0; //关闭网络连接
gprs_p=0;
}
for(i=0;i<24;i++)
str2[i]=Rec_buf[i];
Clr_Rec_buf();
}
}
}
作者:
会飞的大象
时间:
2019-11-25 08:17
就是ciicr,建立网络连接这条不发,大神帮忙看看是怎么回事
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1