GPRS with SM5100B

hi everyone!! i'm working with an arduino uno and a SM5100B GSM Cellular Shield, i'm trying to work with GPRS, but i have to read de comands from de cellular shiel like "+SIND: 1" or + "+SIND 7", i need to read these commands to make a better code, and cofigure this cellular shield using an arduino code. this is de code that i have written. thanks and i hope that anybody could gimme some help

#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>         //Used for string manipulations

char incoming_char=0;//Will hold the incoming character from the Serial Port.
int conf_flag=0;
char key_char=0;
int send_flag=0;
NewSoftSerial cell(2,3);  //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

/////////////////////////////////////////////////////

void setup()
{
  //Initialize serial ports for communication.
Serial.begin(9600);
cell.begin(9600);
Serial.print("Starting SM5100B Communication...");

}

///////////////////////////////////////////////////////


int configure(char){
  int flag=0;
  char a=0;
  int var=0;
    cell.print("AT+SBAND=10");
    cell.print("AT+CFUN=1, 1");
    var=100;
    
    while(var>0){
      a=cell.read();
      if (a=='+SIND: 11'){
        var=0;
      }
      else if(a=='+SIND: 7'){
      var=0;
      }
      else {
        var=var-1;
      }
    }
    if(a=='+SIND: 11'){
      a=0; 
      Serial.print('modulo registrado');
      cell.println("AT+CGAT?");
      a=cell.read();
      if (a=='+CGATT: 1'){
        a=0;
        Serial.print("encontrado servicio GPRS");
        cell.print('AT+CGDCONT=1,  "IP",  "web.colombia.com.co"');
        cell.print('AT+CGPCO=0,"","",1');
        cell.print("AT+CGACT=1,1");
        a=cell.read();
        if (a=='OK'){
           a=0;
           flag=HIGH;
           return flag;
           }
         else{
           Serial.print("error al activar el PDP");
           flag=LOW;
           return flag;
         }
      }
      else if(a=='CGATT: 0'){
        a=0;
        Serial.print('servicio GPRS no encontrado, inserte una sim card con plan de datos');
        flag=LOW;
        return flag;
       }
    }   
    else if(a=='+SIND: 7'){
     a=0;
     Serial.print("modulo solo para llamadas de emergencia");
     flag=LOW;
     return flag;
    }
    
  
}

////////////////////////////////////////////////////////
int conection_f(char){
   char a=0;
   int flag=0; 
 cell.print('AT+SDATACONF=1, "TCP", "74.125.229.248", 80, 1'); // la IP que se encuentra en esta linea es la IP de google, cambiela por la de IP que usted desee
 a=cell.read();
 if(a=='OK'){
   a=0;
   cell.print("AT+SDATASTART=1, 1");
   cell.print("AT+SDATASTATUS=1");
   a=cell.read();
   if (a=='+SOCKSTATUS: 1,1,0102,0,0,0'){
     a=0;
     Serial.print("socket conectado");
     cell.print("AT+SDATATSEND=1, 10"); // envio de datos y tramas
     cell.print("AT+SDATATREAD=1");
     a=cell.read();
     if(a=='+STCPD:1'){
       a=0;
       Serial.print("datos recibidos por el host remoto");
       cell.print("AT+SDATASTART=1,0");
       a=cell.read();
       if(a=='+STCPD:1' || a=='OK'){
         Serial.print("conexion terminada con exito");
         flag=HIGH;
         return flag;
       }       
     
   }
     
 }
   else if(a=='+SOCKSTATUS: 1,0,0104,0,0,0'){   
     a=0;
     Serial.print("socket no conectado");
     flag=LOW;
     return flag;
   }
 
 
 else{
   Serial.print("no se pudo establecer conexion con el servidor");
 
 }
}
}

/////////////////////////////////////////////////////////

