Post a new topicPost a reply Page 1 of 1   [ 7 posts ]
Author Message
 Post subject: Comunication between Xbee with GPRS
PostPosted: Thu Jun 07, 2012 7:28 pm 

Joined: Tue Mar 13, 2012 4:54 pm
Posts: 18
Hello. I have this code for parking sensor
Quote:
#define ADDRESS "0013A20040763C97"
#define Waspmote "0013A20040763C6D"
#define PARKING "0013A20040763C42"
int mac;
packetXBee* paq_sent; 
//char* data;
uint8_t data;
uint8_t temperature;
boolean status;

uint8_t contador=0;


void setup()
{
  delay (9000);//Dejo tiempo
   
    
  SensorParking.loadReference();//Carga coef temperatura
  SensorParking.setBoardMode(SENS_ON);//Activa todo
  
  delay(2000);
  SensorParking.calibration();// Toma los valores iniciales del campo magneticoº
  SensorParking.setBoardMode(SENS_OFF);//Apaga

}
void loop()
{
   

  SensorParking.setBoardMode(SENS_ON);
  
  delay (1000);// Libelium
  
  SensorParking.readParkingSetReset();//Realinea molec y lee tensiones
  temperature = SensorParking.readTemperature();//Compensacion Tª
  SensorParking.calculateReference(temperature);
  status = SensorParking.estimateState();
  
  //Inicio el módulo Xbee
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  xbee802.ON();
  XBee.println("Modulo inicializado");
  
  
  //detecto si la plaza esta ocupada
  
  status = SensorParking.estimateState();
  if(status == PARKING_OCCUPIED)
    {
               contador=contador+1;
               XBee.println("Parece que la plaza se ha ocupado");
               XBee.println(contador,DEC);
    }
  else
    {
          contador=0;
          XBee.println("Plaza libre");
          if( data==1)
          {
              data=0;
              XBee.println("Plaza libre");
              XBee.println(contador,DEC);
              XBee.println(data,DEC);
              enviar();
          }
    }

   if(contador == 20)
    {
               
               data=1;
               enviar();
               XBee.println("Plaza ocupada ");
               XBee.println(contador);
               contador=0;
    }  
            
    delay(1000);//Retardo de un segundo
    XBee.println("Modulo OFF");
    xbee802.OFF();
   
  }
    
  

  
  
  void enviar ()
{
    paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
    paq_sent->mode=UNICAST; 
    paq_sent->MY_known=0; 
    //paq_sent->packetID=0x52;
    paq_sent->opt=0; 
    xbee802.hops=0; 
    //configuro el que envia datos
    xbee802.setOriginParams(paq_sent, PARKING, MAC_TYPE); 
    //Configuro quien lo recibe.Envio libre o ocupado
    xbee802.setDestinationParams(paq_sent, Waspmote, data, MAC_TYPE, DATA_ABSOLUTE);
    
    xbee802.sendXBee(paq_sent); 
    delay(100);
    
    if( !xbee802.error_TX )
    {
      XBee.println("Sin error en la transmisión");
     
    }
    
    else
    {
          XBee.println("Error en la transmisión");
    }
    free(paq_sent);
    paq_sent=NULL;
  }




And this for a wasmote with a module Xbee and GPRS:

Quote:
#define MAX_TRIES 3
#define DEBUG_PORT  
uint8_t tiempoLimite = 3;
uint8_t timeout;

#define Waspmote "0013A20040763C6D"
#define SERVIDOR_IP   "extranet.grupoforo.com"
#define SERVIDOR_SUB_URL  "/gf.saga.web/"
#define SERVIDOR_PUERTO   "90"

char commando[90];
uint8_t n=0;
uint8_t i=0;
uint8_t respuesta = 0;
long previous=0;
uint8_t j=0;
uint8_t Mac_parking[8];
uint8_t dato_leido;
 
char ocupacionc;
char* Mac_parkingc="";
packetXBee* paq_sent;


