Communication in Xbee mesh in API mode

Hi. How to implement communication in a Xbee mesh network in API mode. I am trying to understand Arduino + Xbee communication in a mesh network.

I am starting to learn arduino + Xbee and this time and I just want to know how to establish communication between units in a mesh network. The data is not relevant. I just want to know how to send and receive data from coordinator to router or from router to coordinator. Is the the following exmaple OK? If not, where am I wrong. Similar code is on both units.

#include <SoftwareSerial.h>

SoftwareSerial Xbee( 1, 0 );

void setup( ) {
  Serial.begin( 9600 );
  Xbee.begin( 9600 );

  Serial.println( "Ready!" );
  
  delay( 500 );

  Xbee.write( "XBee 2 says it's ready!" );
  
}

void loop( ) {
//  if( Serial.available( ) ) {
//    /* If data comes in from serial monitor, send it out to XBee */
//    xbee1.write( Serial.read( ) );
//  }
Xbee.write("0x02", HEX);
  if( Xbee.available( ) ) {
    /* If data comes in from XBee, send it out to serial monitor */
    Serial.println("unit2");
    Serial.println(Xbee.read(), HEX);
    Xbee.write(Xbee.read());
  }

  delay( 2000 );
}

Is the the following exmaple OK?

No.

First, you can NOT do SoftwareSerial on the hardware serial pins while doing hardware serial on them.

Second, if the XBees are in API mode, you need to send complete frames. The XBee library manages all the packet construction and checksum calculation for you, AND handles sending the packet to the correct address.

Thank you for your quick response. I will use the XBEE library then (I suppose you mean the Xbee.h library).

First, you can NOT do SoftwareSerial on the hardware serial pins while doing hardware serial on them.

Can you please explain this a bit more? I have almost no arduino or embedded programming experience and I don want to make a mistake like this again. I am a web developer and I am trying to make a web app that will communicate with an arduino mesh network (polling requests, receiving data from the coordinator, etc.).

Thanks in forward.

Can you please explain this a bit more?

What is there to explain? When you want to create an instance of a class that uses n pins, the underlying assumption is ALWAYS that the n pins are otherwise unused. You have the obligation to understand what pins are already used before you assume that you can use them for you class instance.