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

Committer:
sleighton
Date:
Tue Jan 05 14:27:40 2016 +0000
Revision:
4:af08c7749f9d
Parent:
3:cf539cfd3d59
Child:
5:190b9e1a3cc1
network node class added

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 4:af08c7749f9d 10 public:
sleighton 4:af08c7749f9d 11 NetworkNode(std::vector<uint8_t> & addrIn, int indexIn);
sleighton 4:af08c7749f9d 12 //constructor
sleighton 4:af08c7749f9d 13
sleighton 4:af08c7749f9d 14 std::vector<uint8_t> getAddr();
sleighton 4:af08c7749f9d 15 //returns address
sleighton 4:af08c7749f9d 16
sleighton 4:af08c7749f9d 17 int getIndex();
sleighton 4:af08c7749f9d 18 //returns index
sleighton 4:af08c7749f9d 19
sleighton 4:af08c7749f9d 20 void setAddr(std::vector<uint8_t> & addrIn);
sleighton 4:af08c7749f9d 21 //sets address
sleighton 4:af08c7749f9d 22
sleighton 4:af08c7749f9d 23 void setIndex(int indexIn);
sleighton 4:af08c7749f9d 24 //sets index
sleighton 4:af08c7749f9d 25 };
sleighton 4:af08c7749f9d 26
sleighton 2:5040ec01dba1 27 class XBee_Robot {
sleighton 2:5040ec01dba1 28 private:
sleighton 2:5040ec01dba1 29
sleighton 4:af08c7749f9d 30 std::vector< NetworkNode > node_list; //list of network nodes
sleighton 2:5040ec01dba1 31
sleighton 2:5040ec01dba1 32 Serial dataLink; //declare global serial
sleighton 2:5040ec01dba1 33
sleighton 2:5040ec01dba1 34 public:
sleighton 2:5040ec01dba1 35
sleighton 2:5040ec01dba1 36 XBee_Robot(PinName _txIn, PinName _rxIn);
sleighton 2:5040ec01dba1 37 //constructor for XBee
sleighton 2:5040ec01dba1 38
sleighton 2:5040ec01dba1 39 void setRxInterrupt();
sleighton 2:5040ec01dba1 40 //enables interrupt for receive pin
sleighton 2:5040ec01dba1 41
sleighton 2:5040ec01dba1 42 void Rx_interrupt();
sleighton 2:5040ec01dba1 43 //ISR for receive pin
sleighton 2:5040ec01dba1 44
sleighton 2:5040ec01dba1 45 void transmitRequest(uint8_t *BitAddress64, uint8_t *BitAddress16, uint8_t broadcastRadius, uint8_t options, uint8_t *data,size_t dataLength);
sleighton 2:5040ec01dba1 46 //assembles and sends transmission requests
sleighton 2:5040ec01dba1 47
sleighton 2:5040ec01dba1 48 uint8_t calculateChecksum(std::vector<uint8_t> & packet);
sleighton 2:5040ec01dba1 49 //calculates checksum for assembled packets
sleighton 3:cf539cfd3d59 50
sleighton 3:cf539cfd3d59 51 void RxPacketControl(std::vector<uint8_t> & packet);
sleighton 3:cf539cfd3d59 52 //seperates packets depending on API command
sleighton 3:cf539cfd3d59 53
sleighton 3:cf539cfd3d59 54 void checkSourceAddr(std::vector<uint8_t> & addr);
sleighton 3:cf539cfd3d59 55 //checks source address of received packet against list of known addresses and adds new addresses
sleighton 4:af08c7749f9d 56 };