Home/Support/Support Forum/Hi I 'm trying to discover network without using a listener this the code but it doesn't give any think

Hi I 'm trying to discover network without using a listener this the code but it doesn't give any think

0 votes
import com.digi.xbee.api.XBeeDevice;
import com.digi.xbee.api.XBeeNetwork;
import com.digi.xbee.api.exceptions.XBeeException;
import java.util.ArrayList;
import java.util.List;
import com.digi.xbee.api.RemoteXBeeDevice;
public class discover {

private static final String PORT = "COM5";
// TODO Replace with the baud rate of your module.
private static final int BAUD_RATE = 9600;
public static void main(String[] args) {
System.out.println(" +
+");
System.out.println(" | XBee Java Library Discover Devices Sample |");
System.out.println(" +
+\n");

XBeeDevice myDevice = new XBeeDevice(PORT, BAUD_RATE);
try {
myDevice.open();
XBeeNetwork myXBeeNetwork = myDevice.getNetwork();
myXBeeNetwork.setDiscoveryTimeout(15000);
myXBeeNetwork.startDiscoveryProcess();
List<RemoteXBeeDevice> devices = new ArrayList<RemoteXBeeDevice>();



for(int i = 0 ; i < devices.size(); i++){
RemoteXBeeDevice xbee = new RemoteXBeeDevice(myDevice,devices.get(i).get64BitAddress());
System.out.println(devices.get(i).get64BitAddress().toString());
System.out.println(devices.get(i).getPANID().toString().getBytes());
System.out.println(devices.get(i).getXBeeProtocol());
}



} catch (XBeeException e) {
e.printStackTrace();
myDevice.close();
System.exit(1);
}
}
}
Note I'm using XBee S2 and thisis my configuration :
for the zigbee coordinator api:
-PAN ID: C001BEE
-SC scan channels:FFF
-DH:0
-DL:FFFF
-AP API enable:1
for the zigbee routerapi:
-PAN ID: C001BEE
-SC scan channels:FFF
-JV channel verification: enabled
-DH:0
-DL:0
-AP API enable:1
asked Jan 4, 2016 in IEEE 802.15.4 by marie New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

0 votes
What do you mean by Any Listener? If you want to know when a node joins the network, you must read the COM port for data. Otherwise it makes no sense to issue a Node Discovery or enabling the JV command if your application is not going to listen for the data.
answered Jan 14, 2016 by mvut Veteran of the Digi Community (11,302 points)
...