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

Committer:
sleighton
Date:
Wed Jan 06 17:37:09 2016 +0000
Revision:
6:fb0316cafaa6
Parent:
5:190b9e1a3cc1
Child:
7:c3acafdb70c0
Log of address now uses 16 bit network address, includes AT request function and constructor now calls AT request to log it's own network address

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 5:190b9e1a3cc1 27
sleighton 2:5040ec01dba1 28 class XBee_Robot {
sleighton 2:5040ec01dba1 29 private:
sleighton 2:5040ec01dba1 30
sleighton 4:af08c7749f9d 31 std::vector< NetworkNode > node_list; //list of network nodes
sleighton 2:5040ec01dba1 32
sleighton 2:5040ec01dba1 33 Serial dataLink; //declare global serial
sleighton 2:5040ec01dba1 34
sleighton 2:5040ec01dba1 35 public:
sleighton 2:5040ec01dba1 36
sleighton 2:5040ec01dba1 37 XBee_Robot(PinName _txIn, PinName _rxIn);
sleighton 2:5040ec01dba1 38 //constructor for XBee
sleighton 2:5040ec01dba1 39
sleighton 2:5040ec01dba1 40 void setRxInterrupt();
sleighton 2:5040ec01dba1 41 //enables interrupt for receive pin
sleighton 2:5040ec01dba1 42
sleighton 2:5040ec01dba1 43 void Rx_interrupt();
sleighton 2:5040ec01dba1 44 //ISR for receive pin
sleighton 2:5040ec01dba1 45
sleighton 2:5040ec01dba1 46 void transmitRequest(uint8_t *BitAddress64, uint8_t *BitAddress16, uint8_t broadcastRadius, uint8_t options, uint8_t *data,size_t dataLength);
sleighton 2:5040ec01dba1 47 //assembles and sends transmission requests
sleighton 2:5040ec01dba1 48
sleighton 6:fb0316cafaa6 49 void ATQuery(uint8_t ATu, uint8_t ATl);
sleighton 6:fb0316cafaa6 50 //assembled and sends AT requests with no data byte in order to query the AT configuration of the XBee
sleighton 6:fb0316cafaa6 51
sleighton 2:5040ec01dba1 52 uint8_t calculateChecksum(std::vector<uint8_t> & packet);
sleighton 2:5040ec01dba1 53 //calculates checksum for assembled packets
sleighton 3:cf539cfd3d59 54
sleighton 3:cf539cfd3d59 55 void RxPacketControl(std::vector<uint8_t> & packet);
sleighton 3:cf539cfd3d59 56 //seperates packets depending on API command
sleighton 3:cf539cfd3d59 57
sleighton 3:cf539cfd3d59 58 void checkSourceAddr(std::vector<uint8_t> & addr);
sleighton 3:cf539cfd3d59 59 //checks source address of received packet against list of known addresses and adds new addresses
sleighton 4:af08c7749f9d 60 };