void setup(){
  
  // setup for Serial port over USB
  USB.begin();
  USB.println("USB port started...");
  
  RTC.ON();

  // setup for GPRS serial port
  GPRS.ON();
  USB.println("GPRS module ready...");
  
  // waiting while GPRS connects to the network
   while((timeout<MAX_TRIES)&&(!GPRS.check()))
   {
     USB.print("timeout = ");
     USB.println(timeout,DEC);
     timeout++;
     delay(200);
  }
  USB.println("GPRS connected to the network");
  
  // configure SMS and Incoming Calls
  if(GPRS.setInfoIncomingCall()) USB.println("Info Incoming Call OK");
  if(GPRS.setInfoIncomingSMS()) USB.println("Info Incoming SMS OK");
  if(GPRS.setTextModeSMS()) USB.println("Text Mode SMS OK");
  
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  xbee802.ON();
  XBee.println("\n Modulo inicializado");
  if(GPRS.configureGPRS()) USB.println("Configured OK");
}

void loop(){
  // Configure GPRS Connection
  respuesta = GPRS.createSocket(SERVIDOR_IP, SERVIDOR_PUERTO, GPRS_CLIENT);
  USB.print("Respuesta crear socket: ");
  USB.println(respuesta, DEC);
  
  if(respuesta == 1)
  {
    USB.println("Socket Opened OK");
    USB.print("Session Number: ");
    while( GPRS.socket_ID[i]!='\r' )
    {
      USB.print(GPRS.socket_ID[i]-'0',DEC);
      i++;
    }
    i=0;
    USB.println();
  }
  else
  {
    USB.println("Error opening the socket");
    USB.print("Valor Error: ");
    USB.println(GPRS.flag, DEC);
  }
  delay(500);
  
  
  dato_leido=leerdatos(); 
  if (dato_leido==1)
  {
  formatearPeticion("mote.txt",Mac_parkingc,ocupacionc);
  signalCobertura();
  llamarSaga();
  Mac_parkingc[0]=NULL;
  }
  else
  {
    XBee.println("Ningun dato leido");
  }
  // Close socket
  if(GPRS.closeSocket(GPRS.socket_ID)) USB.println("Socket cerrado");
  GPRS.data_read = NULL;
  delay(1000);
}


void signalCobertura()
{
  Serial.println("AT+CSQ",1);
  delay(500);
  while(Serial.available(1)) USB.print(char(Serial.read(1)));
}

void formatearPeticion(char* aspx, char* id, char conectado)
{
  // formato enviado a SAGA
  // GET /gf.saga.web/mote.txt?id=xxxxxxx&O=S\r\n
  sprintf(commando,"%s%s%s\?id=%s%cO=%c%c%c","GET ", SERVIDOR_SUB_URL,aspx, id, '&', conectado,'\r','\n');
  USB.println(commando);
}
void llamarSaga()
{
  if(GPRS.sendData(commando,GPRS.socket_ID)) USB.println("Datos enviados GET ");
  delay(2000);
  n=0;
  while(!n){
    n=GPRS.readData(GPRS.socket_ID,"20");
  }
  USB.print("Bytes Read: ");
  USB.println(GPRS.data_read,DEC);
  if (GPRS.data_read > 0) USB.println(GPRS.data_URL);
}

