XBee and XBee-PRO ZigBee RF modules provide cost-effective wireless connectivity to electronic devices. They are interoperable with other ZigBee PRO feature set devices, including devices from other vendors.

Dependencies:   BufferedArray

Dependents:   MBEDminiproject

Revision:
0:837e6c48e90d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Core/BufferedArray.h	Thu Oct 22 12:28:26 2015 +0000
@@ -0,0 +1,103 @@
+#ifndef UK_AC_HERTS_SMARTLAB_XBEE_BufferedArray
+#define UK_AC_HERTS_SMARTLAB_XBEE_BufferedArray
+
+#include "mbed.h"
+
+/**
+* Represent a generic, dynamic-length raw binary data buffer.
+*/
+class BufferedArray
+{
+protected :
+    /// initial size and automatically increase length.
+    static const int EXPANDSIZE = 20;
+
+    /// Raw data
+    char * data;
+
+    /// Current index of the data, could also used as data lendth.
+    int index;
+
+    /// Max data size that the raw data can hold.
+    int max;
+    
+    void expandSpace(int length);
+
+public:
+    BufferedArray();
+    
+    BufferedArray(int size);
+
+    BufferedArray(BufferedArray * bufferedArray);
+    
+    ~BufferedArray();
+
+    /** Get the raw data.
+    * @returns char array.
+    */
+    char * gets();
+        
+    /** Get the raw data from a specific location.
+    *
+    * @param position where to retrieve
+    *
+    * @returns char array.
+    */
+    char * gets(int position);
+           
+    /** Get 1 byte data from a specific location.
+    *
+    * @param position where to retrieve
+    *
+    * @returns char.
+    */
+    char get(int position);
+
+    /** Get the current index.
+    * @returns char array.
+    */
+    int getPosition();
+
+    /** Set the index within the max length of raw data.
+    * @param position where to begin read and write
+    */
+    void setPosition(int position);
+
+    /** Reset the raw data.
+    * @param length current max size for the raw data
+    */
+    void allocate(int length);
+
+    /** Reset the position and does not affect the content of the data.
+    * @param length current max size for the raw data
+    */
+    void rewind();
+    
+    /** Write 8-bit data into current posiston and increase by 1.
+    * @param value sigle byte
+    */
+    void set(char value);
+
+    /** Write array of data into current posiston, and increase by the lenght.
+    * @param value array of byte
+    * @param offset start point of the data
+    * @param length length to write
+    */
+    void sets(const char * value, int offset, int length);
+
+    /** Write 8-bit data into specific posiston and deos not affect the current position.
+    * @param position where to write
+    * @param value sigle byte
+    */
+    void set(int position, char value);
+
+    /** Write array of data into specific posiston and deos not affect the current position.
+    * @param position where to write
+    * @param value array of byte
+    * @param offset start point of the data
+    * @param length length to write
+    */
+    void sets(int position, const char * value, int offset, int length);
+};
+
+#endif