How to know the xbees are not connected?

Hi, I want to transmit data to a xbee by xbee&arduino.
But how to know the connection does not establish until it does?

If both sides have an arduino , can it tell connection or not by sleep mode or something?

Thanks.

But how to know the connection does not establish until it does?

Point to point? Or mesh network?

In a point to point scenario, you know if a connection exists if the packet is acknowledged. If it isn't, no connection exists.

In a mesh network, the same answer applies, but takes longer to determine as all the nodes on the network are trying to find the destination node, and passing the packet around in the hopes that some node will be able to pass the packet to the destination node.

If you have a mesh network, you can ask each XBee for a list of nodes it knows how to contact. Each time you find a new XBee, you ask it what it knows how to contact. Eventually, you'll have a complete network map, and will know whether the specific destination is connected. Of course, the map will be immediately out of date.

What is it you are trying to accomplish?

Point to point only. My goal Make Your Suitcase Haul Itself Around with Robot Luggage! - YouTube

luggage's xbee sends a signal to the xbee on the target to trigger the ultra sonic sensor sends sonic.

There is a inverter between xbee's Rx and sensor's trig pin. Arduino transmits byte(0xfe)1111 1110 with baud rate 115200 ,after inverter 0xfe becomes 0x01 .With start bit and the data 0x01, it is long enough to trigger the trig pin.

If there is no sonic receive, means there is only luggage on power or sonic doesn't send to the right direction .
The receiver might have noises sometimes if no sonic receive , so I want to make sure if the xbees are not connection,then don't do anything until connection to prevent noise.

I use Serial.write(byte(0xfe)), it would not tell the transmission fails or not.

I use Serial.write(byte(0xfe)), it would not tell the transmission fails or not.

Put the XBees in API mode. Use the XBee library by Andrew Rapp. With that, you can tell whether a given packet was acknowledged. If not, then the other device isn't powered up/connected.