uint8_t leerdatos()
{
  char* ocupacion;
   //Waiting message
  previous=millis();
  while( (millis()-previous) < 20000 )//espero un tiempo X el mensaje
  
  {
    if( XBee.available() )
    {
      xbee802.treatData();
      XBee.println("Comienzo tratamiento datos");
     
      if( xbee802.error_RX )
      {
        XBee.println("Error al recibir mensaje");
      }
     
      else
      {
        XBee.println("Mensaje recibido");
         
         
         while(xbee802.pos>0)
         {
             XBee.println("Paquete recibido");
            
            
            //Leo direccion de quien me ha mandad el sms(MAC). Omito la direccion alta.
             while(j<4)
             {
               Mac_parking[j]=xbee802.packet_finished[xbee802.pos-1]->macSH[j];
               j++;
             }
             
             while(j<8)
             {
               Mac_parking[j]=(xbee802.packet_finished[xbee802.pos-1]->macSL[j-4]);
               devol(Mac_parking[j]);
               XBee.print(Mac_parking[j],HEX);
               j++;
             }
             
            

             XBee.print("\nMac_parkingc(bajo): ");
             XBee.println(Mac_parkingc);
             XBee.println();
             
             //Leo si esta libre o ocupado
               XBee.println("\n Dato recibido: \n");
          
              for(int f=0;f<xbee802.packet_finished[xbee802.pos-1]->data_length;f++)
              {
                 // XBee.println(xbee802.packet_finished[xbee802.pos-1]->data[f],BYTE);
                 ocupacion[f]=xbee802.packet_finished[xbee802.pos-1]->data[f];
                 XBee.print(xbee802.packet_finished[xbee802.pos-1]->data[f]);
              }
              ocupacion[xbee802.packet_finished[xbee802.pos-1]->data_length] = '\0';
             
              XBee.println(ocupacion);
             
              if(ocupacion[0]=='1')
              {
                ocupacionc='S';
              }
              else
              {
                ocupacionc='N';
              }
             XBee.println("ocupacionc");
             XBee.println(ocupacionc);
             
         
             free(xbee802.packet_finished[xbee802.pos-1]);   
             xbee802.packet_finished[xbee802.pos-1]=NULL;
             xbee802.pos--;
             return 1;
        } 
       
    }
  }
    return 0;
   
}
void devol(char caracter)
{
  
  
  sprintf(Mac_parkingc,"%s%X",Mac_parkingc, caracter);
}




The problem is that GPRS works but only when I turn off the sensor parking.If the sensor parking is On, GPRS is working well until
Quote:
if(GPRS.sendData(commando,GPRS.socket_ID)) USB.println("Datos enviados GET ");


After this sentence I have to wait 4 minutes until I can read some data. I think is because of GPRS and Xbee work together because if I write directly the data I have to send it works.

How can I solve this problem??

Also, instead of receiving the data ..I obtain "Error en la transmisión" and when I compare the data I am sending;
Quote:
if(ocupacion[0]=='1')
{
ocupacionc='S';
}
else
{
ocupacionc='N';
}

it doesnt work.
I have tried with Utils.strCmp(ocupacion,"1",1) and is the same.

Thanks a lot.


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Fri Jun 08, 2012 11:53 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Hi _maria_,

About your GPRS problem, I think it is not related to your sensor state but to the connection time, you are waiting for a way too short period in the setup (600 milliseconds), while it requieres of a much longer wait (we used to set the timeout at 90 seconds).

Regarding the reception, take into account that you defined data as a uint8_t and assigned a 1 or a 0 (unsigned integers) while in reception you are assigning it to a char and comparing it with the ASCII characters '1' and '0'.

Anyway, I'd advice you to first develop your codes handling XBee reception and GPRS transmission separately, because debugging such a cumbersome code as the resulting is a really hard task.

Regards.


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Mon Jun 18, 2012 12:59 pm 

Joined: Tue Mar 13, 2012 4:54 pm
Posts: 18
OK. I will try separately.

First without GPRS

-The code to send is:
Quote:
#define ADDRESS "0013A20040763C97"
#define Waspmote "0013A20040763C6D"
#define PARKING "0013A20040763C42"
int mac;
 packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;
 char data ='1';
 int g=0;
 
void setup()
{
  // Inits the XBee 802.15.4 library
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  
  // Powers XBee
  xbee802.ON();
  XBee.println("Modulo inicializado");
}

void loop()
{
  enviar();
  delay(2000);
}
  
  void enviar ()
{
    paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
    paq_sent->mode=UNICAST; 
    paq_sent->MY_known=0; 
    //paq_sent->packetID=0x52;
    paq_sent->opt=0; 
    xbee802.hops=0; 
    //configuro el que envia datos
    xbee802.setOriginParams(paq_sent, PARKING, MAC_TYPE); 
    //Configuro quien lo recibe.Envio libre o ocupado
    xbee802.setDestinationParams(paq_sent, Waspmote, data, MAC_TYPE, DATA_ABSOLUTE);
    
    xbee802.sendXBee(paq_sent); 
    delay(100);
    
    if( !xbee802.error_TX )
    {
      XBee.println("Sin error en la transmisión");
     
    }
    
    else
    {
          XBee.println("Error en la transmisión");
    }
    free(paq_sent);
    paq_sent=NULL;
  }
  




-And to get data:
Quote:
char commando[90];
uint8_t n=0;
uint8_t i=0;
uint8_t respuesta = 0;
long previous=0;
uint8_t j=0;
uint8_t Mac_parking[8];
uint8_t dato_leido;
 
char ocupacionc;
char* Mac_parkingc="";
packetXBee* paq_sent;


void setup(){
  
  // setup for Serial port over USB
  USB.begin();
  USB.println("USB port started...");
  
  RTC.ON();

 
  
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  xbee802.ON();
  XBee.println("\n Modulo inicializado");

}

void loop()

 
  dato_leido=leerdatos(); 
 
  if (dato_leido==1)
  {
    XBee.println("Dato leido");
    //Mac_parkingc[0]=NULL;
  }
  else
  {
    XBee.println("Ningun dato leido");
  }
  delay(1000);
}


