Library for XBee API targeted toward functions with specific use in conjunction with the Pololu 3pi Robot. Work in Progress
XBee_Robot.h
- Committer:
- sleighton
- Date:
- 2016-01-31
- Revision:
- 10:cb1d91c06093
- Parent:
- 9:d5e7e772d5a4
- Child:
- 11:6b699617fc7f
File content as of revision 10:cb1d91c06093:
#include "mbed.h" #include <vector> #include <list> #include <algorithm> class NetworkNode{ private: std::vector<uint8_t> addr; //network address vector int nodeNum; //index int x; int y; int heading; public: NetworkNode(std::vector<uint8_t> & addrIn, int indexIn); //constructor std::vector<uint8_t> getAddr(); //returns address int getIndex(); //returns index int getX(); //returns x coordinate int getY(); //returns y coordinate int getHeading(); //returns heading void setCoordinates(int x_in, int y_in, int heading_in); //sets coordinates void setAddr(std::vector<uint8_t> & addrIn); //sets address void setIndex(int indexIn); //sets index }; class XBee_Robot { private: int currentIndex; //current index of NetworkNode for received packet, allows coordinates to be updated std::vector< NetworkNode > node_list; //list of network nodes Serial dataLink; //declare global serial int commandX; // x coordinate received as commanded by the coordinator int commandY; //y coordinate received as commanded by the coordinator int commandFlag; // flag that indicates if coordinates from the coordinator have been received public: XBee_Robot(PinName _txIn, PinName _rxIn); //constructor for XBee void setRxInterrupt(); //enables interrupt for receive pin void Rx_interrupt(); //ISR for receive pin void transmitRequest(uint8_t *BitAddress64, uint8_t *BitAddress16, uint8_t broadcastRadius, uint8_t options, uint8_t *data,size_t dataLength); //assembles and sends transmission requests void ATQuery(uint8_t ATu, uint8_t ATl); //assembled and sends AT requests with no data byte in order to query the AT configuration of the XBee uint8_t calculateChecksum(std::vector<uint8_t> & packet); //calculates checksum for assembled packets void RxPacketControl(std::vector<uint8_t> & packet); //seperates packets depending on API command void checkSourceAddr(std::vector<uint8_t> & addr); //checks source address of received packet against list of known addresses and adds new addresses void RxDataHandler(std::vector<uint8_t> & packet); //handles received data based on data command int getCommandX(); //used by main program to extract received command coordinates int getCommandY(); //used by main program to extract received command coordinates int getCommandFlag(); //used by main program to poll command flag void resetCommandFlag(); //used by main program to reset command flag };