I’m using java-api-master library to send and receive between (xbee coordinator and java eclipse platforme) and xbee router with arduino. I succeeded to send the data from xbee coordinator with java code and received in the xbee router via arduino. On the other hand when I receive the data from the router send it via arduino to the coordinator I can’t display it correctly please any help this my code :
arduino code :
#include
XBee xbee = XBee();
void setup() {
Serial.begin(9600);
xbee.setSerial(Serial);
}
void loop() {
uint8_t data[] = {‘H’,‘I’};
XBeeAddress64 addr64 = XBeeAddress64(0x0013a200, 0x403D0291 ); //40C8310C //40C66DB6
ZBTxRequest zbTx = ZBTxRequest(addr64, data, sizeof(data));
xbee.send(zbTx);
delay(3000);
}
java eclipse code:
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
import com.rapplogic.xbee.api.ApiId;
import com.rapplogic.xbee.api.XBee;
import com.rapplogic.xbee.api.XBeeResponse;
import com.rapplogic.xbee.api.zigbee.ZNetRxResponse;
import com.rapplogic.xbee.api.AtCommand;
import com.rapplogic.xbee.api.AtCommandResponse;
import com.rapplogic.xbee.util.ByteUtils;
public class ZNetReceiver {
XBee xbee = new XBee();
private final static Logger log = Logger.getLogger(ZNetReceiver.class);
private ZNetReceiver() throws Exception {
XBee xbee = new XBee();
try {
// replace with the com port or your receiving XBee
// this is the com port of my end device on my mac
xbee.open("COM4", 9600);
while (true) {
try {
// we wait here until a packet is received.
XBeeResponse response = xbee.getResponse();
ZNetRxResponse rx = (ZNetRxResponse) response;
log.info("received response " + response.toString());
String sample="";
for(int i=0;i