Home/Support/Support Forum/I'm using Xbee java library to discover the network devices but it doesn't work, please any help this the code :

I'm using Xbee java library to discover the network devices but it doesn't work, please any help this the code :

0 votes
the code :
package com.digi.xbee.example;
import com.digi.xbee.api.XBeeDevice;
import com.digi.xbee.api.XBeeNetwork;
import com.digi.xbee.api.exceptions.XBeeException;
import com.digi.xbee.api.RemoteXBeeDevice;
import java.util.List;
public class discovery {

/* Constants */

// TODO Replace with the serial port where your module is connected to.
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) {
// Instantiate an XBee device object.
XBeeDevice myXBeeDevice = new XBeeDevice(PORT,BAUD_RATE );
try{
myXBeeDevice.open();
// Get the XBee Network object from the XBee device.
XBeeNetwork network = myXBeeDevice.getNetwork();
// Set the timeout to 10 seconds.
network.setDiscoveryTimeout(10000);

// Start the discovery process.
network.startDiscoveryProcess();

// Wait until the discovery process has finished.
while (network.isDiscoveryRunning()) {
// Sleep.
}

// Retrieve the devices that form the network.
List<RemoteXBeeDevice> remotes = network.getDevices();
System.out.println("There are " + network.getNumberOfDevices() + " device(s) in the network.");


}catch (XBeeException e) {
e.printStackTrace();
myXBeeDevice.close();
System.exit(1);
}
}
}
asked Nov 11, 2015 in RF Solutions and XBee by marie New to the Community (2 points)

Please log in or register to answer this question.

2 Answers

0 votes
What XBee products and related firmware are you using?
answered Nov 30, 2015 by mvut Veteran of the Digi Community (11,445 points)
0 votes
Thank for your response , i'am using XBee Serie 2 from Digi
For the router these are the firmware information:
-Product family: XB24-ZB
-Function Set: Zigbee router Api
-Firmware version 23A7
For the coordinator :
-Product family: XB24-ZB
-Function Set: Zigbee coordinator Api
-Firmware version 21A7
answered Nov 30, 2015 by marie New to the Community (2 points)
Are you sure the modules are associated to each other? If you use the Node Discovery function in XCTU, do you see the other modules in the network?
Yes Mvut they works in XCTU and give  me  the addresses list  of the discovered xbees. and this is the configuration of my Xbees in XCTU :
for the zigbee coordinator api:
-PAN ID: C001BEE
-SC scan channels:FFF
-DH:0
-DL:FFFF
-AP API enable:2
for the zigbee router api:
-PAN ID: C001BEE
-SC scan channels:FFF
-DH:0
-DL:FFFF
-AP API enbale:2
for the zigbee coordinator api:
-PAN ID: C001BEE
-SC scan channels:FFF
-JV channel verification: enabled
-DH:0
-DL:0
-AP API enbale:2
Try API mode 1 on the node that you are using the Java files from.  It could very well be that the Java is only using API mode 1.
Thank you Mvut it works :) but I want to ask you a question have any idea how I can do the same process of discovering using c sharp with visual studio ??
Try looking through the examples for the XBee Programmables.
...