Overview
This project uses XMPP (AKA Jabber) to provide IP connectivity to an XBee wireless network. This is accomplished with a Gateway instance that forwards XBee packets to XMPP Clients and similarly receives XBee packets from XMPP Clients and forwards them to the XBee network. The purpose of this project is to allow an XBee wireless network to be shared by multiple applications that may reside on different machines and even different networks! As long as you can connect to an XMPP server, your XBee network and Clients can reside behind firewalls and/or NAT devices and still talk to each other. This project is built on XBee-API and Smack API and is supported on Windows, Mac, Linux and any other OS that supports Java 5+ and RXTX (RXTX for Gateway only).
Currently there are two choices for XMPP servers: Google Talk and Openfire, although it should be possible to use any compliant XMPP server. The Google Talk option is recommended only if you want to talk to your XBee network from anywhere on the internet and you don't have access to a server with a public IP address. If your Client and Gateway are both on the same private network, or you have a server with a public IP address, you should use Openfire. Openfire is easy to install and has a very nice web console.
Problems?
This project is very beta and while there are no known issues at this time, you can expect bugs to crop up. If you come across an issue please report it on the issue tracker, so that I can improve the project.
Questions/Feedback
I can be contacted at andrew.rapp [at] gmail
Getting Started
Before working the XBee-XMPP you should first be familiar with XBee-API
I'm going to use Google Talk in this example so that we get can up and running quickly without needing to install a server. You must have at least two Google Talk accounts to run this example. One account will be used for the Gateway and the other for the Client.
Download the code, unzip and create an Eclipse project for it (on the machine that your XBee is plugged into). The download includes everything thing you need to run the examples, except Eclipse and Java.
Open the XBeeXmppGatewayExample.java and replace yourclient@gmail.com with your Google Talk Client user account:
clientList.add("yourclient@gmail.com");
Now create a XBeeGtalkGateway object, with the Google Talk account for your Gateway user, the password, and the COM port/baud rate of the attached XBee:
gateway = new XBeeGtalkGateway("yourgateway@gmail.com", "yourgatewaypassword", clientList, "/dev/tty.usbserial-A6005v5M", 9600);
Save it. (Eclipse automatically compiles it)
Now create a command prompt and startup the Gateway (sorry, currently only mac/linux):
./startXmppClass.sh com.rapplogic.xbee.xmpp.examples.XBeeXmppGatewayExample
You should see some console output.
Now we are ready to start the Client. The wonderful thing about this solution is that the Client doesn't need to be on the same machine or even the same network. Since XMPP is a network protocol, we can start the client anywhere, as long as it can connect to the Google Talk server (e.g. coffee shop, hotel etc.)
If you are on a different machine, again download the code, unzip and create an Eclipse project for it.
Open XBeeXmppClientExample.java in Eclipse and create a XBeeGtalkClient object with the Google Talk Client user and password, and the Gateway user
XBeeXmppClient client = new XBeeGtalkClient("yourclient@gmail.com", "yourclientpassword", "yourgateway@gmail.com");
Save
Now we will run the Client in Eclipse. Select Run As->Java Application from the Run menu
This example sends an AI (Association Status) to the XBee that is attached to the Gateway every 10 seconds. You should be seeing output in the Eclipse console.
To demonstrate how well XMPP tolerates disconnects, kill the the Gateway and you should see a "gateway offline" message in the Client console. When the Gateway is offline the Client just waits for it to come back online. Now startup the Gateway and the Client will resume sending requests. You can do a similar test with the Gateway.
Using Openfire is identical except that you will be instead creating XBeeOpenfireClient and XBeeOpenfireGateway objects. Of course, you'll also need to setup your own Openfire server. The good news is that it's not hard and I'll describe how to do that at a later time.
Now go off and write your remote XBee XMPP application and send/receive any XBeeRequest/XBeeResponse to your XBee nework from anywhere on the internet!
Here's a more involved example that uses Remote AT to request samples from a remote XBee