Post a new topicPost a reply Page 1 of 2   [ 15 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: gateway dropping packets
PostPosted: Mon Sep 12, 2011 10:52 pm 

Joined: Mon Nov 22, 2010 4:59 pm
Posts: 19
Hi,

I have a simple program which send data over ZigBee network.
The program sets an alarm every 3 seconds and after waking up sends a test message to the gateway, before sending the data it checks if its associated with the network.

The problem I am facing is that about 50% of the time the gateway is not receiving the "test message" even though the waspmote reports that the packet is sent i.e.

Code:
if( !xbeeZB.error_TX )
  {
    XBee.println("ok");
  }

is always true- which means that the message has been sent.
Waspmote never fails to send the message but gateway receives the message less than 50% of the time. Distance is not a problem since both gateway and the mote are connected to the same machine and are just 1 feet apart.

Here is the code
Code:
packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;

 char*  data="Test nessage";
 
void setup()
{
  USB.begin();
  RTC.ON();
  // Inits the XBee ZigBee library
    xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);
   xbeeZB.ON();
  //xbeeZB.setAPSencryption(XBEE_ON);
 
  delay(2000);
}

void loop(){
   RTC.setAlarm1(0, 0, 0,3,RTC_OFFSET,RTC_ALM1_MODE3); // Sets Alarm1
 
 //go to sleep till the next alarm
 PWR.sleep(ALL_OFF);
 RTC.ON();
 USB.begin();
 
 //Alarm triggered
 if( intFlag & RTC_INT )
 {
    intFlag &= ~(RTC_INT); // Clear flag
      Utils.blinkLEDs(500); // Blinking LEDs
    Utils.blinkLEDs(500);
   send_data();
 }   
}

void send_data()
{
  USB.println("In send data");
 // Powers XBee
  xbeeZB.ON();
  delay(2000);
 
   do
  {
    XBee.print("waiting for association ");
    XBee.println(xbeeZB.associationIndication,HEX);
    delay(1000);
    xbeeZB.getAssociationIndication();
  }while(xbeeZB.associationIndication!=0);
 
 
  // 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;
  xbeeZB.hops=0;
  xbeeZB.setOriginParams(paq_sent, "5678", MY_TYPE);
  xbeeZB.setDestinationParams(paq_sent, "0013A20040690220", data, MAC_TYPE,DATA_ABSOLUTE);
  xbeeZB.sendXBee(paq_sent);
  if( !xbeeZB.error_TX )
  {
    XBee.println("ok");
  }
  free(paq_sent);
  paq_sent=NULL;
   
}


Any ideas?

Amit


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Wed Sep 14, 2011 9:06 am 

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

What serial port are you using in order to see gateway's output? Hyperterminal? Cutecom?

Regards


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Wed Sep 14, 2011 3:53 pm 

Joined: Mon Nov 22, 2010 4:59 pm
Posts: 19
I am using X-CTU. Another thing, if I increase the delay in send_data() just after xbeeZB.ON() from 2000 to 20000, I receive all the packets.

Thanks
Amit


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Fri Sep 16, 2011 9:03 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7479
Hi Amit,
asingh66 wrote:
I am using X-CTU. Another thing, if I increase the delay in send_data() just after xbeeZB.ON() from 2000 to 20000, I receive all the packets.

Thanks
Amit
When you start using XBee-ZB there is an initial network setting that must be done. So, this is the reason you have to wait some time before using it.

Regards


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Fri Sep 16, 2011 11:21 pm 

Joined: Mon Nov 22, 2010 4:59 pm
Posts: 19
In the code I am waiting for the mote to be associated with a network before it starts sending messages:

Code:
 do
  {
    XBee.print("waiting for association ");
    XBee.println(xbeeZB.associationIndication,HEX);
    delay(1000);
    xbeeZB.getAssociationIndication();
  }while(xbeeZB.associationIndication!=0);



Only when it get connected to the network, it sends the data. So what is the reason for me to have any delay. Also, Can you tell me what is the optimal time for delay?Is there a number you recommend?


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Wed Sep 21, 2011 9:48 am 

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

This function jus texecutes an AT command in order to know if the node is associated to the network, so it should work as you told us. A colleague of mine found this issue too, so we are going to check this function again. Please, introduce some delay by now, in order to wait the node to be connected to the network until we give you any other answer.

