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

Committer:
sleighton
Date:
Sat Jan 30 21:20:00 2016 +0000
Revision:
8:7e936dc02dec
Parent:
7:c3acafdb70c0
Child:
9:d5e7e772d5a4
Handles coordinates, updates node list accordingly

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