void loop(){


//If a character comes in from the cellular module...
if(cell.available() >0)
{
incoming_char=cell.read();    //Get the character from the cellular serial port.

Serial.print(incoming_char);

if (incoming_char=='+SIND: 1'){
 Serial.print("espere mientras el modulo se prepara");  
}

else if (incoming_char=='+SIND: 7'){
 Serial.print("espere mientras el modulo se prepara");  
}

else if (incoming_char=='+SIND: 11'){
 Serial.print("modulo listo para empezar a transmitir");   
}  
  
  
}




////If a character is coming from the terminal to the Arduino...
if(Serial.available() >0)
{

key_char=Serial.read(); //Get the character coming from the terminal



if (key_char=='conf' || incoming_char=='+SIND: 7')
 {
   conf_flag=configure(key_char);
   if (conf_flag==HIGH){
      Serial.print("modulo listo para transmitir");
   }  
  else if (conf_flag==LOW){
      Serial.print("modulo no se pudo configurar con exito, intentelo nuevamente");  
   }
 }

if (key_char=='server' && incoming_char=='+SIND: 11' ){
  send_flag=conection_f(key_char);
   if(send_flag==HIGH){
   Serial.print("datos enviados con exito, conexion terminada");
   }
   else if(send_flag==LOW){
  Serial.print("error al enviar los datos intentelo de nuevo");
 }
  


}


}
}
int configure(char){

The function takes an anonymous argument that can never be used. Why?

    cell.print("AT+SBAND=10");
    cell.print("AT+CFUN=1, 1");

Doesn't it matter what the response to the first command is?

      a=cell.read();
      if (a=='+SIND: 11'){

The cell.read() function reads ONE character. That ONE character will NEVER equal '+SIND: 11'. NEVER.

thank you, i understand, so what functions can i use for read that commands? please help me

so what functions can i use for read that commands?

You use cell.read(), but, you understand that it reads one character (just like Serial.read()), so you need to store the data in a char array, and keep that array NULL terminated.

You can compare the contents of that array to a string using strcmp() and enclosing the known string in double quotes.

I've written my code again acording to your suggestions, first i don't have the function strcmp, so i made string comparison using this code

a=="+SIND: 11"

and i made the command reading with this code

char* a;

 for(i=0;i<=9;i++){
        a[i]=cell.read();
     }

so my final code is this, but still not working, could you please help me? thanks

#include <NewSoftSerial.h>  //Include the NewSoftSerial library to send serial commands to the cellular module.
#include <string.h>         //Used for string manipulations

char incoming_char[9];//Will hold the incoming character from the Serial Port.

int i=0;
int conf_flag=0;
char key_char[4];
int send_flag=0;
NewSoftSerial cell(2,3);  //Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin.

/////////////////////////////////////////////////////

void setup()
{
  //Initialize serial ports for communication.
Serial.begin(9600);
cell.begin(9600);
Serial.print("Starting SM5100B Communication...");

}

///////////////////////////////////////////////////////


int configure(){
  char* a;
  int flag=0;
  int var=0;
    cell.print("AT+SBAND=10");
    cell.print("AT+CFUN=1, 1");
    var=100;
            
    while(var>0){
     for(i=0;i<=9;i++){
        a[i]=cell.read();
     }
        
        if (a=="+SIND: 11"){
        var=0;
      }
      else if(a=="+SIND: 7"){
      var=0;
      }
      else {
        var=var-1;
      }
    }
    if(a=="+SIND: 11"){
      a=0; 
      Serial.print("modulo registrado");
      cell.println("AT+CGAT?");
      while(var>0){
     for(i=0;i<9;i++){
        a[i]=cell.read();
     }
      if (a=="+CGATT: 1"){
        a=0;
        Serial.print("encontrado servicio GPRS");
        cell.print("AT+CGDCONT=1, \"IP\", \"web.colombia.com.co\"");
        cell.print("AT+CGPCO=0,\"none\",\"none\",1");
        //  cell.print("AT+CGPCO=0,"","",1");
        cell.print("AT+CGACT=1,1");
        while(var>0){
     for(i=0;i<2;i++){
        a[i]=cell.read();
     }
        if (a=="OK"){
           a=0;
           flag=HIGH;
           return flag;
           }
         else{
           Serial.print("error al activar el PDP");
           flag=LOW;
           return flag;
         }
      }
      }
      else if(a=="CGATT: 0"){
        a=0;
        Serial.print('servicio GPRS no encontrado, inserte una sim card con plan de datos');
        flag=LOW;
        return flag;
       }
    }
    }   
    else if(a=="+SIND: 7"){
     a=0;
     Serial.print("modulo solo para llamadas de emergencia");
     flag=LOW;
     return flag;
    }
    
    } 



////////////////////////////////////////////////////////
int conection_f(){
 int b=0;
  char* a;
  int flag=0; 
 cell.print("AT+SDATACONF=1,\"TCP\",\"74.125.229.248\", 80, 1"); // la IP que se encuentra en esta linea es la IP de google, cambiela por la de IP que usted desee
 //cell.println("AT+SDATACONF=1,\"TCP\",\"181.51.142.39\", 2510,1"); // servidor temporal
 for(i=0;i<2;i++){
        a[i]=cell.read();
     }
 if(a=="OK"){
   a=0;
   cell.print("AT+SDATASTART=1, 1");
   for(i=0;i<28;i++){
        a[i]=cell.read();
     }
     if(a=="+STCPD: 1"){ 
     cell.print("AT+SDATATREAD=1");
     if(cell.available() >0)
      {
        b=cell.read();    //Get the character from the cellular serial port.
         Serial.print(b);
      }
     }  
   
   cell.print("AT+SDATASTATUS=1");
   for(i=0;i<28;i++){
        a[i]=cell.read();
     }
   if (a=="+SOCKSTATUS: 1,1,0102,0,0,0"){
     a=0;
     Serial.print("socket conectado");
//     cell.print("AT+SDATATSEND=1, 10"); // envio de datos y tramas
//      for(i=0;i<9;i++){
//       a[i]=cell.read();
//     }
//     if(a=="+STCPD: 1"){
//       a=0;
//       Serial.print("datos recibidos por el host remoto");
        cell.print("AT+SDATASTART=1,0");
       for(i=0;i<2;i++){
        a[i]=cell.read();
     }
       if(a=="OK"){
         Serial.print("conexion terminada con exito");
         flag=HIGH;
         return flag;
       }       
     
   }
     
 }
   else if(a=="+SOCKSTATUS: 1,0,0104,0,0,0"){   
     a=0;
     Serial.print("socket no conectado");
     flag=LOW;
     return flag;
   }
 
 
 else{
   Serial.print("no se pudo establecer conexion con el servidor");
 
 }
}


/////////////////////////////////////////////////////////

void loop(){


//If a character comes in from the cellular module...
if(cell.available() >0)
{

  for(i=0;i<9;i++){
  incoming_char[i]=cell.read();    //Get the character from the cellular serial port.
  }
 

if (incoming_char=="+SIND: 1"){
 Serial.print("espere mientras el modulo se prepara");  
}

else if (incoming_char=="+SIND: 7"){
 Serial.print("espere mientras el modulo se prepara");  
}

else if (incoming_char=="+SIND: 11"){
 Serial.print("modulo listo para empezar a transmitir");   
}  
  
  
}




////If a character is coming from the terminal to the Arduino...
if(Serial.available() >0)
{


  for(i=0;i<13;i++){
   key_char[i]=Serial.read();    //Get the character from the cellular serial port.
  }
 

if (key_char=="conf" || incoming_char=="+SIND: 7")
 {
   conf_flag=configure();
   if (conf_flag==HIGH){
      Serial.print("modulo listo para transmitir");
   }  
  else if (conf_flag==LOW){
      Serial.print("modulo no se pudo configurar con exito, intentelo nuevamente");  
   }
 }

if (key_char=="serv" && incoming_char=="+SIND: 11" ){
  send_flag=conection_f();
   if(send_flag==HIGH){
   Serial.print("datos enviados con exito, conexion terminada");
   }
   else if(send_flag==LOW){
  Serial.print("error al enviar los datos intentelo de nuevo");
 }
  


}


}
}
  char* a;

The variable a is a pointer. Where does it point to?

     for(i=0;i<=9;i++){
        a[i]=cell.read();
     }

Regardless of whether a response has been received, or not, you try to read 10 characters and put them in the place that a points to. To repeat, where does a point to?

There are a lot of similarities between pointers and arrays, and they can almost always be used interchangeably, with one major exception. That is that pointers THAT HAVE BEEN POINTED TO SOME MEMORY and arrays are nearly always interchangeable.

Your pointer has NOT been pointed to some memory, so you can't use it like it were an array. You need a REAL array.

        if (a=="+SIND: 11"){

The pointer a will NEVER point to the constant string "+SIND: 11", so they will NEVER be equal.

first i don't have the function strcmp

Yes, you do.

Thanks for your advices, my code it's already working, but i have some problems with the command AT+DATATSEND, i want to send mesages from my smb5100b but when i use this command I recieve error messages like CMR: ERROR 4, and when i put the comand like this

AT+DATATSEND= 1,1

i have this answer

and my device doesn't receive any other command

i have the same problem when i write this comand on arduino with this code

cell.print("AT+DATATSEND= 1,1")

could you help me please? thanks!

I´m so new on this topic, but.

I would recommend seeing these sites:

http://nicegear.co.nz/blog/gprs-with-the-sm5100b-arduino-gsm-shield/

And to use on Arduino