Library for XBee API targeted toward functions with specific use in conjunction with the Pololu 3pi Robot. Work in Progress

Committer:
sleighton
Date:
Sun Jan 31 19:34:21 2016 +0000
Revision:
9:d5e7e772d5a4
Parent:
8:7e936dc02dec
Child:
10:cb1d91c06093
Tracks heading

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sleighton 2:5040ec01dba1 1 #include "mbed.h"
sleighton 2:5040ec01dba1 2 #include <vector>
sleighton 3:cf539cfd3d59 3 #include <list>
sleighton 3:cf539cfd3d59 4 #include <algorithm>
sleighton 2:5040ec01dba1 5
sleighton 4:af08c7749f9d 6 class NetworkNode{
sleighton 4:af08c7749f9d 7 private:
sleighton 4:af08c7749f9d 8 std::vector<uint8_t> addr; //network address vector
sleighton 4:af08c7749f9d 9 int nodeNum; //index
sleighton 8:7e936dc02dec 10 int x;
sleighton 8:7e936dc02dec 11 int y;
sleighton 9:d5e7e772d5a4 12 int heading;
sleighton 4:af08c7749f9d 13 public:
sleighton 4:af08c7749f9d 14 NetworkNode(std::vector<uint8_t> & addrIn, int indexIn);
sleighton 4:af08c7749f9d 15 //constructor
sleighton 4:af08c7749f9d 16
sleighton 4:af08c7749f9d 17 std::vector<uint8_t> getAddr();
sleighton 4:af08c7749f9d 18 //returns address
sleighton 4:af08c7749f9d 19
sleighton 4:af08c7749f9d 20 int getIndex();
sleighton 4:af08c7749f9d 21 //returns index
sleighton 4:af08c7749f9d 22
sleighton 8:7e936dc02dec 23 int getX();
sleighton 8:7e936dc02dec 24 //returns x coordinate
sleighton 8:7e936dc02dec 25
sleighton 8:7e936dc02dec 26 int getY();
sleighton 8:7e936dc02dec 27 //returns y coordinate
sleighton 8:7e936dc02dec 28
sleighton 9:d5e7e772d5a4 29 int getHeading();
sleighton 9:d5e7e772d5a4 30 //returns heading
sleighton 9:d5e7e772d5a4 31
sleighton 9:d5e7e772d5a4 32 void setCoordinates(int x_in, int y_in, int heading_in);
sleighton 8:7e936dc02dec 33 //sets coordinates
sleighton 8:7e936dc02dec 34
sleighton 4:af08c7749f9d 35 void setAddr(std::vector<uint8_t> & addrIn);
sleighton 4:af08c7749f9d 36 //sets address
sleighton 4:af08c7749f9d 37
sleighton 4:af08c7749f9d 38 void setIndex(int indexIn);
sleighton 4:af08c7749f9d 39 //sets index
sleighton 4:af08c7749f9d 40 };
sleighton 4:af08c7749f9d 41
sleighton 5:190b9e1a3cc1 42
sleighton 2:5040ec01dba1 43 class XBee_Robot {
sleighton 2:5040ec01dba1 44 private:
sleighton 9:d5e7e772d5a4 45
sleighton 8:7e936dc02dec 46 int currentIndex; //current index of NetworkNode for received packet, allows coordinates to be updated
sleighton 2:5040ec01dba1 47
sleighton 4:af08c7749f9d 48 std::vector< NetworkNode > node_list; //list of network nodes
sleighton 2:5040ec01dba1 49
sleighton 2:5040ec01dba1 50 Serial dataLink; //declare global serial
sleighton 2:5040ec01dba1 51
sleighton 2:5040ec01dba1 52 public:
sleighton 2:5040ec01dba1 53
sleighton 2:5040ec01dba1 54 XBee_Robot(PinName _txIn, PinName _rxIn);
sleighton 2:5040ec01dba1 55 //constructor for XBee
sleighton 2:5040ec01dba1 56
sleighton 2:5040ec01dba1 57 void setRxInterrupt();
sleighton 2:5040ec01dba1 58 //enables interrupt for receive pin
sleighton 2:5040ec01dba1 59
sleighton 2:5040ec01dba1 60 void Rx_interrupt();
sleighton 2:5040ec01dba1 61 //ISR for receive pin
sleighton 2:5040ec01dba1 62
sleighton 2:5040ec01dba1 63 void transmitRequest(uint8_t *BitAddress64, uint8_t *BitAddress16, uint8_t broadcastRadius, uint8_t options, uint8_t *data,size_t dataLength);
sleighton 2:5040ec01dba1 64 //assembles and sends transmission requests
sleighton 2:5040ec01dba1 65
sleighton 6:fb0316cafaa6 66 void ATQuery(uint8_t ATu, uint8_t ATl);
sleighton 6:fb0316cafaa6 67 //assembled and sends AT requests with no data byte in order to query the AT configuration of the XBee
sleighton 6:fb0316cafaa6 68
sleighton 2:5040ec01dba1 69 uint8_t calculateChecksum(std::vector<uint8_t> & packet);
sleighton 2:5040ec01dba1 70 //calculates checksum for assembled packets
sleighton 3:cf539cfd3d59 71
sleighton 3:cf539cfd3d59 72 void RxPacketControl(std::vector<uint8_t> & packet);
sleighton 3:cf539cfd3d59 73 //seperates packets depending on API command
sleighton 3:cf539cfd3d59 74
sleighton 3:cf539cfd3d59 75 void checkSourceAddr(std::vector<uint8_t> & addr);
sleighton 3:cf539cfd3d59 76 //checks source address of received packet against list of known addresses and adds new addresses
sleighton 7:c3acafdb70c0 77
sleighton 7:c3acafdb70c0 78 void RxDataHandler(std::vector<uint8_t> & packet);
sleighton 7:c3acafdb70c0 79 //handles received data based on data command
sleighton 4:af08c7749f9d 80 };