uint8_t leerdatos()
{
  char* ocupacion;
   //Waiting message
  previous=millis();
  while( (millis()-previous) < 20000 )//espero un tiempo X el mensaje
  
  {
    if( XBee.available() )
    {
      xbee802.treatData();
      XBee.println("Comienzo tratamiento datos");
     
      if( xbee802.error_RX )
      {
        XBee.println("Error al recibir mensaje");
      }
     
      else
      {
        XBee.println("Mensaje recibido");
         
         
         while(xbee802.pos>0)
         {
             XBee.println("Paquete recibido");
            
            
             while(j<8)
             {
               Mac_parking[j]=(xbee802.packet_finished[xbee802.pos-1]->macSL[j-4]);
               devol(Mac_parking[j]);
               XBee.print(Mac_parking[j],HEX);
               j++;
             }
             

             //Utils.hex2str(Mac_parking[j],Mac_parkingc);
             XBee.print("\nMac_parkingc(bajo): ");
             XBee.println(Mac_parkingc);
             XBee.println();
             
             //Leo si esta libre o ocupado
               XBee.println("Dato recibido: \n");
          
              for(int f=0;f<xbee802.packet_finished[xbee802.pos-1]->data_length;f++)
              {
                
                 ocupacion[f]=xbee802.packet_finished[xbee802.pos-1]->data[f]; 
                 XBee.print(xbee802.packet_finished[xbee802.pos-1]->data[0]);
              }
              
              
              ocupacion[xbee802.packet_finished[xbee802.pos-1]->data_length] = '\0';
              XBee.println("---");
              XBee.println(ocupacion);
              //sprintf(ocupacionc,"%s",ocupacion);
              if(ocupacion[0]=='1')
              {
                ocupacionc='S';
              }
              else
              {
                ocupacionc='N';
              }
             XBee.println("ocupacionc");
             XBee.println(ocupacionc);
             
         
             free(xbee802.packet_finished[xbee802.pos-1]);   
             xbee802.packet_finished[xbee802.pos-1]=NULL;
             xbee802.pos--;
             return 1;
        } 
       
      }
    }
  }
    return 0;
}
void devol(char caracter)
{
  
  //XBee.println(caracter,HEX);
  sprintf(Mac_parkingc,"%s%X",Mac_parkingc, caracter);
}




I obtain always this in the sender:

Modulo inicializado
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión
~RMY ~RMY ~}3¢@v<m#}3¢@v<B49p~RMY Error en la transmisión


And in the receiver:

USB port started...

Modulo inicializado
Comienzo tratamiento datos
Mensaje recibido
Paquete recibido
000040763C42
Mac_parkingc(bajo): 000040763C42


