Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Communication problem between two Waspomte
PostPosted: Fri Jan 13, 2012 7:53 pm 

Joined: Thu Jan 12, 2012 12:09 pm
Posts: 7
Hi libelium-dev

I used the Waspmote XBee 802.15.4, it work perfectly when i send message from mote 1 to GW, but when I send the message from mote1 to mote2, mote2 received nothing. The sending code and receiving code is as following.
In the code, I set panid and channel in function createnetwork(). I have read "Read Me First" posted on the website, it said that “6. All Waspmotes' XBees are set in mode AP = 2 (API mode).” I think the problem maybe is relevant to this. I do not know how to set “AP = 2” in the code, Is X-CTU the only way to set “AP = 2”? But X-CTU does not contain my xbee version.

sending code:
Code:
uint8_t  PANID[2]={0x12,0x34};
char*  KEY="WaspmoteKey";
packetXBee* paq_sent;
int8_t state=0;
long previous=0;
char*  data="Test Message!";
int g=0;

//int i;

void setup()
{
  // Inits the XBee 802.15.4 library
  xbee802.init(XBEE_802_15_4,FREQ2_4G,NORMAL);
 
  // Powers XBee
  xbee802.ON();
  createnetwork();
}

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, "0013A200406918A6", MAC_TYPE);
  xbee802.setDestinationParams(paq_sent, "0013A200406918A2", data, MAC_TYPE, DATA_ABSOLUTE);
  xbee802.sendXBee(paq_sent);
  if( !xbee802.error_TX )
  {
    XBee.println("ok");
  }
  free(paq_sent);
  paq_sent=NULL;
 
  // Waiting the answer
  previous=millis();
  while( (millis()-previous) < 20000 )
  {
    if( XBee.available() )
    {
      xbee802.treatData();
      if( !xbee802.error_RX )
      {
        // Writing the parameters of the packet received
        while(xbee802.pos>0)
        {
          XBee.print("Network Address Source: ");
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->naS[0],HEX);
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->naS[1],HEX);
          XBee.println("");
          XBee.print("MAC Address Source: ");         
          for(int b=0;b<4;b++)
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->macSH[b],HEX);
          }
          for(int c=0;c<4;c++)
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->macSL[c],HEX);
          }
          XBee.println("");
          XBee.print("Network Address Origin: ");         
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->naO[0],HEX);
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->naO[1],HEX);
          XBee.println("");
          XBee.print("MAC Address Origin: ");         
          for(int d=0;d<4;d++)
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->macOH[d],HEX);
          }
          for(int e=0;e<4;e++)
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->macOL[e],HEX);
          }
          XBee.println("");
          XBee.print("RSSI: ");                   
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->RSSI,HEX);
          XBee.println("");         
          XBee.print("16B(0) or 64B(1): ");                   
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->mode,HEX);
          XBee.println("");
          XBee.print("Data: ");                   
          for(int f=0;f<xbee802.packet_finished[xbee802.pos-1]->data_length;f++)
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->data[f],BYTE);
          }
          XBee.println("");
          XBee.print("PacketID: ");                   
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->packetID,HEX);
          XBee.println("");     
          XBee.print("Type Source ID: ");                             
          XBee.print(xbee802.packet_finished[xbee802.pos-1]->typeSourceID,HEX);
          XBee.println("");     
          XBee.print("Network Identifier Origin: ");         
          while( xbee802.packet_finished[xbee802.pos-1]->niO[g]!='#' )
          {
            XBee.print(xbee802.packet_finished[xbee802.pos-1]->niO[g],BYTE);
            g++;
          }
          g=0;
          XBee.println(""); 
          free(xbee802.packet_finished[xbee802.pos-1]);
          xbee802.packet_finished[xbee802.pos-1]=NULL;
          xbee802.pos--;
        }
        previous=millis();
      }
    }
  }

  delay(1000);
}
  // Chosing a channel : channel 0x0D
  void createnetwork()
  {
  xbee802.setChannel(0x0D);
  if( !xbee802.error_AT ) XBee.println("Channel set OK");
  else XBee.println("Error while changing channel");
 
  // Chosing a PANID : PANID=0x1234
  xbee802.setPAN(PANID);
  if( !xbee802.error_AT ) XBee.println("PANID set OK");
  else XBee.println("Error while changing PANID"); 
 
  // Enabling security : KEY="WaspmoteKey"
  xbee802.encryptionMode(1);
  if( !xbee802.error_AT ) XBee.println("Security enabled");
  else XBee.println("Error while enabling security"); 
 
  xbee802.setLinkKey(KEY);
  if( !xbee802.error_AT ) XBee.println("Key set OK");
  else XBee.println("Error while setting Key"); 
 
  // Keep values
  xbee802.writeValues();
  if( !xbee802.error_AT ) XBee.println("Changes stored OK");
  else XBee.println("Error while storing values"); 
 
  delay(3000);
  }



receiving code is almost the same to sending code ,the it does not contains the following node in function loop():
Code:
// 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, "0013A200406918A6", MAC_TYPE);
  xbee802.setDestinationParams(paq_sent, "0013A200406918A2", data, MAC_TYPE, DATA_ABSOLUTE);
  xbee802.sendXBee(paq_sent);
  if( !xbee802.error_TX )
  {
    XBee.println("ok");
  }
  free(paq_sent);
  paq_sent=NULL;
 


Best regards
fengye


Top
 Profile  
 
 Post subject: Re: Communication problem between two Waspomte
PostPosted: Mon Jan 16, 2012 12:09 pm 

Joined: Thu Jan 12, 2012 12:09 pm
Posts: 7
Hi libelium-dev
I am new to use Waspomte and stuck at this point. I have read relevant topic on the forum and did not find some solutions.Could you give me some guide?
Looking forward to yout reply.
Best regards
fengye


Top
 Profile  
 
 Post subject: Re: Communication problem between two Waspomte
PostPosted: Mon Jan 16, 2012 5:50 pm 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7440
Dear fengyebxh,

Before going deep into your code, what happens if you try with Sending & receiving example for 802.15.4?

Please try uploading on one mote the Sending &Receiving example and into another Sending &receivingB.

Please check if this works and if so you can start from here. If not we will review you code deeply.

Kind regards.


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