GSM SM5100B C M E E R RØR:4错误 [英] GSM SM5100B C M E E R R O R : 4 error

查看:219
本文介绍了GSM SM5100B C M E E R RØR:4错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Arduino来控制SM5100B GSM设备

,一切正常,除非我想接收另一之后发送短信。我得到这个,

错误code:


  

0 K> + C M的s:2 5 O K + C M E E R RØR:4


我的code处理上述收到的短信:

 的#include< SoftwareSerial.h> //附上NewSoftSerial库串行命令发送到蜂窝模块。
        焦炭INCHAR; //保存从串口输入字符。
        SoftwareSerial细胞(2,3);
        char的移动电话号码[] =0597010129;
        无效设置(){
        // GSM
        Serial.begin(9600); //打开串口,设置数据传输速率为9600 bps
        Serial.println(初始化GSM模块的串行端口进行通信。);
        cell.begin(9600);
        延迟(35000); //给时间GSM模块和网络上的登记等
        Serial.println(延时关机);
        cell.pr​​intln(AT + CMGF = 1); //设置短信模式为文本
        延迟(200);
        cell.pr​​intln(AT + CNMI = 3,3,0,0); //设置模块在收到短信数据发送到串行输出
        延迟(200);
        }        空隙环(){         如果(cell.available()&0)//如果一字符进来,从蜂窝模块
         {
         INCHAR = cell.read();
         Serial.println(INCHAR);
         如果(INCHAR =='#'){// OK - 我们的命令开始           延迟(10);
           INCHAR = cell.read();
           Serial.println(INCHAR);             如果(INCHAR =='一'){               延迟(10);
               Serial.println(以下简称SMS如下因素:\\ n);
               INCHAR = cell.read();
               Serial.println(INCHAR);               如果(INCHAR =='0'){// sequance =#A0                 Serial.println(#A0被接收);             }
             否则如果(INCHAR =='1'){// sequance =#A1                Serial.println(#A1被接收);
                sendSms();             }
         }
         cell.pr​​intln(AT + CMGD = 1,4); // AT命令来删除所有信息
         Serial.println(删除所有SMS);
          }
        } //结束如果(cell.available()大于0){...}
        }        无效sendSms(){
        //cell.pr​​intln(\"AT+CMGF=1); //设置短信模式为文本
        cell.pr​​int(AT + CMGS =); //现在发送短信...
        cell.pr​​int((char)的34); // ASCII相当于
        cell.pr​​int(移动电话号码);
        cell.pr​​intln((char)的34); // ASCII相当于
        延迟(500); //给模块的一些思考的时间
        cell.pr​​int(:D你好m3alleg:D); //我们的信息发送
        cell.pr​​intln((char)的26); // ASCII相当于按Ctrl-Z的
        延迟(20000);
}


解决方案

一般人您在处理音符命令。

不,不,不!这样做的这种方式永远可靠地工作。您必须
等待> 被发送之前接收字符文本
送或者实际上它是不只是方式> 字符,它为四
字符。从 3GPP规范报价27.005


  

      
  • 的TA将发送一个四字符序列
      < CR>< LF>< GREATER_THAN><空> (IRA 13,10,62,32)之后的命令行
      终止与< CR> ;之后的文本可以从TE输入到
      ME / TA。

  •   

(TA(终端适配器)在这里是指调制解调器和TE(终端设备)的发送者命令)

和27.005对于任何中止的AT命令(显然是AT + CMGS规定
任何字符此命令将被终止执行。)发送将
中止命令的操作。引用 ITU V.250


  

5.6.1中止命令


  
  

...


  
  

中止
  命令是由实现
  从DTE到DCE传输
  任何字符。


(DCE(数据通信设备)在这里是指调制解调器和DTE(数据终端设备)的AT的发送者命令)

这意味着,当你发送文派之前为\\ r \\ n>发送
由调制解调器的命令将被中止。有没有办法等待长
足够的期待响应中发送。您必须读取和解析
响应文本你从调制解调器回来。

这同样适用于每个命令后的最终结果code(例如确定
错误 CME ERROR 和多了一些)。比如发送AT + CMGF = 1
然后不先等待OK乞讨发送下一个命令
对于问题。因此,发送AT命令时一如既往,您必须等待
发送下一个命令之前最终结果code。

请不要,不要使用延迟来等待任何AT命令响应。它的
因为踢狗,站在你的方式,以获得他们有用
移动。是的,它实际上可能工作有时,但在某些时候你
会后悔采取这种方法...

回答你的问题。

根据你得到的回应

,我可以看到你的问题不是命令
流产(虽然你的分析有严重的问题,如上所述
你应该解决这个问题),而CME ERROR是您的最佳线索。从节
9.2.1常规错误,在27.007它让不支持操作作为
描述值4。

27.005规定:


  

如果发送网络或ME错误,最后的结果code + CMS ERROR在失败:返回


注意,这是+ CMS ERROR,而不是+ CME错误,但它是适用的,请看下面。

我猜动作的顺序如下:

AT指令处理SM100B GSM调制解调器的一部分接受SMS数据
并格式化它以适当的格式,并将其发送到的部分
调制解调器与GSM网络进行通信。它成功地发送
SMS数据到网络并报告该回AT命令处理
其中一部分然后打印 + CMGS:25 和最终的结果code 确定。然而
很短的时间之后,网络送回一个拒绝消息为SMS,
,然后给出了+ CME ERROR响应。

如果上面我的猜测是正确的,应该响应已交付
为+ CMS ERROR呢?没有,因为最终响应
已为AT + CMGS命令已经被赋予(OK),并
返回多个最终结果codeS为一个命令不应该做
(除非错误(注1))。
尽管+ CME ERROR可以代替ERROR最终结果code,
它不仅是一个最终的结果code。从AT + CMEE命令说明:


  

设置命令禁用或启用使用结果code + CME错误:为与一个错误的指示
  在MT的功能。启用后,MT相关的错误引起+ CME ERROR:最终结果code,而不是
  经常ERROR最终结果code。 ERROR通常返回时,错误与语法,无效的参数,
  或TA功能。


因此​​,+ CME ERROR既可以是一个最终的结果code以及未经请求
结果code(也可能是一个中间结果code)。

但无法在AT + CMGS命令已经等待接收网络
拒绝并返回+ CMS ERROR?可能不会。不知道过
很多有关的短信发送网络的详细信息,它可能是这样的
今天拒绝可能比以前发生在更晚的时间。这样
变化是有时与GSM的一个问题涉及在该命令有
一个古老的遗产原本紧缚GSM行为,
有时变少并且随着技术移动到GPRS少真,
UMTS,LTE,等

注1:

我的一个习惯抱怨的标准的方式前同事
指定的语音呼叫处理,因为经过ATD1234;命令
你第一次得到的最终结果code OK,再后来当呼叫
结束你会得到一个新的最终结果code NO CARRIER。这只是可怕
糟糕的设计,呼叫结束标志应该是一个特定的不请自来
响应,而不是最后的回应。

总结一下

您的短信似乎是由网络拒绝。试着找出原因。
你也有一些严重的问题,您的AT命令处理
你应该确定;有没有办法来处理AT命令不
阅读和分析来自调制解调器响应文本。

I am using Arduino to control an SM5100B GSM device, everything works except when I want to send an SMS after receiving another. I get this,

Error code:

O K > + C M G S : 2 5 O K + C M E E R R O R : 4

My code for handling the aforementioned received SMS:

     #include <SoftwareSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module. 
        char inchar;                //Will hold the incoming character from the Serial Port. 
        SoftwareSerial cell(2,3); 
        char mobilenumber[] = "0597010129";
        void setup() { 
        //GSM
        Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
        Serial.println("Initialize GSM module serial port for communication.");                       
        cell.begin(9600); 
        delay(35000); // give time for GSM module to register on network etc. 
        Serial.println("delay off");
        cell.println("AT+CMGF=1"); // set SMS mode to text 
        delay(200); 
        cell.println("AT+CNMI=3,3,0,0"); // set module to send SMS data to serial out upon receipt 
        delay(200); 
        } 



        void loop() {   

         if(cell.available() >0)//If a character comes in, from the cellular module
         { 
         inchar=cell.read(); 
         Serial.println(inchar); 
         if (inchar=='#'){ // OK - the start of our command 

           delay(10); 
           inchar=cell.read();
           Serial.println(inchar);  

             if (inchar=='a'){ 

               delay(10); 
               Serial.println("The folowing SMS : \n");
               inchar=cell.read();
               Serial.println(inchar); 

               if (inchar=='0'){ //sequance = #a0

                 Serial.println("#a0 was received"); 

             }
             else if (inchar=='1'){//sequance = #a1

                Serial.println("#a1 was received ");
                sendSms();

             }
         }
         cell.println("AT+CMGD=1,4");// AT command to delete all msgs
         Serial.println(" delete all SMS"); 
          } 
        }//end of  if(cell.available() >0) {...}
        }

        void sendSms(){
        //cell.println("AT+CMGF=1"); // set SMS mode to text 
        cell.print("AT+CMGS=");  // now send message... 
        cell.print((char)34); // ASCII equivalent of " 
        cell.print(mobilenumber); 
        cell.println((char)34);  // ASCII equivalent of " 
        delay(500); // give the module some thinking time 
        cell.print(":D hello m3alleg :D");   // our message to send 
        cell.println((char)26);  // ASCII equivalent of Ctrl-Z 
        delay(20000);
}

解决方案

General note about your handling of AT commands.

No, no, no! This way of doing it will never work reliably. You MUST wait for the > character to be be received before sending "text to send". Or actually it is not just the > character, it is four characters. Quote from 3GPP specification 27.005:

  • the TA shall send a four character sequence <CR><LF><greater_than><space> (IRA 13, 10, 62, 32) after command line is terminated with <CR>; after that text can be entered from TE to ME/TA.

(TA (terminal adapter) here means modem and TE (terminal equipment) the sender of AT commands)

For any abortable AT command (and 27.005 clearly states for AT+CMGS This command should be abortable.) the sending of any character will abort the operation of the command. To quote ITU V.250:

5.6.1 Aborting commands

...

Aborting of commands is accomplished by the transmission from the DTE to the DCE of any character.

(DCE (data communication equipment) here means modem and DTE (data terminal equipment) the sender of AT commands)

This means that when you send "text to send" before "\r\n> " is sent by the modem the command will be aborted. There is no way to wait "long enough" for expecting the response be send. You MUST read and parse the response text you get back from the modem.

The same applies for the final result code after each command (e.g. OK, ERROR, CME ERROR and a few more). For instance sending "AT+CMGF=1" and then sending the next command without first waiting for OK is begging for problems. So always when sending AT commands, you MUST wait for the final result code before sending the next command.

Please never, never use delay to wait for any AT command response. It's as useful as kicking dogs that stand in your way in order to get them to move. Yes it might actually work some times, but at some point you will be sorry for taking that approach...

Answer to your question.

Based on the response you get, I can see that your problem is not command abortion (although your parsing have serious problems as described above that you should fix), and the CME ERROR is your best clue. From section "9.2.1 General errors" in 27.007 it gives operation not supported as description for value 4.

27.005 states that:

If sending fails in a network or an ME error, final result code +CMS ERROR: is returned.

Notice that this is +CMS ERROR and not +CME ERROR, but it is applicable, see below.

I guess that sequence of actions is as following:

The AT command handling part of the SM100B GSM modem accepts the sms data and formats it in an appropriate format and sends it of to the part of the modem that communicates with the GSM network. It successfully send the sms data to the network and reports this back to the AT command handling part which then prints +CMGS: 25 and final result code OK. However after a short time the network sends back a rejection message for the sms, which is then given as the +CME ERROR response.

If my guess above is correct, should the response have been delivered as +CMS ERROR instead? No, because the final response has for the AT+CMGS command has already been given (OK), and returning multiple final result codes for a command should never be done (except by mistake (note 1)). And while +CME ERROR can replace the ERROR final result code, it is not only a final result code. From the AT+CMEE command description:

Set command disables or enables the use of result code +CME ERROR: as an indication of an error relating to the functionality of the MT. When enabled, MT related errors cause +CME ERROR: final result code instead of the regular ERROR final result code. ERROR is returned normally when error is related to syntax, invalid parameters, or TA functionality.

Thus +CME ERROR can both be an final result code as well as an unsolicited result code (possibly also an intermediate result code).

But could not the AT+CMGS command have waited to receive the network rejection and returned +CMS ERROR? Probably not. Without knowing too much about the network details of sms sending, it might be the case that rejection today might occur at a much later time than before. Such changes are sometimes a problem with GSM related AT commands which have an old heritage that was originally tightly tied to GSM behaviour which some times becomes less and less true as the technology moves to GPRS, UMTS, LTE, etc.

Note 1:

One of my former colleagues used to complain about the way the standard have specified voice call handling, because after a ATD1234; command you first get the final result code OK, and then later when the call is ended you get a new final result code NO CARRIER. This just horribly bad design, the call end indication should have been a specific unsolicited response and not a final response.

So to summarise

Your sms seems to be rejected by the network. Try to find out why. You also have some serious problems with your AT command handling that you should fix; there is no way to handle AT commands without reading and parsing the response text from the modem.

这篇关于GSM SM5100B C M E E R RØR:4错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