Dato recibido:

44---
99SI RVA—!¡‰½!
ocupacionc
N
Dato leido


The problems are:

1. I am sending a char data = '1' and when I read the data received is not this. How can I solve this?

2.Altough I receive a packet once, I obtain "Error en la transmision" always.

3. When "Dato leido" appears the receiver doesnt do anything more.

Thanks!


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Mon Jun 18, 2012 5:34 pm 

Joined: Tue Mar 13, 2012 4:54 pm
Posts: 18
Sorry! I was wrong in the last post.

As you said before I have tried the different codes separately.

In the sender, always:

Quote:
#define ADDRESS "0013A20040763C97"
#define Waspmote "0013A20040763C6D"
#define PARKING "0013A20040763C42"
int mac;
 packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;
 char* data="1";

 int g=0;
  
// uint8_t  PANID[2]={0x12,0x34};
 
void setup()
{
  // Inits the XBee 802.15.4 library
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  
  // Powers XBee
  xbee802.ON();
  XBee.println("Modulo inicializado");
}

void loop()
{
  // Set params to send
  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
  paq_sent->mode=UNICAST;
  paq_sent->MY_known=0;
  //paq_sent->packetID=0x52;
  paq_sent->opt=0; 
  xbee802.hops=0;
  xbee802.setOriginParams(paq_sent,PARKING , MAC_TYPE);
  xbee802.setDestinationParams(paq_sent,Waspmote , data, MAC_TYPE, DATA_ABSOLUTE);
  xbee802.sendXBee(paq_sent);
  
  if( xbee802.error_TX )
  {
    XBee.println("Error en la transmisión");
  }
  else
  {
  XBee.println("Sin error en la transmisión");
  }
  free(paq_sent);
  paq_sent=NULL;
  
  // Waiting the answer

  delay(1000);
}




The reciever:
Quote:
char commando[90];
uint8_t n=0;
uint8_t i=0;
uint8_t respuesta = 0;
long previous=0;
uint8_t j=0;
uint8_t Mac_parking[8];
uint8_t dato_leido;
 
char ocupacionc;
char* Mac_parkingc="";
packetXBee* paq_sent;


void setup()
{
  
  // setup for Serial port over USB
  USB.begin();
  USB.println("USB port started...");
  
  RTC.ON();

 
  
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  xbee802.ON();
  XBee.println("\n Modulo inicializado");

}

void loop()

 
  dato_leido=leerdatos(); 
 
  if (dato_leido==1)
  {
    XBee.println("Dato leido");
    //Mac_parkingc[0]=NULL;
  }
  else
  {
    XBee.println("Ningun dato leido");
  }
  delay(1000);
}


uint8_t leerdatos()
{

   //Waiting message
  previous=millis();
  while( (millis()-previous) < 20000 )//espero un tiempo X el mensaje
  
  {
    if( XBee.available() )
    {
      xbee802.treatData();
      XBee.println("Comienzo tratamiento datos");
     
      if( xbee802.error_RX )
      {
        XBee.println("Error al recibir mensaje");
      }
     
      else
      {
        XBee.println("Mensaje recibido");
         
         
         while(xbee802.pos>0)
         {
             XBee.println("Paquete recibido");
            
            
             while(j<8)
             {
               Mac_parking[j]=(xbee802.packet_finished[xbee802.pos-1]->macSL[j-4]);
               devol(Mac_parking[j]);
               j++;
             }
             

             //Utils.hex2str(Mac_parking[j],Mac_parkingc);
             XBee.print("\nMac_parkingc(bajo): ");
             XBee.println(Mac_parkingc);
         
             //Leo si esta libre o ocupado
       
              if(xbee802.packet_finished[xbee802.pos-1]->data[0]=='1')
              {
                ocupacionc='S';
              }
              else
              {
                ocupacionc='N';
              }
             XBee.println("ocupacionc");
             XBee.println(ocupacionc);
             
             free(paq_sent);
             paq_sent=NULL;
             free(xbee802.packet_finished[xbee802.pos-1]);   
             xbee802.packet_finished[xbee802.pos-1]=NULL;
             xbee802.pos--;
             return 1;
        } 
       
      }
    }
  }
    return 0;
}
void devol(char caracter)
{
  
  //XBee.println(caracter,HEX);
  sprintf(Mac_parkingc,"%s%X",Mac_parkingc, caracter);
}





