Libelium is offering new technical support channels, to contact with de Technical Support team to solve any issue our doubt please contact with your sales agent or visit our contact site



Post a new topicPost a reply Page 1 of 1   [ 5 posts ]
Author Message
 Post subject: Read data from GRPS QuadBand module
PostPosted: Fri Sep 02, 2011 12:13 pm 

Joined: Fri Sep 02, 2011 12:05 pm
Posts: 3
Hi (sorry for my bad english)

i want to read response from module to make some actions. In particular i want to check if there a missing call and check if call number is a determinate number.
I try this :

Serial.println("AT+CPBR=1;");

time=millis();
while(millis()<time+timeouts){
if(Serial.available()>0){
datarec=datarec.concat(Serial.read());
if(datarec.endsWith('\n')){

break;

}
}
}

The response on Hyperterminal was correct i see +CPBR: .......

If i check the datarec, it always blank...

Module are connect to an arduino in standalone mode and i read the data from another arduino without atmega like in libelium tutorial (http://www.libelium.com/squidbee/index. ... -_Sagem%29) .

If i try to make call or send sms it works correctly.

Can you help me ? Have you any software that i can use ?


Top
 Profile  
 
 Post subject: Re: Read data from GRPS QuadBand module
PostPosted: Mon Sep 05, 2011 10:08 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi cesco,

I suggest you to read this post viewtopic.php?f=29&t=552

There is a code for reading SMS, maybe it can help you.

regards


Top
 Profile  
 
 Post subject: Re: Read data from GRPS QuadBand module
PostPosted: Wed Sep 07, 2011 11:51 am 

Joined: Fri Sep 02, 2011 12:05 pm
Posts: 3
Thanks for answer.

I test the code but i don't know why the result aren't correct because i obtain strange result: part of answer + command overlying ...

Serial is set to 19200.

Is there the possibility to use another communication serial pin in order to read command/result directly to arduino ?

It's very difficult to debug process.


Top
 Profile  
 
 Post subject: Re: Read data from GRPS QuadBand module
PostPosted: Thu Sep 08, 2011 8:00 am 

Joined: Mon Sep 28, 2009 12:06 pm
Posts: 11366
Hi,

Maybe is better if you try first connecting the GPRS module to the PC directly http://www.cooking-hacks.com/index.php/ ... band#step2 so you'll see directly on the screen the answers of the GPRS.

The problem is that you can't do it with Arduino Mega because you have to take the microcontroller out. Could you get an Arduino Uno?

regards


Top
 Profile  
 
 Post subject: Re: Read data from GRPS QuadBand module
PostPosted: Thu Sep 08, 2011 10:57 am 

Joined: Fri Sep 02, 2011 12:05 pm
Posts: 3
I try with arduino uno but the function suggest don't work so i use this function to read data

Code:
#define LINEBUF_SIZE 129
char databuffer[LINEBUF_SIZE];
byte last_read_timed_out=0;
 
unsigned int read_line(unsigned long timeout_ms=2000) {
    //Reads a line of text from the 'duino Serial library's buffer (128 bytes unless changed).
    //Reads until
    // - a newline   (which then makes it to the buffer - can make some string tests easier)
    // - the buffer is full (hardcoded length)
    // - reading a next character times out
    // ...whichever comes first.
    //
    // Writes the a null-terminated string into databuffer,
    //  (so reads at most (LINEBUF_SIZE-1) useful characters)
    // Returns the amount of bytes we read (==strlen(databuffer))
    //
    // On timeout:
    // - Waits no longer than 'timeout_ms' milliseconds for each next character.
    // - On timeout, sets last_read_timed_out=1
    // - Note that currently function only returns 0 when it timed out reading
    //   anything at all, so that can also be a simple test for timeout
    // - Timeout values of <30ms can be too short
    //
    // On newlines:
    // - was written with the idea that you may get only CR or LF
    //    (not sure if that's ever true)
    // - will not emit empty lines
    // - which combines to mean that it will leave \n in the Serial buffer
    //   and only ignores it on the next call of read_line(). This is significant
    //   when you're doing data exchange, because that byte will mess things up.
    char *tptr=databuffer;
    unsigned long last_byte_time;
 
    last_read_timed_out=0;   
    databuffer[0]=0x00;      // (make sure empty string on timeout is null terminated)
    last_byte_time=millis(); // used in a 'last byte was read this long ago' test
 
    while (true) { //(not and endless loop, broken off by timeout if not by end-of-line)
      //If the buffer is full, break off.
      if ((tptr-databuffer) > (LINEBUF_SIZE-2)) { //verify for off-by-one error.
        // -2 so that the last position can safely be set to the null terminator.
        tptr[1]=0x00;
        break;
      }
 
      // Read a byte, if it's there
      if (Serial.available()>0) { // If there's a byte to be read,
        tptr[0]=Serial.read();    // read it in
        tptr[1]=0x00; //(could be postponed until we know we're done, actually)
        tptr++;
        last_byte_time=millis();  // update 'last byte read came at' time
 
        // Terminate reading on a newline, deal with empty lines by ignoring them
        if (   ((tptr[-1]=='\n') || (tptr[-1]=='\r'))  &&  ( ((int)(tptr-databuffer)) == 1 )   )
        { //empty line or crlf? Pretend this line didn't exist, start over with next character.
          tptr=databuffer;
          databuffer[0]=0x00;
          continue;
        }
        if (tptr[-1]=='\r') { // CR, \r, but not at start of line - assume this is a complete response, return it
          break;
        } //note that this leaves the \n from a CRLF in the Serial buffer. This function deals with it, your manual Serial code may not.
 
        continue; //we read a byte, skip timeout check this round
      } else { //no byte available yet
         //delay(1); //probably unnecessary.
      }
 
      // Time out?
      if (millis()-last_byte_time > timeout_ms) { //TODO: check behaviour at millis overflow
        tptr[1]='\0';
        last_read_timed_out=1; //signal that we timed out
        break;
      }
    }
 
    // I use software-serial for debug to print out the time of receive,
    // the just-read line's length, string representation, and hex representation
    // (omitted here for relative brevity)
 
    return (int)(tptr-databuffer); // amount of bytes we read into databuffer (TODO: check)
}


It works very good

Now i want to read a sms and after delete it.

By AT+CMGR=1 i read correctly sms , after execute : Serial.println("AT+CMGD=1,4"); but nothing happens. It work only one time... I don't know why sometime something work and after don't work...
Like AT+FUN=1,1 (in order to reset missed call) it work only one time... :(


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 5 posts ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Libelium theme based on 610nm Style by Daniel St. Jules of http://www.gamexe.net


© Libelium Comunicaciones Distribuidas S.L. | Terms of use.