Go Down

Topic: gsm sim900a issue (Read 340 times) previous topic - next topic

PereTGN

Hello all,

I'm using an Arduino UNO and GSM sim900a module to make just  calls and everthing works fine(Phone being called ringing and stops ringing when "hang up" AT command is executed) but i have noticed the following issue.

Firstly, a menu of some AT commands  is printed out in a command line window as a guidance for the user so if I press 'y', the AT+CPIN? AT command is executed. The result i get with this is

  AT+CPIN?
+CPIN: SIM PIN

OK


Then I press  press 'u', the AT+CPIN=MySIMPIN AT command is executed and The result i get with this is

  AT+CPIN=MySIMPIN
OK

+CPIN: READY


Up to here everything is ok but i've noticed "if mySerial.available()>0" statement at some point gets true (value of availablein else: 5) when i was expecting to remaind false.

My understanding is that mySerial.available() method will return a value higher than 0 whenever i start a communication with the GSMsim900 board via "Start_Operation_Function(command);" function(mySerial.write). Then the mySerial.available() will be returning decremented values while Im reading the result in "Executing_Operation_Function();" function (mySerial.read) but once everything is read I'm expecting mySerial.available() method to return 0 and remain so while no other at command is executed and that's not the case in these two scenarios.

1.-Enter SIM pin
2.-Hang up a call successfully after a call is successfully executed(phone ringing)

All other option i have implemented, no matter the other of execution, mySerial.available() return 0 at the end of the transmisson of the result and remain so if no other at command is executed, so if mySerial.available()>0 is always false at this point.

does anyone know why this is happening?

Please, see the log file attached for the Ente SIM Pin case for a better understanding of the issue i noticed.
Please, see a piece of the code below as well

Thanks in advance

Regards

Code: [Select]
void loop()
{
  if (Serial.available()>0)
  {
    switch(Serial.read())
    {
case 'q':
  Start_Operation_Function("AT+GMI\r\n"); //Request Manufacturer Identification
  break;
case 'w':
  Start_Operation_Function("AT+GMM\r\n"); //Request TA Model Identification
  break;
case 'e':
  Start_Operation_Function("AT+GMR\r\n"); //Request TA Revison Identification of SW release
  break;
case 'r':
  Start_Operation_Function("AT+GOI\r\n"); //Request Global object Identification
  break;
case 't':
  Start_Operation_Function("AT+GSN\r\n"); //Request TA serial number identification (IMEI)
  break;
case 'y':
  Start_Operation_Function("AT+CPIN?\r\n"); //Status of SIMcard
  break;y
case 'u':
  Start_Operation_Function("AT+CPIN=MySIMPIN\r\n"); //Enter PIN SIMcard
  break;
case 'i':
  Start_Operation_Function("AT+CMEE?\r\n"); //ENable error reporting. it has to be enabled everytime board is switched back on
  break;
case 'o':
  Start_Operation_Function("AT+CMEE=1\r\n"); //ENable error reporting. it has to be enabled everytime board is switched back on
  break;
case 'p':
  Start_Operation_Function("ATI\r\n");     //Product Info
  break;
case 's':
// SendMessage();
break;
case 'c':
  Start_Operation_Function("ATDN┬║tobecalled;\r\n"); //calling number
break;
case 'h':
      Start_Operation_Function("ATH0\r\n"); //Hang up
break;
case 'f':
//RedialCall();
break;
case 'a':
//ReceiveCall();
break;
default:
break;
    }
}
int value;
 if (mySerial.available()>0)
 {

    if (AT_Command_Started)
    {
    value=mySerial.available();
    Serial.print("value of avilable in if: ");
    Serial.println(value);
    Executing_Operation_Function();

    }
    else
    {
    value=mySerial.available();
    Serial.print("value of avilable in else: ");
    Serial.println(value);
        //Serial.println("Command not recognized or not implemented");
    }
 }
 else
 {
    if (AT_Command_Started)
    {
    End_Operation_Function();
    }
    else
{
    //Do nothing
}
 }
 delay(10);
}

/*Support Functions*/



Go Up