java xbee library and arduino xbee library ?

hello i’ m working to build a wireless sensor network using arduino and xbee modules and try to communicate with a graphical interface using java eclipse
For the arduino I’m using the xbee arduino library that operating in api escaped mode (AP=2) .
For the eclipse i’m using the xbee java library that operatin in api mode (AP=1).
The problem is how to resolve the conflict between api modes in java and arduino and how to collect in java database the data coming from differents nodes please any idea that can help me ?

You need to choose one or the other. You can’t mix the two API modes as they present the data differently.

Thank you for you answer Mvut I see i can’t mixt two API but the problem is when I choose the AP=2 for my xbee I can’t send and receive correctly data between arduinos but not in the eclipse side beceause java xbee library doesn’t support the escpaed mode and if I choose the AP=1 i can’t send data between arduinos via xbees using the xbee arduino library because it does n’t support this mode AP=1 you see what I mean ?

Are you not working with a different radio connected to the JAVA system than what is connected to the Arduino or are the two using the exact same module? IE one module for both systems?

I have three arduinos and three xbees Series 2 the coordinator or the master (arduino+xbee) is connected to the java system and the others are routers each (arduino+ xbee)

I would suggest looking on Arduino.com for a different lib then. There should be several for the XBee and the Arduino that use API mode 1 and AT command mode.

Hi Mvut I found this library from github :https://github.com/andrewrapp/xbee-api that requires api mod eby setting AP=2 I try to install the libraries includes in the zip below and test this example OpenCloseConnection test in https://github.com/andrewrapp/xbee-api/tree/master/src/com/rapplogic/xbee/test
but it doesn’t work it mention an error cannot resolve the type for (OpenCloseConnectionsTest.class) this the code :
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.rapplogic.xbee.api.AtCommand;
import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeException;

public class api {
private final static Logger log = Logger.getLogger(OpenCloseConnectionsTest.class);

private XBee xbee = new XBee();

public static void main(String[] args) throws XBeeException, InterruptedException {
	PropertyConfigurator.configure("log4j.properties");
	new OpenCloseConnectionsTest();
}

public  OpenCloseConnectionsTest() throws XBeeException, InterruptedException {
	
	// series 1
	//String device = "/dev/tty.usbserial-A4004Rim";
	// series 2
//	String device = "/dev/tty.usbserial-A6005v5M";
	String device ="COM5";
	log.info("opening connection");

// xbee.setStartupChecks(false);

	// first connect directly to end device and configure.  then comment out configureXXX methods and connect to coordinator
	xbee.open(device, 9600);
	
	if (!xbee.isConnected()) throw new RuntimeException("Should be connected");
	
	try {
		log.info("attempting duplicate open");
		xbee.open(device, 9600);
		throw new RuntimeException("fail -- already open");
	} catch (Exception e) {
		log.debug("Expected", e);
	}
	
	log.info("sending channel command");
	
	if (!xbee.sendAtCommand(new AtCommand("CH")).isOk()) throw new RuntimeException("fail");
	log.info("closing connection");
	xbee.close();
	
	if (xbee.isConnected()) {
		throw new RuntimeException("Should be disconnected");
	}
	
	try {
		log.info("sending at command, but we're disconnected");
		xbee.sendAtCommand(new AtCommand("CH")).isOk();
		throw new RuntimeException("Should be disconnected");
	} catch (Exception e) {
		log.debug("Expected", e);
	}
	
	log.info("reconnecting");
	xbee.open(device, 9600);
	if (!xbee.sendAtCommand(new AtCommand("CH")).isOk()) throw new RuntimeException("fail");
	
	log.info("closing conn");
	xbee.close();
	
	try {
		log.info("try duplicate close");
		xbee.close();
		throw new RuntimeException("Already closed");
	} catch (Exception e) {
		log.debug("Expected", e);
	}
}	

}
Please any help to resolve it ?

https://docs.digi.com/display/XBJLIB/XBee+Java+Library
here is the library

Hi Marie,
Did you manage to get the arduino library working?
Are you susing S2B or S3B modules?