Committer:
sleighton
Date:
Tue Jan 05 14:48:39 2016 +0000
Revision:
5:190b9e1a3cc1
Parent:
4:af08c7749f9d
Child:
6:fb0316cafaa6
Updated to include a network node class which makes indexing easier and in future updates will designate the coordinator, routers and end nodes

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 2:5040ec01dba1 49 uint8_t calculateChecksum(std::vector<uint8_t> & packet);
sleighton 2:5040ec01dba1 50 //calculates checksum for assembled packets
sleighton 3:cf539cfd3d59 51
sleighton 3:cf539cfd3d59 52 void RxPacketControl(std::vector<uint8_t> & packet);
sleighton 3:cf539cfd3d59 53 //seperates packets depending on API command
sleighton 3:cf539cfd3d59 54
sleighton 3:cf539cfd3d59 55 void checkSourceAddr(std::vector<uint8_t> & addr);
sleighton 3:cf539cfd3d59 56 //checks source address of received packet against list of known addresses and adds new addresses
sleighton 4:af08c7749f9d 57 };