Show Posts
Pages: 1 ... 13 14 [15] 16 17 ... 25
211  Using Arduino / Programming Questions / Can I connect several a GPRS At command on: April 11, 2013, 10:30:30 am
Dear All,

Today I had a reflexion while thining about my project.
I am trying to write AT commande to connect and send data to a remote server.

In my loop() I have that code to connect
Code:
  Serial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
 
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
 
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
 
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
 

When it's connected it send the data
Code:
int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
 
  Serial.println(F("Sending HTTP packet..."));
  cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
  waitFor('>'); // wait for GSM module to tell us it's ready to recieve the packet
  cell.print(request+"\r\n"); // SIZE: 2
  cell.print("Host: "+host+"\r\n"); // SIZE: 8
  cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
  cell.write(26); // ctrl+z character: send the packet
  waitFor("OK");

 Serial.println("Yes! Sent data acknowledged by server!");

Then it wait for 1mn and the loop starts again.

But should I run that code again
Code:
Serial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
 
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
 
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
 
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
 
  delay(5000); // wait for the socket to connect

It's already connected! no?

I should loop on that code:
Code:
int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
 
  Serial.println(F("Sending HTTP packet..."));
  cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
  waitFor('>'); // wait for GSM module to tell us it's ready to recieve the packet
  cell.print(request+"\r\n"); // SIZE: 2
  cell.print("Host: "+host+"\r\n"); // SIZE: 8
  cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
  cell.write(26); // ctrl+z character: send the packet
  waitFor("OK");

But if I am true, and I leave my module runing for 5 hours, it will be connected for 5 hours, then I will my my ISP provide?
Should I not disconnect at the end of the loop and reconnect when loop starts?
212  International / Français / Re: Comment puis envoyer des donner à un serveur web avec un GPRS on: April 11, 2013, 10:21:35 am
Ok, je te remercie pour ta réponse,

Y a un petit questionnement que je me suis posé cette après midi

Cici va initier la connection pour l'envoi http
Code:
erial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
 
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
 
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
 
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
 
  delay(5000); // wait for the socket to connect
Une fois connecté, il va envoyé les données
Code:
int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
 
  Serial.println(F("Sending HTTP packet..."));
  cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
  waitFor('>'); // wait for GSM module to tell us it's ready to recieve the packet
  cell.print(request+"\r\n"); // SIZE: 2
  cell.print("Host: "+host+"\r\n"); // SIZE: 8
  cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
  cell.write(26); // ctrl+z character: send the packet
  waitFor("OK");

 Serial.println("Yes! Sent data acknowledged by server!");

(Je me passe des boucle de vérification.)

Une fois fait la boucle recommence.


Quand la boucle recommence, es-ce qu'il doit refaire ceci si ca deja été fait?
Code:
  Serial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
 
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
 
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
 
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
 

