xbee in api mode library

Fork of xbee_lib by Tristan Hughes

Committer:
noname77
Date:
Sat Jan 25 21:20:41 2014 +0000
Revision:
8:3ef2044c1302
Parent:
7:8e5855f18ad3
Child:
9:08ccd085662f
some working code, xbees comunicate. need to mess it up a bit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noname77 7:8e5855f18ad3 1 class xbeeFrame : public xbee
noname77 7:8e5855f18ad3 2 {
noname77 7:8e5855f18ad3 3 private:
noname77 7:8e5855f18ad3 4 PinName _tx;
noname77 7:8e5855f18ad3 5 PinName _rx;
noname77 7:8e5855f18ad3 6 PinName _reset;
noname77 7:8e5855f18ad3 7
noname77 8:3ef2044c1302 8 char _apiFrame[FRAME_SIZE]; //fully assembled frame
noname77 7:8e5855f18ad3 9 unsigned char _length[2]; //length bytes
noname77 7:8e5855f18ad3 10 unsigned char _frameType; //frame type
noname77 7:8e5855f18ad3 11 unsigned char _frameID; //frame id
noname77 7:8e5855f18ad3 12 unsigned char _destAddr[8]; //destination address
noname77 7:8e5855f18ad3 13 unsigned char _sourceAddr[8]; //source address
noname77 7:8e5855f18ad3 14 unsigned char _options; //other options
noname77 8:3ef2044c1302 15 char* _payload; //actual data to be sent/received
noname77 7:8e5855f18ad3 16 unsigned char _checksum; //checksum byte
noname77 7:8e5855f18ad3 17 unsigned char _rssi; // RSSI
noname77 8:3ef2044c1302 18 char* _rfData; //pointer to an array to store incoming data
noname77 7:8e5855f18ad3 19 unsigned char _status; //status of transmitted frame
noname77 7:8e5855f18ad3 20
noname77 7:8e5855f18ad3 21 public:
noname77 7:8e5855f18ad3 22 /** Configure serial data pin.
noname77 7:8e5855f18ad3 23 * @param tx The serial tx pin the xbee is conected to.
noname77 7:8e5855f18ad3 24 * @param rx The serial rx pin the xbee is conected to.
noname77 7:8e5855f18ad3 25 * @param reset The pin connected to the Xbee reset pin.
noname77 7:8e5855f18ad3 26 */
noname77 7:8e5855f18ad3 27 xbeeFrame(PinName tx, PinName rx, PinName reset);
noname77 7:8e5855f18ad3 28 ~xbeeFrame();
noname77 7:8e5855f18ad3 29 /** Initializes the frame
noname77 7:8e5855f18ad3 30 */
noname77 7:8e5855f18ad3 31 void InitFrame(void);
noname77 7:8e5855f18ad3 32 /** Assembles the frame to be sent
noname77 7:8e5855f18ad3 33 */
noname77 7:8e5855f18ad3 34 void AssembleFrame(void);
noname77 7:8e5855f18ad3 35 /** Calculates the checksum of the frame
noname77 7:8e5855f18ad3 36 * @return Returns the checksum of the frame
noname77 7:8e5855f18ad3 37 */
noname77 7:8e5855f18ad3 38 char CalculateChecksum(void);
noname77 7:8e5855f18ad3 39 /** Calculates the length of the frame
noname77 7:8e5855f18ad3 40 * @return Returns the length of the frame
noname77 7:8e5855f18ad3 41 */
noname77 7:8e5855f18ad3 42 int CalculateLength(void);
noname77 7:8e5855f18ad3 43 /** Get the length of the frame
noname77 7:8e5855f18ad3 44 * @return Returns the length of the packet
noname77 7:8e5855f18ad3 45 */
noname77 7:8e5855f18ad3 46 int GetLength(void);
noname77 7:8e5855f18ad3 47 /** Set the packet destination address
noname77 7:8e5855f18ad3 48 * @param dest_address Pointer to a array storing destination address
noname77 7:8e5855f18ad3 49 */
noname77 8:3ef2044c1302 50 void SetDestination(unsigned char* dest);
noname77 7:8e5855f18ad3 51 /** Set the packet payload
noname77 7:8e5855f18ad3 52 * @param payload Pointer to a array storing payload (must be '\0' ended)
noname77 7:8e5855f18ad3 53 */
noname77 7:8e5855f18ad3 54 void SetPayload(char* payload);
noname77 7:8e5855f18ad3 55 /** Parses the received frame into proper data fields
noname77 7:8e5855f18ad3 56 */
noname77 7:8e5855f18ad3 57 void ParseFrame(void);
noname77 7:8e5855f18ad3 58 /** Prints the received frame information
noname77 7:8e5855f18ad3 59 */
noname77 8:3ef2044c1302 60 void PrintData(void);
noname77 8:3ef2044c1302 61 /** Sends the frame
noname77 8:3ef2044c1302 62 */
noname77 8:3ef2044c1302 63 void SendFrame(void);
noname77 7:8e5855f18ad3 64 /** Receives the frame
noname77 7:8e5855f18ad3 65 */
noname77 8:3ef2044c1302 66 void ReceiveFrame(char* buf);
noname77 8:3ef2044c1302 67 /** Returns pointer to api frame
noname77 8:3ef2044c1302 68 */
noname77 8:3ef2044c1302 69 char* GetFramePointer(void);
noname77 7:8e5855f18ad3 70 /** Indicates if the frame has been received
noname77 7:8e5855f18ad3 71 */
noname77 7:8e5855f18ad3 72 unsigned char frameReceived;
noname77 8:3ef2044c1302 73
noname77 8:3ef2044c1302 74 void PrintPayload();
noname77 7:8e5855f18ad3 75 };