Post a new topicPost a reply Page 1 of 1   [ 4 posts ]
Author Message
 Post subject: DigiMesh networking - UNICAST transmission problem
PostPosted: Wed Jun 13, 2012 12:45 pm 

Joined: Mon May 21, 2012 10:07 am
Posts: 13
Hello,
I am trying to send a test message from one module to another with these simple codes (Digimesh network, nodes have same PAN and same Channel):


Sender:

Code:
packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;
 char*  data="Test message!";
 
 
void setup()
{
  // Inits the XBee DigiMesh library
  xbeeDM.init(DIGIMESH,FREQ2_4G,PRO);
 
  // Powers XBee
  xbeeDM.ON();
 
}

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;
//  xbeeDM.hops=0;
  xbeeDM.setOriginParams(paq_sent, "XXXXXXXXXXXXXXX", MAC_TYPE); //XXXX... is the MAC of the sender
  xbeeDM.setDestinationParams(paq_sent, "YYYYYYYYYYYYYYY", data, MAC_TYPE, DATA_ABSOLUTE); //YYY... is the MAC of the receiver

  XBee.println("Try to send message");

  xbeeDM.sendXBee(paq_sent);

  if( !xbeeDM.error_TX )
  {
    XBee.println("OK. Message sent");
  }
else
  {
    XBee.println("Message is not sent");
  }

  free(paq_sent);
  paq_sent=NULL;
 
  delay(5000);
}




Receiver:

Code:
packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;
 int count=0;
void setup()
{
  // Inits the XBee DigiMesh library
  xbeeDM.init(DIGIMESH,FREQ2_4G,PRO);
 
  // Powers XBee
  xbeeDM.ON();
}

void loop()
{
 
  // Waiting message
  previous=millis();
  while( (millis()-previous) < 20000 )
  {
    if( XBee.available() )
    {
      xbeeDM.treatData();
      if( !xbeeDM.error_RX )
      {
         // Sending answer back
         while(xbeeDM.pos>0)
         {
             XBee.println("Message received from (MAC address): ");
         
          for(int b=0;b<4;b++)
          {
            XBee.print(xbeeDM.packet_finished[xbeeDM.pos-1]->macSH[b],HEX);
          }
          for(int c=0;c<4;c++)
          {
            XBee.print(xbeeDM.packet_finished[xbeeDM.pos-1]->macSL[c],HEX);
          }
         
         
           XBee.print("MAC Address Origin: ");         
          for(int d=0;d<4;d++)
          {
            XBee.print(xbeeDM.packet_finished[xbeeDM.pos-1]->macOH[d],HEX);
          }
          for(int e=0;e<4;e++)
          {
            XBee.print(xbeeDM.packet_finished[xbeeDM.pos-1]->macOL[e],HEX);
          }
         
           free(xbeeDM.packet_finished[xbeeDM.pos-1]);   
           xbeeDM.packet_finished[xbeeDM.pos-1]=NULL;
           xbeeDM.pos--;
        }
      }
    }
  }

  delay(5000);
}





The problem is that when I use the BROADCAST mode, the transmission is OK, while in UNICAST mode there are transmission problems (only few packets are received ..). Why this behavior? Thank you!


Top
 Profile  
 
 Post subject: Re: DigiMesh networking - UNICAST transmission problem
PostPosted: Wed Jun 13, 2012 2:28 pm 

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

Did you follow all steps of Waspmote checklist?

It is just to be sure you have battery charged and connected and those things.

Let us know before going further.

Regards.


Top
 Profile  
 
 Post subject: Re: DigiMesh networking - UNICAST transmission problem
PostPosted: Wed Jun 13, 2012 4:53 pm 

Joined: Mon May 21, 2012 10:07 am
Posts: 13
Yes, I followed all the steps.
I insert in my code a scanNetwork() function and, after this, also the UNICAST transmission is OK. This is the code:

Code:
packetXBee* paq_sent;
 int8_t state=0;
 long previous=0;
 char*  data="Test message!";
 
 
void setup()
{
  // Inits the XBee DigiMesh library
  xbeeDM.init(DIGIMESH,FREQ2_4G,PRO);
 
  // Powers XBee
  xbeeDM.ON();
  xbeeDM.scanNetwork(); // Discovery nodes
 
}

void loop()
{


while(xbeeDM.totalScannedBrothers>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;
//  xbeeDM.hops=0;
  xbeeDM.setOriginParams(paq_sent, "XXXXXXXXXXXXXXX", MAC_TYPE); //XXXX... is the MAC of the sender
  xbeeDM.setDestinationParams(paq_sent, "YYYYYYYYYYYYYYY", data, MAC_TYPE, DATA_ABSOLUTE); //YYY... is the MAC of the receiver

  XBee.println("Try to send message");

  xbeeDM.sendXBee(paq_sent);

  if( !xbeeDM.error_TX )
  {
    XBee.println("OK. Message sent");
  }
else
  {
    XBee.println("Message is not sent");
  }

  free(paq_sent);
  paq_sent=NULL;
 
  delay(5000);

}

 xbeeDM.scanNetwork(); // Discovery nodes

}


..but I don't know if it is right to do so.

I have another doubt about the digimesh network: if I have two nodes (A&B) that can communicate between them only through another intermediate node (C), this last node should automatically forward the message that A will send to B (in UNICAST mode). Is it right?


Top
 Profile  
 
 Post subject: Re: DigiMesh networking - UNICAST transmission problem
PostPosted: Thu Jun 14, 2012 9:57 am 

Joined: Mon Sep 28, 2009 1:06 pm
Posts: 7479
marek87
marek87 wrote:
I have another doubt about the digimesh network: if I have two nodes (A&B) that can communicate between them only through another intermediate node (C), this last node should automatically forward the message that A will send to B (in UNICAST mode). Is it right?
Yes, it will do it automatically.

Let us know if you have more questions.

Regards.


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