Es-ce que je dois déconnecter le connection avant que la boucle recommence?
213  International / Français / Re: Comment puis envoyer des donner à un serveur web avec un GPRS on: April 11, 2013, 02:54:33 am
(suite du code qui suis la function loop()
Code:
/* NOTES
 *
 * what is +STIN:1 ?
 *
 * to disconnect after transmission: AT+CGACT=0,1 breaks socket. AT+CGATT=0 seems to work more authoritatively?
 * AT+SDATASTART=1,0 // close TCP connection
 * AT+SDATASTATUS=1 // clear sent/ack bytes from SOCKSTATUS
 *
*/

// ====== HELPER FUNCTIONS ====== //

// keep reading the serial messages we receive from the module
// loop forever until we get a nonzero string ending in \r\n - print and return that.
// TODO: implement a timeout that returns 0?
String getMessage() {
  String s="";
  while(1) {
    if(cell.available()>0) {
      s = s+(char)cell.read();
      if (s.length()>1 && s[s.length()-2]=='\r' && s[s.length()-1]=='\n') { // if last 2 chars are \r\n
        if (s==" \r\n" || s=="\r\n") { // skip these, move on
          s="";
        }
        else { // we have a message!
          Serial.println(s.substring(0,s.length()-2));
          return s.substring(0,s.length()-2);
        }
      }
    }
  }
}

// for eating a single message we expect from the module
// prints out the next message from the module. if it's not the expected value, die
void waitFor(String s) {
  String message=getMessage();
  if (message != s) {
    Serial.println("Wait, that's not what we were expecting. We wanted \""+s+"\"");
    cellOutputForever();
  }
  delay(100); // wait for a tiny bit before sending the next command
}

// keep spitting out messages from the module til we get the one we expect
void waitTil(String s) {
  String message;
  while (1) {
    message = getMessage();
    if (message == s){
      delay(100); // cause we're probably about to send another command
      return;
    }
  }
}

// keep reading characters until we get char c
void waitFor(char c) {
  while(1) {
    if(cell.available()>0) {
      if ((char)cell.read() == c) {
        delay(100);
        return;
      }
    }
  }
}

// if something goes wrong, abort and just display cell module output so we can see error messages
// this will loop forever
void cellOutputForever() {
  Serial.println("Looping forever displaying cell module output...");
  while(1) {
    if(cell.available()>0) {
      Serial.print((char)cell.read());
    }
  }
}

// like above, but in hex, useful for debugging
void cellHexForever() {
  while(1) {
    if(cell.available()>0) {
      char c = (char)cell.read();
//      Serial.print("a char: ");
      Serial.print(c, HEX);
      Serial.print(" ");
      Serial.println(c);
    }
  }
}


// receive string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// 0 is connection id. 1 is whether connected or not. 2 is status (0104 is connecting, 0102 is connected, others)
// 3 is sent bytes. 4 is acknowledged bytes. 5 is "received data counter"
// THIS FUNCTION WILL check that sent bytes == ack bytes, and return that value
// return 0 if they don't match or if amount of data is 0
int checkSocketString(String s) {
  if (socketStringSlice(3,s) == 0)
    return 0;
  else if (socketStringSlice(3,s) == socketStringSlice(4,s))
    return socketStringSlice(3,s);
  else
    return 0;
}

// returns the index of the nth instance of char c in String s
int nthIndexOf(int n, char c, String s) {
  int index=0;
  for (int i=0; i<=n; i++) {
    index = s.indexOf(c,index+1);
  }
  return index;
}

// expects string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// returns nth chunk of data, delimited by commas
int socketStringSlice(int n, String s) {
  String slice = s.substring(nthIndexOf(n-1,',',s)+1,nthIndexOf(n,',',s));
  char cArray[slice.length()+1];
  slice.toCharArray(cArray, sizeof(cArray));
  return atoi(cArray);
}
214  International / Français / Re: Comment puis envoyer des donner à un serveur web avec un GPRS on: April 11, 2013, 02:53:51 am
Mais c'est un truc de ouf,
Y a pas des commande AT pour tous les modules?

Sais-tu ou je peux commander un SIM900? J'ai besoin d'un tout petit

Si j'ai ce code mais il ne fonctionne que lors du premier passage dans la loop(), après, il se bloque dans la function
Code:
void cellOutputForever() {
  Serial.println("Looping forever displaying cell module output...");
  while(1) {
    if(cell.available()>0) {
      Serial.print((char)cell.read());
    }
  }
}
ou après le premoer envoi au server,
il se bloque et n'arrive plus recevoir un aknoledge du server
Code:
  while (1) {
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String s = getMessage(); // we want s to contain the SOCKSTATUS message
    if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    waitFor("OK");
   
    if (!s.startsWith("+SOCKSTATUS")) {
      Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
      cellOutputForever(); // something went wrong
    }
    if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
      break; // we're good!
    else {
      Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
      delay(1000);
    }
  }
  Serial.println("Yes! Sent data acknowledged by server!");
C'est asesez dur d'etre précis, mais voici le code complet
Code:
/* SM5100B-GPRS
 * this Arduino program sends an HTTP request over GPRS using the SM5100B GSM shield
 * author: http://toby.is
 * more info: http://github.com/tobek/SM5100B-GPRS
*/

// include the SoftwareSerial library to send serial commands to the cellular module:
#include <SoftwareSerial.h>

SoftwareSerial cell(2,3);  // Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin. connect this to the GSM module

const String apn = "internet"; // access-point name for GPRS

const String ip = "80.00.000.00"; // IP address of server we're connecting to
const String host = "www.qqq-qqq.net"; // required in HTTP 1.1 - what's the name of the host at this IP address?
const String request = "GET /temp/updatesql.php?lat=1.10&long=1.20&alt=1.30&speed=1.40&course=1.50&date=2013-4-10&time=19:12:00 HTTP/1.1";
const String useragent = "Mozilla/5.0"; // for our purposes the user agent doesn't matter - if I understand correctly it's helpful to use something generic the server will recognize

int GPRS_registered = 0;
int GPRS_AT_ready = 0;

  /* this will send the following packet:
 *
 * GET /m/testpage.php?data=testing HTTP/1.1
 * Host: avantari.co.uk
 * User-Agent: Mozilla/5.0
 *
 * this is the equivalent of visiting http://avantari.co.uk/m/testpage.php?data=testing
*/

void setup()
{
  //Initialize serial ports for communication with computer
  Serial.begin(9600);
 
  Serial.println(F(""));
  Serial.println(F("Starting SM5100B Communication..."));
  cell.begin(9600);
  /*
  waitTil("+SIND: 4"); // keep printing cell output til we get "+SIND: 4"
  Serial.println("Module ready");
  */
 
  Serial.println(F("Wait for module is registered (+SIND: 11) and  ready (+SIND: 4) ..."));
 

  while (GPRS_registered == 0 || GPRS_AT_ready == 0) {
       String ready = getMessage();
       
       if(ready == "+SIND: 1"){
         Serial.println(F("SIM is inserted ..."));
       }
       
       if(ready == "+SIND: 10,\"SM\",1,\"FD\",1,\"LD\",1,\"MC\",1,\"RC\",1,\"ME\",1"){
         Serial.println(F("SIM is ready ..."));
       }
       
       if(ready == "+SIND: 11"){
         GPRS_registered = 1;
         Serial.println(F("Module is registered to network ..."));
       }
       
       if(ready == "+SIND: 3"){
         Serial.println(F("GPRS is partially ready ..."));
       }
       
       if(ready == "+SIND: 4"){
         GPRS_AT_ready = 1;
         Serial.println(F("GPRS is ready ..."));
       }
       
       if(ready == "+SIND: 7"){
         Serial.println(F("Emergency only ..."));
       }
       
    }
   
 
  //waitTil("+SIND: 4"); // keep printing cell output til we get "+SIND: 4"
  Serial.println(F(" "));
  Serial.println(F("READY TO GO"));
 
 
}

void loop()
{
 
  Serial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
 
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
 
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
 
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
 
  delay(5000); // wait for the socket to connect
 
  // now we'll loop forever, checking the socket status and only breaking when we connect
  while (1) {
    Serial.println(F("Checking socket status:"));
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String sockstat = getMessage();
    waitFor("OK");
    if (sockstat=="+SOCKSTATUS:  1,0,0104,0,0,0") {
      Serial.println(F("Not connected yet. Waiting 1 second and trying again."));
      delay(1000);
    }
    else if (sockstat=="+SOCKSTATUS:  1,1,0102,0,0,0") {
      Serial.println(F("Socket connected"));
      break;
    }
    else {
      Serial.println(F("We didn't expect that."));
      cellOutputForever();
    }
  }
 
  // we're now connected and can send HTTP packets!
 
  int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
 
  Serial.println(F("Sending HTTP packet..."));
  cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
  waitFor('>'); // wait for GSM module to tell us it's ready to recieve the packet
  cell.print(request+"\r\n"); // SIZE: 2
  cell.print("Host: "+host+"\r\n"); // SIZE: 8
  cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
  cell.write(26); // ctrl+z character: send the packet
  waitFor("OK");
 
 
  // now we're going to keep checking the socket status forever
  // break when the server tells us it acknowledged data
  while (1) {
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String s = getMessage(); // we want s to contain the SOCKSTATUS message
    if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    waitFor("OK");
   
    if (!s.startsWith("+SOCKSTATUS")) {
      Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
      cellOutputForever(); // something went wrong
    }
    if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
      break; // we're good!
    else {
      Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
      delay(1000);
    }
  }
  Serial.println("Yes! Sent data acknowledged by server!");

  // we could skip the checking of SOCKSTATUS in the above while-loop
  // instead we could just wait for one or both of these:
  //waitTil("+STCPD:1"); // this means data is received
  //waitTil("+STCPC:1"); // this means socket is closed
 
  // TODO: actually check if we received data, don't just do this blindly
 // Serial.println(F("Reading data from server..."));
 // cell.println("AT+SDATAREAD=1"); // how we read data server has sent
  // WARNING: this might not work - software serial can be too slow for receiving data
   
  //cellHexForever(); // useful for debugging
 // cellOutputForever(); // just keep printing whatever GSM module is telling us
}


Je suis limité dans le nombre de caratères autorisés dans ce poste. Je colle la suite su code, qui suit la finc de fubction loop() dans un post suivant
215  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 11, 2013, 02:49:55 am
It s looping for ever...
The terminal return me message:
Code:
void waitFor(String s) {
  String message=getMessage();
  if (message != s) {
    Serial.println("Wait, that's not what we were expecting. We wanted \""+s+"\"");
    cellOutputForever();
  }
  delay(100); // wait for a tiny bit before sending the next command
}
But I can not understand why

Some time it's alway showing
Quote
Sent data not yet acknowledged by server, waiting 1 second and checking again
Code:
while (1) {
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String s = getMessage(); // we want s to contain the SOCKSTATUS message
    if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    waitFor("OK");
   
    if (!s.startsWith("+SOCKSTATUS")) {
      Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
      cellOutputForever(); // something went wrong
    }
    if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
      break; // we're good!
    else {
      Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
      delay(1000);
    }
  }
216  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 07:09:49 pm
Here is the following after the loop()
Code:

/* NOTES
 * what is +STIN:1 ?
 * to disconnect after transmission: AT+CGACT=0,1 breaks socket. AT+CGATT=0 seems to work more authoritatively?
 * AT+SDATASTART=1,0 // close TCP connection
 * AT+SDATASTATUS=1 // clear sent/ack bytes from SOCKSTATUS
*/
// keep reading the serial messages we receive from the module
// loop forever until we get a nonzero string ending in \r\n - print and return that.
// TODO: implement a timeout that returns 0?
String getMessage() {
  String s="";
  while(1) {
    if(cell.available()>0) {
      s = s+(char)cell.read();
      if (s.length()>1 && s[s.length()-2]=='\r' && s[s.length()-1]=='\n') { // if last 2 chars are \r\n
        if (s==" \r\n" || s=="\r\n") { // skip these, move on
          s="";
        }
        else { // we have a message!
          Serial.println(s.substring(0,s.length()-2));
          return s.substring(0,s.length()-2);
        }
      }
    }
  }
}

// for eating a single message we expect from the module
// prints out the next message from the module. if it's not the expected value, die
void waitFor(String s) {
  String message=getMessage();
  if (message != s) {
    Serial.println("Wait, that's not what we were expecting. We wanted \""+s+"\"");
    cellOutputForever();
  }
  delay(100); // wait for a tiny bit before sending the next command
}

// keep spitting out messages from the module til we get the one we expect
void waitTil(String s) {
  String message;
  while (1) {
    message = getMessage();
    if (message == s){
      delay(100); // cause we're probably about to send another command
      return;
    }
  }
}

// keep reading characters until we get char c
void waitFor(char c) {
  while(1) {
    if(cell.available()>0) {
      if ((char)cell.read() == c) {
        delay(100);
        return;
      }
    }
  }
}

// if something goes wrong, abort and just display cell module output so we can see error messages
// this will loop forever
void cellOutputForever() {
  Serial.println("Looping forever displaying cell module output...");
  while(1) {
    if(cell.available()>0) {
      Serial.print((char)cell.read());
    }
  }
}

// like above, but in hex, useful for debugging
void cellHexForever() {
  while(1) {
    if(cell.available()>0) {
      char c = (char)cell.read();
//      Serial.print("a char: ");
      Serial.print(c, HEX);
      Serial.print(" ");
      Serial.println(c);
    }
  }
}


// receive string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// 0 is connection id. 1 is whether connected or not. 2 is status (0104 is connecting, 0102 is connected, others)
// 3 is sent bytes. 4 is acknowledged bytes. 5 is "received data counter"
// THIS FUNCTION WILL check that sent bytes == ack bytes, and return that value
// return 0 if they don't match or if amount of data is 0
int checkSocketString(String s) {
  if (socketStringSlice(3,s) == 0)
    return 0;
  else if (socketStringSlice(3,s) == socketStringSlice(4,s))
    return socketStringSlice(3,s);
  else
    return 0;
}

// returns the index of the nth instance of char c in String s
int nthIndexOf(int n, char c, String s) {
  int index=0;
  for (int i=0; i<=n; i++) {
    index = s.indexOf(c,index+1);
  }
  return index;
}

// expects string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// returns nth chunk of data, delimited by commas
int socketStringSlice(int n, String s) {
  String slice = s.substring(nthIndexOf(n-1,',',s)+1,nthIndexOf(n,',',s));
  char cArray[slice.length()+1];
  slice.toCharArray(cArray, sizeof(cArray));
  return atoi(cArray);
}
Is there no an easier way to do it?
Hope you can help. Thank
217  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 07:09:00 pm
Dear Peter,

Thank. But I am trying it since a couple of month and I can not get a result. I have been oft in front of problem regarding the delay between AT request and I am still pending with that issue.

It the reason why I am looking for exemple code wich work in a repeating loop. For exemple send a data each 20 sec.

I fond some library but it still not work....

Would you have an exemple with socksatus?

This is an exemple.I found, but it only send once. After it return an error and it block. The script loop at while(1) loop
Code:
#include <SoftwareSerial.h>

SoftwareSerial cell(2,3);  // Create a 'fake' serial port. Pin 2 is the Rx pin, pin 3 is the Tx pin. connect this to the GSM module

const String apn = "internet"; // access-point name for GPRS
const String ip = "80.00.000.11"; // IP address of server we're connecting to
const String host = "www.yyy-xxx.net"; // required in HTTP 1.1 - what's the name of the host at this IP address?
const String request = "GET /temp/updatesql.php?lat=1.10&long=1.20&alt=1.30&speed=1.40&course=1.50&date=2013-4-10&time=19:12:00 HTTP/1.1";
const String useragent = "Mozilla/5.0"; // for our purposes the user agent doesn't matter - if I understand correctly it's helpful to use something generic the server will recognize

int GPRS_registered = 0;
int GPRS_AT_ready = 0;

void setup()
{
  Serial.begin(9600);
  
  Serial.println(F(""));
  Serial.println(F("Starting SM5100B Communication..."));
  cell.begin(9600);
  /*
  waitTil("+SIND: 4"); // keep printing cell output til we get "+SIND: 4"
  Serial.println("Module ready");
  */
  
  Serial.println(F("Wait for module is registered (+SIND: 11) and  ready (+SIND: 4) ..."));
 
  while (GPRS_registered == 0 || GPRS_AT_ready == 0) {
       String ready = getMessage();
      
       if(ready == "+SIND: 1"){
         Serial.println(F("SIM is inserted ..."));
       }
      
       if(ready == "+SIND: 10,\"SM\",1,\"FD\",1,\"LD\",1,\"MC\",1,\"RC\",1,\"ME\",1"){
         Serial.println(F("SIM is ready ..."));
       }
      
       if(ready == "+SIND: 11"){
         GPRS_registered = 1;
         Serial.println(F("Module is registered to network ..."));
       }
      
       if(ready == "+SIND: 3"){
         Serial.println(F("GPRS is partially ready ..."));
       }
      
       if(ready == "+SIND: 4"){
         GPRS_AT_ready = 1;
         Serial.println(F("GPRS is ready ..."));
       }
      
       if(ready == "+SIND: 7"){
         Serial.println(F("Emergency only ..."));
       }
      
    }
    
  
  //waitTil("+SIND: 4"); // keep printing cell output til we get "+SIND: 4"
  Serial.println(F(" "));
  Serial.println(F("READY TO GO"));
  
  
}

void loop()
{
  
  Serial.println(F("Attaching GPRS..."));
  cell.println("AT+CGATT=1");
  waitFor("OK");
  
  Serial.println(F("Setting up PDP Context..."));
  cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
  waitFor("OK");

  Serial.println(F("Activating PDP Context..."));
  cell.println("AT+CGACT=1,1");
  waitFor("OK");
  
  Serial.println(F("Configuring TCP connection to TCP Server..."));
  cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
  waitFor("OK");
  
  Serial.println(F("Starting TCP Connection..."));
  cell.println("AT+SDATASTART=1,1");
  waitFor("OK");
  
  delay(5000); // wait for the socket to connect
  
  // now we'll loop forever, checking the socket status and only breaking when we connect
  while (1) {
    Serial.println(F("Checking socket status:"));
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String sockstat = getMessage();
    waitFor("OK");
    if (sockstat=="+SOCKSTATUS:  1,0,0104,0,0,0") {
      Serial.println(F("Not connected yet. Waiting 1 second and trying again."));
      delay(1000);
    }
    else if (sockstat=="+SOCKSTATUS:  1,1,0102,0,0,0") {
      Serial.println(F("Socket connected"));
      break;
    }
    else {
      Serial.println(F("We didn't expect that."));
      cellOutputForever();
    }
  }
  
  // we're now connected and can send HTTP packets!
  
  int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
  
  Serial.println(F("Sending HTTP packet..."));
  cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
  waitFor('>'); // wait for GSM module to tell us it's ready to recieve the packet
  cell.print(request+"\r\n"); // SIZE: 2
  cell.print("Host: "+host+"\r\n"); // SIZE: 8
  cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
  cell.write(26); // ctrl+z character: send the packet
  waitFor("OK");
  
  
  // now we're going to keep checking the socket status forever
  // break when the server tells us it acknowledged data
  while (1) {
    cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
    String s = getMessage(); // we want s to contain the SOCKSTATUS message
    if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
      s = getMessage();
    //if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
    //  s = getMessage();
    waitFor("OK");
    
    if (!s.startsWith("+SOCKSTATUS")) {
      Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
      cellOutputForever(); // something went wrong
    }
    if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
      break; // we're good!
    else {
      Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
      delay(1000);
    }
  }
  Serial.println("Yes! Sent data acknowledged by server!");

  // we could skip the checking of SOCKSTATUS in the above while-loop
  // instead we could just wait for one or both of these:
  //waitTil("+STCPD:1"); // this means data is received
  //waitTil("+STCPC:1"); // this means socket is closed
  
  // TODO: actually check if we received data, don't just do this blindly
 // Serial.println(F("Reading data from server..."));
 // cell.println("AT+SDATAREAD=1"); // how we read data server has sent
  // WARNING: this might not work - software serial can be too slow for receiving data

//Wait 10 sec and send again the data to server. Of course the data will change within that time
delay(10000);
}

In the next post, I past the following code, the function
218  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 04:12:07 pm
Oups, I miss a detail.

it has to be send in a frequently time. For exemple, each 10sec or 20 sec or 60sec...

XML as JSON are interesting for transfering data
219  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 04:05:00 pm
Yes, but with or without XML. The best would be the best.

For now my vision is to send to an php file with will get the value with $_GET and then the PHP script store the value in a databae.
But I am a bit a geniner and I will be interested for the best way to do it.

XML would be very interesting.

Then in resume.
1. Arduino collect the value
2. It use the GPRS module to send the data, it can be an XML file or GET value
3. the web server get and record the value into a database

Do you think there is labrary which do it?
220  Using Arduino / Programming Questions / Re: How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 03:44:34 pm
No, no, sorry,

I have a sketch code will get some value.
The sketch code use the GPRS module to send data to a remote MySQL database / web server.
221  International / Français / Comment puis envoyer des donner à un serveur web avec un GPRS on: April 10, 2013, 02:16:43 pm
Bonjour à tous,

Connaitriez-vous une librairie qui me permettrait d'emvoyer des données à un serveur web et les stocker dans une base de donnée?
Ca pourrait être un fichier XML ou une URL avec des variable

J'ai besoin que cette librairie soit performante et qu'elle s'adapte à différent module GPRS et particulièrement à ces deux

this https://www.sparkfun.com/products/9607 ou this https://www.sparkfun.com/products/10138

Votre aide me serait très précieuse à trouver donc une solution pour envoyer et stocker quelques données, via GPRS, sur un serveur web


Milles mercis pour vos lumières, solutions ou tuto  smiley
222  Using Arduino / Programming Questions / How can I send data to a web server with GPRS (HTTP or XML) on: April 10, 2013, 02:11:41 pm
Dear All,

I need to send some data as variable or, at the best, an XML file to a web server.

I have a GPRS Module and the data will be send through the cell phone

The xml file content will be store in a MySQL database.

I am looking for an Arduino Uno or Mini Pro library to send and store data into a MySQL database, BUT I need that library work with different GPRS modules as
this https://www.sparkfun.com/products/9607 or this https://www.sparkfun.com/products/10138



Could you help to make me able to send data to a web server?

Many thank for your help.
Cheers
223  International / Français / Re: Quels sont les aventage d'une librarie on: April 10, 2013, 02:39:17 am
Donc ca permetrait de libérer e la mémoire et éviter un crash/reboot du script?
224  International / Français / Quels sont les aventage d'une librarie on: April 10, 2013, 02:16:13 am
Hello

Je travaille sur une project qui va collecter des position GPS et les envoyer sur un server via HTTP/HTTPS. Comme débutant, j'ai un très bon résultat et je suis content. Je recois bien les positions GPS qui sont stocké dans une variable String.

J'ai aussi un autre code qui lui envoie les données au serveur toutes les 10 sec.
Il les envoi avec le protocole HTTP et AT+ commande

J0'ai testé ce code séparément dans un autre fichier, et il marche.

Maintenant, j'ai fusionné les code en ajoutant une fonction void sendDATA(){} dans lequel se trouve mon code qui envoit donc les commandes au serveur.

Le problème, c'est qu'au moment ou le code sendDATA() est exécuté, le terminal crash et reboot, comme si on appuzait sur la touche reboot. Si je commande le code sendDATA(), ca fonctionne. Si je l'utilise séparément, il fonctionne.
C'est un peu comme, si la mémoire était plein, ou si le terminal avait "trop à lire/faire...."

Seriez-vous la raison?

Maintenant, je me demande des bénéfice d'une librairie. par exemple, je pourrais créer un fichie SendData/SendData.h avec la fonction sendDATA() et le mettre dans le dossier library.

Es-ce que ca me serait bénéfique?
Quel est le bénéfique d'une librairie?

Que me recommanderiez-vous pour créer ma première librairie avec succès?
Quels sont les points que je dois pas manquer?

Merci pour vos lumières?

Voci le code de sendDATA()
Code:
NewSoftSerial.h

/* FUNCTIONS RELATED TO GPRS WHILE SENDING DATA TO THE SERVER*/

// HOW TO HAVE IT AS A LIBRARAY AND SEND DATA (GPS FIXES) TO A SERVER IN HTTP OT HTTPS

// getMessage is defined outside, but I can have that function here
// cell. is defined outside
// GPRS_ACTIVE, DEBUG and SENDDATA are defined outside but I can remove its
// requests (is a String) is defined outside but I should add it as para,meter in my function sendDATA(requests)

// for eating a single message we expect from the module
// prints out the next message from the module. if it's not the expected value, die
void waitFor(String s) {
  String message=getMessage();
  if (message != s) {
    Serial.print(F("Wait, that's not what we were expecting. We wanted "));
    Serial.println("\""+s+"\"");
    cellOutputForever();
  }
  delay(100); // wait for a tiny bit before sending the next command
}

// if something goes wrong, abort and just display cell module output so we can see error messages
// this will loop forever
void cellOutputForever() {
  Serial.println(F("Looping forever displaying cell module output..."));
  while(1) {
    if(cell.available()>0) {
      Serial.print((char)cell.read());
    }
  }
}

// keep reading characters until we get char c
void waitForGSM(char c) {
  while(1) {
    if(cell.available()>0) {
      if ((char)cell.read() == c) {
        delay(100);
        return;
      }
    }
  }
}

// receive string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// 0 is connection id. 1 is whether connected or not. 2 is status (0104 is connecting, 0102 is connected, others)
// 3 is sent bytes. 4 is acknowledged bytes. 5 is "received data counter"
// THIS FUNCTION WILL check that sent bytes == ack bytes, and return that value
// return 0 if they don't match or if amount of data is 0
int checkSocketString(String s) {
  if (socketStringSlice(3,s) == 0)
    return 0;
  else if (socketStringSlice(3,s) == socketStringSlice(4,s))
    return socketStringSlice(3,s);
  else
    return 0;
}

// returns the index of the nth instance of char c in String s
int nthIndexOf(int n, char c, String s) {
  int index=0;
  for (int i=0; i<=n; i++) {
    index = s.indexOf(c,index+1);
  }
  return index;
}

// expects string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// returns nth chunk of data, delimited by commas
int socketStringSlice(int n, String s) {
  String slice = s.substring(nthIndexOf(n-1,',',s)+1,nthIndexOf(n,',',s));
  char cArray[slice.length()+1];
  slice.toCharArray(cArray, sizeof(cArray));
  return atoi(cArray);
}

void sendDATA(){
         
          /********************************/
          /*  SEND THE DATA TO THE SERVER */
          /********************************/
     
          //cell.println("AT+SBAND=6");
       
#ifdef GPRS_ACTIVE
    #ifdef SENDDATA
         //cell.println("AT+SBAND=6");
       
         #ifdef DEBUG
           freeRAM();
            Serial.println(F("1. Attaching GPRS..."));
          #endif
       
          cell.println("AT+CGATT=1");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("2. Setting up PDP Context..."));
          #endif
          cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("3. Activating PDP Context..."));
          #endif
           
          cell.println("AT+CGACT=1,1");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("4. Configuring TCP connection to TCP Server..."));
          #endif
          cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
          //cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\","+port+"");
          waitFor("OK");
           
           #ifdef DEBUG
             Serial.println(F("5. Starting TCP Connection..."));
           #endif

           cell.println("AT+SDATASTART=1,1");
           waitFor("OK");
           
           delay(5000); // wait for the socket to connect
     
           // now we'll loop forever, checking the socket status and only breaking when we connect
           while (1) {
             #ifdef DEBUG
               Serial.println(F("6. Checking socket status:"));
             #endif
             cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
             String sockstat = getMessage();
             waitFor("OK");
             if (sockstat=="+SOCKSTATUS:  1,0,0104,0,0,0") {
               Serial.println(F("Not connected yet. Waiting 1 second and trying again."));
               delay(1000);
             }
             else if (sockstat=="+SOCKSTATUS:  1,1,0102,0,0,0") {
               Serial.println(F("Socket connected"));
               break;
             }
             else {
               Serial.println(F("We didn't expect that."));
               cellOutputForever();
             }
           }
           
            // we're now connected and can send HTTP packets!
            //int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
           int packetLength = 26+host.length()+requests.length()+useragent.length();
           
           #ifdef DEBUG
             Serial.println(F("7. Sending HTTP packet..."));
           #endif
           cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
           waitForGSM('>'); // wait for GSM module to tell us it's ready to recieve the packet
           cell.print(requests+"\r\n"); // SIZE: 2
           cell.print("Host: "+host+"\r\n"); // SIZE: 8
           cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
           cell.write(26); // ctrl+z character: send the packet
           waitFor("OK");
           
           
           // now we're going to keep checking the socket status forever
           // break when the server tells us it acknowledged data
           while (1) {
              cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
              String s = getMessage(); // we want s to contain the SOCKSTATUS message
              if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
                s = getMessage();
              if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
                s = getMessage();
              waitFor("OK");
             
              if (!s.startsWith("+SOCKSTATUS")) {
               
                  Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
               
                cellOutputForever(); // something went wrong
              }
              if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
                break; // we're good!
              else {
                Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
                delay(1000);
              }
            }
           
            #ifdef DEBUG
              Serial.println(F(" "));
              Serial.println(F("YES! DATA ARE SENT AND ACKNOWLEDGE BY SRERVER!"));
         
            #endif
         
         #endif // END IFDEF DSENDDATA
       #endif // END IEF GPRS_ACTIVE   
       
     /***************************************/
     /* **** END SENDING DATA TO THE SERVER */
     /***************************************/

}
225  Using Arduino / Programming Questions / What the benefic of a library on: April 10, 2013, 02:05:59 am
Good morning,

