XBee Messenger
Introduction:
Going into CSE 20212 - Fundamentals of Computing II - I knew the final project was a large portion of the class. Being a computer engineer, I wanted to incorporate a hardware aspect into the project. I formed a team of fellow computer engineers and computer scientists, and we decided on a messaging application, specifically one we would build on top of a home-grown wireless network.
We broke down the project into 4 sections: hardware, internet relay protocal (IRC), packet protocals, and GUI. My roles were hardware and project manager. I made sure the team had the resources they needed to work on thier respective sections and organized team meetings to discuss progress and ideas.
Hardware:
At the root of our messaing application is a collection of XBee radios. We specifically used XBee S1 radios in serial mode. Serial mode emulates a serial port on the computer, allowing characters to be transferred from one XBee to another. Arduinos were used as a bridge between the computer and XBee, simply relaying serial communcation between the two devices. For the computer, clients use their personal UNIX laptops and the server is run on a Raspberry Pi.
Network Setup:
The server manages all communication between devices. Within the XBees we configured client radios to use one set of addresses, where the server XBee uses the same address, but flipped. This forces clients to only be able to talk to the server and vice versa. (Also known as a star topology). Every message from one client to another must pass through the server for routing.
When a client sends a message it will be passed from the computer, through the arduino, into the XBee, transmitted wirelessly, received by the server XBee, processed by the server, sent back through the server XBee, recieved by the other client's XBee, pass through the arduino, and processed by the client's computer and displayed to the user.
Message Protocals:
A custom IRC protocal was written for this project. Users can create and join rooms, and only users in that room can see messages that are sent by others. In side the protocal, messages and commands are sent within JSON messages. This allows messages to be sent only by characters, which is required by the XBees.
GUI:
A GUI was created using Qt. A variety of C++ libraries were used to incorporate JSON messaging, serial communication and multi-threading. One thread will manage the GUI, creating messages and packaging messages to be sent. Another will constantly monitor the serial port, looking for traffic and processing data that comes in.
Result:
By the end of the project we had a fully functioning program that could send and receive messages. Users could both send messages and run commands, doing things such as changing their name and creating new chat rooms. The server kept track of everything, logging all messages and backing up data in case of power loss.