I recieve all data properly and the programm run quick.

And when I work with GPRS:
Quote:
#define DEBUG_PORT  
uint8_t tiempoLimite = 3;
uint8_t timeout;

#define Waspmote "0013A20040763C6D"
#define SERVIDOR_IP   "extranet.grupoforo.com"
#define SERVIDOR_SUB_URL  "/gf.saga.web/"
#define SERVIDOR_PUERTO   "90"

char commando[90];
uint8_t n=0;
uint8_t i=0;
uint8_t respuesta = 0;
long previous=0;
uint8_t j=0;
uint8_t Mac_parking[8];
uint8_t dato_leido=1;
 
char ocupacionc='0';
char* Mac_parkingc="1234567";
packetXBee* paq_sent;


void setup(){
  
  // setup for Serial port over USB
  USB.begin();
  USB.println("USB port started...");
  
  RTC.ON();

  // setup for GPRS serial port
  GPRS.ON();
  USB.println("GPRS module ready...");
  
  // waiting while GPRS connects to the network
   while((timeout<MAX_TRIES)&&(!GPRS.check()))
   {
     USB.print("timeout = ");
     USB.println(timeout,DEC);
     timeout++;
     delay(200);
  }
  USB.println("GPRS connected to the network");
  
  // configure SMS and Incoming Calls
  if(GPRS.setInfoIncomingCall()) USB.println("Info Incoming Call OK");
  if(GPRS.setInfoIncomingSMS()) USB.println("Info Incoming SMS OK");
  if(GPRS.setTextModeSMS()) USB.println("Text Mode SMS OK");
  
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
  xbee802.ON();
  XBee.println("\n Modulo inicializado");
  if(GPRS.configureGPRS()) USB.println("Configured OK");
}

void loop()
{  
  // Configure GPRS Connection
  respuesta = GPRS.createSocket(SERVIDOR_IP, SERVIDOR_PUERTO, GPRS_CLIENT);
  USB.print("Respuesta crear socket: ");
  USB.println(respuesta, DEC);
  
  if(respuesta == 1)
  {
    USB.println("Socket Opened OK");
    USB.print("Session Number: ");
    while( GPRS.socket_ID[i]!='\r' )
    {
      USB.print(GPRS.socket_ID[i]-'0',DEC);
      i++;
    }
    i=0;
    USB.println();
  }
  else
  {
    USB.println("Error opening the socket");
    USB.print("Valor Error: ");
    USB.println(GPRS.flag, DEC);
  }
  delay(500);
  
  
 
  if (dato_leido==1)
  {
  formatearPeticion("mote.txt",Mac_parkingc,ocupacionc);
  signalCobertura();
  llamarSaga();
  //Mac_parkingc[0]=NULL;
  }
  else
  {
    XBee.println("Ningun dato leido");
  }
  // Close socket
  if(GPRS.closeSocket(GPRS.socket_ID)) USB.println("Socket cerrado");
  GPRS.data_read = NULL;
  delay(1000);
}


void signalCobertura()
{
  Serial.println("AT+CSQ",1);
  delay(500);
  while(Serial.available(1)) USB.print(char(Serial.read(1)));
}

void formatearPeticion(char* aspx, char* id, char conectado)
{
  // formato enviado a SAGA
  // GET /gf.saga.web/mote.txt?id=xxxxxxx&O=S\r\n
  sprintf(commando,"%s%s%s\?id=%s%cO=%c%c%c","GET ", SERVIDOR_SUB_URL,aspx, id, '&', conectado,'\r','\n');
  USB.println(commando);
}
void llamarSaga()
{
  if(GPRS.sendData(commando,GPRS.socket_ID)) USB.println("Datos enviados GET ");
  delay(2000);
  n=0;
  while(!n){
    n=GPRS.readData(GPRS.socket_ID,"20");
  }
  USB.print("Bytes Read: ");
  USB.println(GPRS.data_read,DEC);
  if (GPRS.data_read > 0) USB.println(GPRS.data_URL);
}