Actually I am working on a GPS/GPRS project. I am a beginer but I got a great result.
My ocde work fine. May be there is some thing to perfect but until now I got the GPS fix in regular schedule.

I also have a code to send the data to a server via HTTP and with AT+ command.

I tested the code separately and it worked fine.

Now I merged the code by adding a function call void sendDATA(){} and when the fix is display, the sebdDATA function follow the GPS fix data.

The problem is when the terminal is ready to lunch the sendDATA code, the module carsh and restarted as if I press the rerset buton. If I comment the sedDATA function it work. If I execute the sendDATA code in a different sketch file, it works.

It like if the memory is full, or if the terminal has too much to read.

Do you have an idea?

Now I am thinking to put my senDATA code into a senDATA.h file to have it has a library.
Do you think it will help?
What is the benefict?

What would you recommand me to create successefuly my first library?
What are the point that I mst'nt miss?

Many thank for your help

Here is me sendDATA code
Code:
NewSoftSerial.h

/* FUNCTIONS RELATED TO GPRS WHILE SENDING DATA TO THE SERVER*/

// HOW TO HAVE IT AS A LIBRARAY AND SEND DATA (GPS FIXES) TO A SERVER IN HTTP OT HTTPS

// getMessage is defined outside, but I can have that function here
// cell. is defined outside
// GPRS_ACTIVE and SENDDATA are defined outside but I can remove its
// requests (is a String) is defined outside but I should add it as para,meter in my function sendDATA(requests)

