![]() |
發布時間: 2019-11-19 15:51
正文摘要:單片機通過串口與GPRS模塊通信時,模塊會將單片機發送的數據返回。應該怎么設置才能不讓模塊返回接收的數據,只返回應答數據。請大神指教 |
就是ciicr,建立網絡連接這條不發,大神幫忙看看是怎么回事 |
還有一個問題就是單片機在控制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(); } } } |
為什么老檢測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(); } |
有沒有指令讓模塊鎖定在2G模式下工作,多鏈路時為什么場景0發不通,請大神指教 |
關閉指令回顯 ATE0 打開指令回顯 ATE1 |
謝謝,對AT指令不太理解,關了回顯,問題解決了 |
您好,這個你需要在程序里面找到返回的那個指令,然后注釋掉就可以了。由于你沒貼程序,我暫時也沒法找。你自己找找,很快的。 |
GPRS模塊有不讓回顯的AT指令 |