Best regards


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Tue Mar 20, 2012 6:21 pm 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
I am trying to use the getAssociationIndication() function with a gases sensor board as follows:

Quote:
long previous=0;

packetXBee* paq_sent; 
int8_t state=0; 

char A[10]; // Temperature
char B[10]; // Barometric Pressure
char C[10]; // Carbon Monoxide
char D[10]; // Carbon Dioxide
char E[10]; // Oxygen
char F[10]; // Ozone
char G[10]; // Air Contaminants Gases I
char H[10]; // Air Contaminants Gases II
char I[10]; // Waspmote Battery
char aux[200];
char* macLow=" ";

// Resistor (1 - 100 KOhms) and Gain (1 - 101)
#define CO_GAIN 1
#define CO_RESISTOR 50
#define CO2_GAIN 1
#define O2_GAIN 100
#define O3_GAIN 1
#define O3_RESISTOR 10
#define ACS1_GAIN 1
#define ACS1_RESISTOR 10
#define ACS2_GAIN 1
#define ACS2_RESISTOR 10
#define key_access "WaspmoteKey"

float value_T=0.0;
float value_Air=0.0;
float value_CO=0.0;
float value_CO2=0.0;
float value_O2=0.0;
float value_O3=0.0;
float value_ACS1=0.0;
float value_ACS2=0.0;
float value=0;

uint8_t batt;
uint8_t counter=0;

void setup()
{
  // Store key access in EEPROM
  for(int i=0;i<8;i++){
    Utils.writeEEPROM(i+107,key_access[i]);
  }
  XBee.setMode(XBEE_ON);
  XBee.begin(9600);
  delay(1000);
  XBee.print("+++");
  delay(2000);
  XBee.println("ATBD5,AP2,WR,CN");
  delay(150);
  
  xbeeZB.writeValues();
  delay(500);
    
  XBee.setMode(XBEE_OFF);
  XBee.close();

  Utils.setLED(LED0, LED_ON);
  Utils.setLED(LED1, LED_ON);
  delay(5000);
  Utils.setLED(LED0, LED_OFF);
  Utils.setLED(LED1, LED_OFF);
  for (int i=0;i<24;i++){
    Utils.blinkLEDs(125);
  }
  // Inits the XBee XSC library
  xbeeZB.init(ZIGBEE,FREQ2_4G,NORMAL);

  // Powers XBee
  xbeeZB.ON();
  delay(100000);
  
  // Get the XBee MAC address
  int counter = 0;
  while(xbeeZB.getOwnMac()==1&&counter<4){
    xbeeZB.getOwnMac();
    counter++;
  }
  Utils.hex2str(xbeeZB.sourceMacLow,macLow,4);
 
  
}

void loop()
{
  
   SensorGas.setBoardMode(SENS_ON);
   delay(50);
   RTC.ON();
   delay(500);
   XBee.setMode(XBEE_OFF);
   delay(500);
   PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);
   if( intFlag & RTC_INT )
   {
      Utils.blinkLEDs(1000);
      Utils.blinkLEDs(1000);
      Utils.blinkLEDs(1000);
      intFlag &= ~(RTC_INT);      
   }   
   
    
   getData();  
   sendData(); 
}

// gets values from sensors
void getData()
{
  SensorGas.setBoardMode(SENS_ON);
  RTC.ON();
  delay(100);

  value=0;

  for(int g=0;g<5;g++){
    value_T = SensorGas.readValue(SENS_TEMPERATURE);
    value_T = (value_T - 0.5) * 100;
    value = value_T + value;

    delay(100);
  }
  value = value/5;
  Utils.float2String(value,A,1); 



// Waspmote Battery  
  batt = PWR.getBatteryLevel();
  Utils.long2array(batt,I);
}  