// for eating a single message we expect from the module
// prints out the next message from the module. if it's not the expected value, die
void waitFor(String s) {
  String message=getMessage();
  if (message != s) {
    Serial.print(F("Wait, that's not what we were expecting. We wanted "));
    Serial.println("\""+s+"\"");
    cellOutputForever();
  }
  delay(100); // wait for a tiny bit before sending the next command
}

// if something goes wrong, abort and just display cell module output so we can see error messages
// this will loop forever
void cellOutputForever() {
  Serial.println(F("Looping forever displaying cell module output..."));
  while(1) {
    if(cell.available()>0) {
      Serial.print((char)cell.read());
    }
  }
}

// keep reading characters until we get char c
void waitForGSM(char c) {
  while(1) {
    if(cell.available()>0) {
      if ((char)cell.read() == c) {
        delay(100);
        return;
      }
    }
  }
}

// receive string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// 0 is connection id. 1 is whether connected or not. 2 is status (0104 is connecting, 0102 is connected, others)
// 3 is sent bytes. 4 is acknowledged bytes. 5 is "received data counter"
// THIS FUNCTION WILL check that sent bytes == ack bytes, and return that value
// return 0 if they don't match or if amount of data is 0
int checkSocketString(String s) {
  if (socketStringSlice(3,s) == 0)
    return 0;
  else if (socketStringSlice(3,s) == socketStringSlice(4,s))
    return socketStringSlice(3,s);
  else
    return 0;
}

