Amman Vedi / xbee_lib

Dependents:   IOT_Sockets

Fork of xbee_api by Wiktor Grajkowski

Revision:
7:8e5855f18ad3
Child:
8:3ef2044c1302
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/xbeeFrame.h	Sat Jan 25 16:29:44 2014 +0000
@@ -0,0 +1,67 @@
+class xbeeFrame : public xbee
+{
+private:
+    PinName _tx;
+    PinName _rx;
+    PinName _reset;
+
+    unsigned char _apiFrame[FRAME_SIZE];   //fully assembled frame
+    unsigned char _length[2];               //length bytes
+    unsigned char _frameType;              //frame type
+    unsigned char _frameID;                //frame id
+    unsigned char _destAddr[8];            //destination address
+    unsigned char _sourceAddr[8];          //source address
+    unsigned char _options;                 //other options
+    unsigned char* _payload;                         //actual data to be sent/received
+    unsigned char _checksum;                //checksum byte
+    unsigned char _rssi;                    // RSSI
+    unsigned char _rfData[MAX_DATA_LEN];   //incoming data array
+    unsigned char _status;                  //status of transmitted frame
+    
+public:
+    /** Configure serial data pin.
+      * @param tx The serial tx pin the xbee is conected to.
+      * @param rx The serial rx pin the xbee is conected to.
+      * @param reset The pin connected to the Xbee reset pin.
+      */
+    xbeeFrame(PinName tx, PinName rx, PinName reset);
+    ~xbeeFrame();
+    /** Initializes the frame
+      */
+    void InitFrame(void);
+    /** Assembles the frame to be sent
+      */  
+    void AssembleFrame(void);
+    /** Calculates the checksum of the frame
+      * @return Returns the checksum of the frame
+      */
+    char CalculateChecksum(void);
+    /** Calculates the length of the frame
+      * @return Returns the length of the frame
+      */
+    int CalculateLength(void);
+    /** Get the length of the frame
+      * @return Returns the length of the packet
+      */
+    int GetLength(void);
+    /** Set the packet destination address 
+      * @param dest_address Pointer to a array storing destination address
+      */
+    void SetDestination(char* dest);
+    /** Set the packet payload 
+      * @param payload Pointer to a array storing payload (must be '\0' ended)
+      */
+    void SetPayload(char* payload);    
+    /** Parses the received frame into proper data fields
+      */
+    void ParseFrame(void);
+    /** Prints the received frame information
+      */
+    void PrintData(void);
+    /** Receives the frame
+      */
+    void ReceiveFrame(void);
+    /** Indicates if the frame has been received
+      */
+    unsigned char frameReceived;
+};
\ No newline at end of file