I obtain

USB port started...
GPRS module ready...
GPRS connected to the network
Info Incoming Call OK
Info Incoming SMS OK
†ext Mode SMS OK
Modulo inicializado
Configured OK
Respuesta crear socket: 1
Socket Opened OK
Session Number: 1
GET /gf.saga.web/mote.txt?id=1234567&O=0


AT+CSQ

+CSQ: 17,99

OK
Datos enviados GET
Bytes Read: 2
30
Socket cerrado



That means that it works properly.

The problem is when I mix GPRS with receiver programm. It works well until it try to llamarSaga.

USB port started...
GPRS module ready...
GPRS connected to the network
Info Incoming Call OK
Info Incoming SMS OK
†ext Mode SMS OK
Modulo inicializado
Configured OK
Respuesta crear socket: 1
Socket Opened OK
Session Number: 1
Comienzo tratamiento datos
Error al recibir mensaje
Comienzo tratamiento datos
Mensaje recibido
Paquete recibido

Mac_parkingc(bajo): 000040763C42
ocupacionc
S
Dato leido
GET /gf.saga.web/mote.txt?id=000040763C42&O=S


AT+CSQ

+CSQ: 18,99

OK


As you can see the programm doesnt run more.

Another problem is that altough I receive the data, I obtain "Error en la transmision".

Please let me know how to solve it.


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Tue Jun 19, 2012 8:57 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Hi _maria_,

having your codes working separately means that there is no problem with your hardware, so it is a software issue you should research deeper.

As you will know, we are Wireless Sensor Networks hardware manufacturers. On addition to that, we provide with a complete software system to control our hardware and comprehensive documentation. We are committed to support the clients in the development process through the forum, but we cannot implement the final solution for each project.

Some clients just do not want to implement the software for their projects and prefer us to do it for them, or maybe they find it complicated. In these cases we offer special services like:
1. a number of one-to-one support hours with one engineer on our online e-learning platform. You can have direct line with one of our experts and if you like we can access your desktop in a remote way.
2a. general training courses which are a great introduction to our systems.
2b. specific training course, focusing on the features and modules you need to handle.
3. customized engineering: you can let us know the list of tasks your system needs to work out, and our R&D Dept. can develop all the project for you.


Please visit this area regarding training: http://www.libelium.com/products/training
and this one about custom engineering: http://www.libelium.com/products/services

Do not hesitate to ask any questions you may have.

Best regards


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Wed Jun 20, 2012 6:53 pm 

Joined: Tue Mar 13, 2012 4:54 pm
Posts: 18
Hello.

As you said, I've researched deeper and always the concluison is the same, xbee and gprs can not work together.

When I use both together, I turn on the GPRS only when I want to send some data. After is off.
Memory decreases a lot when I have to read from a packet structure created by the sender. ( I obtain values like 800 or less).

However when I dont read a packet structure, the program works perfect.

Is there a possibility to delete memory? If not only turning off the GPRS or Xbee module is not going to solve my problem. I need something to delete memory but not
Code:
             free(paq_sent);
             paq_sent=NULL;
             free(xbee802.packet_finished[xbee802.pos-1]);   
             xbee802.packet_finished[xbee802.pos-1]=NULL;
             xbee802.pos--;

or calloc funtion to create a variable, as I read in other posts because I have already used and I obtain the same values that I mentioned before.

Thank you.


Top
 Profile  
 
 Post subject: Re: Comunication between Xbee with GPRS
PostPosted: Thu Jun 21, 2012 9:01 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Hi _maria_,

if memory is not under control, the best option to delete it is to use the function PWR.reboot() to reset the mote when if falls below a minimum threshold.

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 7 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:


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