// returns the index of the nth instance of char c in String s
int nthIndexOf(int n, char c, String s) {
  int index=0;
  for (int i=0; i<=n; i++) {
    index = s.indexOf(c,index+1);
  }
  return index;
}

// expects string such as "SOCKSTATUS: 1,1,0102,10,10,0"
// returns nth chunk of data, delimited by commas
int socketStringSlice(int n, String s) {
  String slice = s.substring(nthIndexOf(n-1,',',s)+1,nthIndexOf(n,',',s));
  char cArray[slice.length()+1];
  slice.toCharArray(cArray, sizeof(cArray));
  return atoi(cArray);
}

void sendDATA(){
         
          /********************************/
          /*  SEND THE DATA TO THE SERVER */
          /********************************/
     
          //cell.println("AT+SBAND=6");
       
#ifdef GPRS_ACTIVE
    #ifdef SENDDATA
         //cell.println("AT+SBAND=6");
       
         #ifdef DEBUG
           freeRAM();
            Serial.println(F("1. Attaching GPRS..."));
          #endif
       
          cell.println("AT+CGATT=1");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("2. Setting up PDP Context..."));
          #endif
          cell.println("AT+CGDCONT=1,\"IP\",\""+apn+"\"");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("3. Activating PDP Context..."));
          #endif
           
          cell.println("AT+CGACT=1,1");
          waitFor("OK");
           
          #ifdef DEBUG
            Serial.println(F("4. Configuring TCP connection to TCP Server..."));
          #endif
          cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\",80");
          //cell.println("AT+SDATACONF=1,\"TCP\",\""+ip+"\","+port+"");
          waitFor("OK");
           
           #ifdef DEBUG
             Serial.println(F("5. Starting TCP Connection..."));
           #endif

           cell.println("AT+SDATASTART=1,1");
           waitFor("OK");
           
           delay(5000); // wait for the socket to connect
     
           // now we'll loop forever, checking the socket status and only breaking when we connect
           while (1) {
             #ifdef DEBUG
               Serial.println(F("6. Checking socket status:"));
             #endif
             cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
             String sockstat = getMessage();
             waitFor("OK");
             if (sockstat=="+SOCKSTATUS:  1,0,0104,0,0,0") {
               Serial.println(F("Not connected yet. Waiting 1 second and trying again."));
               delay(1000);
             }
             else if (sockstat=="+SOCKSTATUS:  1,1,0102,0,0,0") {
               Serial.println(F("Socket connected"));
               break;
             }
             else {
               Serial.println(F("We didn't expect that."));
               cellOutputForever();
             }
           }
           
            // we're now connected and can send HTTP packets!
            //int packetLength = 26+host.length()+request.length()+useragent.length(); // 26 is size of the non-variable parts of the packet, see SIZE comments below
           int packetLength = 26+host.length()+requests.length()+useragent.length();
           
           #ifdef DEBUG
             Serial.println(F("7. Sending HTTP packet..."));
           #endif
           cell.print("AT+SDATATSEND=1,"+String(packetLength)+"\r");
           waitForGSM('>'); // wait for GSM module to tell us it's ready to recieve the packet
           cell.print(requests+"\r\n"); // SIZE: 2
           cell.print("Host: "+host+"\r\n"); // SIZE: 8
           cell.print("User-Agent: "+useragent+"\r\n\r\n"); // SIZE: 16
           cell.write(26); // ctrl+z character: send the packet
           waitFor("OK");
           
           
           // now we're going to keep checking the socket status forever
           // break when the server tells us it acknowledged data
           while (1) {
              cell.println("AT+SDATASTATUS=1"); // we'll get back SOCKSTATUS and then OK
              String s = getMessage(); // we want s to contain the SOCKSTATUS message
              if (s == "+STCPD:1") // this means server sent data. cool, but we want to see SOCKSTATUS, so let's get next message
                s = getMessage();
              if (s == "+STCPC:1") // this means socket closed. cool, but we want to see SOCKSTATUS, so let's get next message
                s = getMessage();
              waitFor("OK");
             
              if (!s.startsWith("+SOCKSTATUS")) {
               
                  Serial.println(F("Wait, this isn't the SOCKSTATUS message!"));
               
                cellOutputForever(); // something went wrong
              }
              if (checkSocketString(s) == packetLength) // checks that packetLength bytes have been acknowledged by server
                break; // we're good!
              else {
                Serial.println(F("Sent data not yet acknowledged by server, waiting 1 second and checking again."));
                delay(1000);
              }
            }
           
            #ifdef DEBUG
              Serial.println(F(" "));
              Serial.println(F("YES! DATA ARE SENT AND ACKNOWLEDGE BY SRERVER!"));
         
            #endif
         
         #endif // END IFDEF DSENDDATA
       #endif // END IEF GPRS_ACTIVE   
       
     /***************************************/
     /* **** END SENDING DATA TO THE SERVER */
     /***************************************/

}
Pages: 1 ... 13 14 [15] 16 17 ... 25