// sends a message
void sendData()
{
  

  sprintf(aux,",%s,%s,%s,",macLow,A,I);
  xbeeZB.ON();
  delay(10000);
  
  do
  {
    XBee.print("waiting for association ");
    XBee.println(xbeeZB.associationIndication,HEX);
    delay(1000);
    xbeeZB.getAssociationIndication();
  }
  while(xbeeZB.associationIndication!=0);





  paq_sent=(packetXBee*) calloc(1,sizeof(packetXBee)); 
  paq_sent->mode=UNICAST; 
  paq_sent->MY_known=0; 
  paq_sent->packetID=0x52; 
  paq_sent->opt=0; 
  xbeeZB.hops=0; 
  xbeeZB.setOriginParams(paq_sent, "0013A20040714C00", MAC_TYPE);
  xbeeZB.setDestinationParams(paq_sent, "0013A200406B094A", aux, MAC_TYPE, DATA_ABSOLUTE);
  xbeeZB.sendXBee(paq_sent);
  
   while( counter<1 ){
   state=xbeeZB.sendXBee(paq_sent);
       counter++;
     }
     counter=0;
  if(!state)
  {
    XBee.println("OK");
  }
  
  free(paq_sent);
  paq_sent = NULL;

  delay(1000);

  
}





So if I set the sleeping time to 10 seconds:

Code:
PWR.deepSleep("00:00:00:10",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);


I get the following data over wireless on the coordinator:

Quote:
38,~ • }3¢ @qL d5Bd5 }3¢ @qL Áz
16,~ • }3¢ @qL ÿÂB
22,ÿÂ }3¢ @qL Á*
48,~ * }3¢ @qL ÿÂAR# }3¢ @qL ,00000000,19.8,55,(
48,~ * }3¢ @qL ÿÂAR# }3¢ @qL ,00000000,19.8,55,(
48,~ * }3¢ @qL YsAR# }3¢ @qL ,00000000,19.6,55,
48,~ * }3¢ @qL YsAR# }3¢ @qL ,00000000,19.6,55,
48,~ * }3¢ @qL £GAR# }3¢ @qL ,00000000,19.2,55,
48,~ * }3¢ @qL £GAR# }3¢ @qL ,00000000,19.2,55,
48,~ * }3¢ @qL ­AR# }3¢ @qL ,00000000,19.0,55,$
48,~ * }3¢ @qL ­AR# }3¢ @qL ,00000000,19.0,55,$
48,~ * }3¢ @qL -×AR# }3¢ @qL ,00000000,19.0,55,í
48,~ * }3¢ @qL -×AR# }3¢ @qL ,00000000,19.0,55,í
48,~ * }3¢ @qL §TAR# }3¢ @qL ,00000000,19.0,55,ö
48,~ * }3¢ @qL §TAR# }3¢ @qL ,00000000,19.0,55,ö
48,~ * }3¢ @qL TAR# }3¢ @qL ,00000000,19.1,54,š
48,~ * }3¢ @qL TAR# }3¢ @qL ,00000000,19.1,54,š
48,~ * }3¢ @qL ã¿AR# }3¢ @qL ,00000000,19.8,55,G
48,~ * }3¢ @qL ã¿AR# }3¢ @qL ,00000000,19.8,55,G
48,~ * }3¢ @qL ¤AR# }3¢ @qL ,00000000,19.0,55,9
48,~ * }3¢ @qL ¤AR# }3¢ @qL ,00000000,19.0,55,9


Which is what I would expect (Temperature around 19°C and Battery capacity around 55%).

The problem is when I try to make the sleeping time longer (since this is what I would need to run the gases board for a prolonged period) and I set a longer sleeping time of lets say 5 minutes:

Quote:
PWR.deepSleep("00:00:05:00",RTC_OFFSET,RTC_ALM1_MODE2,ALL_OFF);


... I do no longer get any data on the coordinator! Why this?

Another question would be why is the mac low adress zeroes only?


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Tue Mar 27, 2012 1:21 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7479
Hi Wirthm_U,

It sounds pretty weird. Could you repeat your tests with the five minutes delay with the mote connected to the USB, so we can check if the problem is in the RTC not awaking the mote or in the radio communication?

Regards.


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Wed Mar 28, 2012 11:11 am 

Joined: Tue Jan 31, 2012 3:57 pm
Posts: 36
Five minute interval works when connected via USB.


Top
 Profile  
 
 Post subject: Re: gateway dropping packets
PostPosted: Fri Mar 30, 2012 10:26 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7479
Hi Wirthm_U,

you mean that when you connected the mote to the USB and configure a five minutes sleep time you are receiving the data in your gateway without any problem?

That's weird again. Could you retry your initial test with the battery fully charged, to check if the problem was in the mote hanging owing to a powering issue?

Regards.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 15 posts ]
Go to page 1, 2  Next


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