API for communicating with XBee devices.

Dependencies:   CircularBuffer FixedLengthList

Dependents:   XBeeApiTest XBeeApiSimpleATCmdsExample XBeeApiBroadcastExample XBeeApiBroadcastExampleRTOS ... more

Overview

XBeeApi is intended to be a library for providing a high-level API interface to the XBee - for example getChannel() and setChannel(2) methods rather than needing to send( "ATCH" ) and send( "ATCH 2" ) - and then de-code the responses.

See the notebook page here for a description of how the API works & some details on the various classes.

Features:

  • Support for transmission & reception of data packets
  • Support for reading & changing settings
  • Support for "Remote AT" interface to access settings & I/O channels on remote XBees
  • XBeeApi should work if you're using mbed-rtos, though it is not currently threadsafe. Take a look at the XBeeApiBroadcastExampleRTOS example if you're including mbed-rtos.

Example Programs

There are also example programs available:

Transmit

Import programXBeeApiSimpleBroadcastExample

Simple example of how to use XBeeApi - set up the XBee, configure P2P networking then transmit a frame.

Import programXBeeApiBroadcastExample

Example for XBeeAPI; a little more involved than XBeeApiSimpleBroadcastExample with report on failure to set up the XBee and on the transmit status of the message.

Import programXBeeApiBroadcastExampleRTOS

Example of using the XBeeApi library to broadcast a message, based on XBeeApiBroadcastExample. This example shows how to use the library when using mbed-rtos. Before compiling you must open "XbeeApi\Config\XBeeApiCfg.hpp" and change the '#if 0' to '#if 1' on the line above the comment reading "Use RTOS features to make XBeeApi threadsafe"

Settings/Status

Import programXBeeApiSimpleATCmdsExample

Simple example of using XBeeApi to send AT-style commands to the XBee

Import programXBeeApiRemoteATCmdsExample

Example of using the XBeeApi library to send AT commands to remote XBee devices in order to read/write settings

Receive

Import programXBeeApiSimpleReceiveExample

Simple example of using XBeeApi to receive data packets via wireless

Import programXBeeApiReceiveCallbackExample

Example of using the XBeeApi library to receive a message via a callback method

Import programXBeeApiReceiveCallbackExampleRTOS

Example of using the XBeeApi library to receive a message via a callback method. This example shows how to use the library when using mbed-rtos. See the comment at the top of main.cpp

Remote I/O

Import programXBeeApiRemoteIOExample

Example of using the XBeeApi library to read inputs on a remote XBee

If you have 2 mbed connected XBees available then you can use XBeeApiSimpleReceiveExample and XBeeApiSimpleBroadcastExample as a pair.

Note that this is still a work in progress! XBeeApiTodoList tracks some of the functionality still to be added.

Files at this revision

API Documentation at this revision

Comitter:
johnb
Date:
Sun Jul 13 15:47:40 2014 +0000
Parent:
49:37bba77ee73f
Child:
51:a7d0d2ef9261
Commit message:
Add support for Remote AT commands

Changed in this revision

Base/XBeeApiFrame.hpp Show annotated file Show diff for this revision Revisions of this file
Remote/XBeeDeviceRemoteAt.cpp Show annotated file Show diff for this revision Revisions of this file
Remote/XBeeDeviceRemoteAt.hpp Show annotated file Show diff for this revision Revisions of this file
Utility/XBeeApiCmdAt.cpp Show annotated file Show diff for this revision Revisions of this file
Utility/XBeeApiCmdAt.hpp Show annotated file Show diff for this revision Revisions of this file
Utility/xbeeapi.hpp Show annotated file Show diff for this revision Revisions of this file
--- a/Base/XBeeApiFrame.hpp	Mon Jul 07 19:14:46 2014 +0000
+++ b/Base/XBeeApiFrame.hpp	Sun Jul 13 15:47:40 2014 +0000
@@ -185,5 +185,7 @@
 /** Value which represents the broadcast address */
 #define XBEE_BROADCAST_ADDR 0xFFFF
 
+/** Value which indicates that 64-bit addressing should be used */
+#define XBEE_USE_64BIT_ADDR 0xFFFE
 
 #endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Remote/XBeeDeviceRemoteAt.cpp	Sun Jul 13 15:47:40 2014 +0000
@@ -0,0 +1,228 @@
+/** 
+
+Copyright 2014 John Bailey
+   
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+
+#include "XBeeDeviceRemoteAt.hpp"
+
+#define XBEE_API_CMD_REMOTE_REQ_HEADER_LEN 14U
+
+template< typename T >
+class XBeeApiCmdAtRemoteSet : public XBeeApiFrame {
+    uint8_t m_buffer[ XBEE_API_CMD_REMOTE_REQ_HEADER_LEN + sizeof( T ) ];
+    public:
+        /** Constructor
+                   
+            \param p_data Pointer to a buffer of length 2 bytes identifying
+                          the command, e.g. 'V', 'R' would set up a version
+                          request
+            \param p_val New value for the parameter 
+        */
+        XBeeApiCmdAtRemoteSet( const uint8_t        p_frameId,
+                               const uint16_t       p_addr16Bit,
+                               const uint64_t       p_addr64Bit,
+                               const uint8_t* const p_data,
+                               const T p_val );
+        /** Destructor */
+        virtual ~XBeeApiCmdAtRemoteSet();
+};
+
+class XBeeApiCmdAtRemoteReq : public XBeeApiFrame {
+    uint8_t m_buffer[ XBEE_API_CMD_REMOTE_REQ_HEADER_LEN ];
+    public:
+        /** Constructor
+                   
+            \param p_data Pointer to a buffer of length 2 bytes identifying
+                          the command, e.g. 'V', 'R' would set up a version
+                          request
+            \param p_val New value for the parameter 
+        */
+        XBeeApiCmdAtRemoteReq( const uint8_t        p_frameId,
+                               const uint16_t       p_addr16Bit,
+                               const uint64_t       p_addr64Bit,
+                               const uint8_t* const p_data );
+        /** Destructor */
+        virtual ~XBeeApiCmdAtRemoteReq();
+};
+
+XBeeDeviceRemoteAt::XBeeDeviceRemoteAt( XBeeDevice* p_device,
+                                        const uint16_t& p_addr16Bit,
+                                        const uint64_t& p_addr64Bit  ) : XBeeApiCmdAt( p_device ), m_addr16Bit( p_addr16Bit ), m_addr64Bit( p_addr64Bit )
+{
+}
+        
+XBeeDeviceRemoteAt::~XBeeDeviceRemoteAt( void )
+{
+}
+
+extern Serial pc;
+
+#define XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS (XBEE_CMD_POSN_ID_SPECIFIC_DATA+1)
+#define XBEE_REMOTE_AT_RESPONSE_16BIT_ADDRESS (XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + sizeof( uint64_t))
+#define XBEE_REMOTE_AT_RESPONSE_STATUS (17U)
+
+size_t XBeeDeviceRemoteAt::getResponseStatusPos( void ) const
+{
+    return XBEE_REMOTE_AT_RESPONSE_STATUS;
+}
+
+bool XBeeDeviceRemoteAt::decodeCallback( const uint8_t* const p_data, size_t p_len )
+{
+    bool ret_val = false;
+ 
+    /* TODO: Length check */
+ 
+    if( XBEE_CMD_REMOTE_AT_RESPONSE == p_data[ XBEE_CMD_POSN_API_ID ] )
+    {
+        uint64_t src64BitAddr = (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS ]) << 56U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 1 ]) << 48U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 2 ]) << 40U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 3 ]) << 32U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 4 ]) << 24U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 5 ]) << 16U) |
+                                (((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 6 ]) << 8U) |
+                                ((uint64_t)p_data[ XBEE_REMOTE_AT_RESPONSE_64BIT_ADDRESS + 7 ]);
+        uint16_t src16BitAddr = (((uint16_t)p_data[ XBEE_REMOTE_AT_RESPONSE_16BIT_ADDRESS ]) << 8U) | 
+                                p_data[ XBEE_REMOTE_AT_RESPONSE_16BIT_ADDRESS + 1 ];
+                
+        if(( src16BitAddr == m_addr16Bit ) ||
+           ( src64BitAddr == m_addr64Bit ))
+        {
+            ret_val = processResponseFrame( p_data, p_len );
+            
+#if 0
+            pc.printf("Len %d\r\n",p_len);
+            for( uint8_t i = 0; i < p_len; i++ ) {
+                pc.printf("%02X ",p_data[i]);
+            }
+            pc.printf("\r\n");
+            ret_val = true;
+#endif
+        }
+    }
+    
+    return ret_val;
+}
+
+void XBeeDeviceRemoteAt::SendCmd_uint8_t( const uint8_t        p_frameId,
+                                          const uint8_t* const p_data,
+                                          const uint8_t&       p_val )
+{
+     XBeeApiCmdAtRemoteSet<uint8_t> req( p_frameId, m_addr16Bit, m_addr64Bit, p_data, p_val );
+     m_device->SendFrame( &req );
+}
+
+void XBeeDeviceRemoteAt::SendCmd_uint16_t( const uint8_t        p_frameId,
+                                           const uint8_t* const p_data,
+                                           const uint16_t&      p_val )
+{
+     XBeeApiCmdAtRemoteSet<uint16_t> req( p_frameId, m_addr16Bit, m_addr64Bit, p_data, p_val );
+     m_device->SendFrame( &req );
+}
+
+void XBeeDeviceRemoteAt::SendReq( const uint8_t             p_frameId,
+                                  const uint8_t*            p_data )
+{
+    XBeeApiCmdAtRemoteReq req( p_frameId, m_addr16Bit, m_addr64Bit, p_data );
+    m_device->SendFrame( &req );
+}
+
+template < typename T >
+XBeeApiCmdAtRemoteSet<T>::XBeeApiCmdAtRemoteSet( const uint8_t        p_frameId,
+                                                 const uint16_t       p_addr16Bit,
+                                                 const uint64_t       p_addr64Bit,
+                                                 const uint8_t* const p_data,
+                                                 const T p_val ) : XBeeApiFrame( )
+{
+    size_t s;
+    uint8_t* dest;
+    const uint8_t* src = (uint8_t*)(&p_val);
+    
+    m_apiId = XBEE_CMD_REMOTE_AT_CMD;
+    
+    m_buffer[0] = p_frameId;
+    
+    m_buffer[1] = p_addr64Bit >> 56U;
+    m_buffer[2] = p_addr64Bit >> 48U;
+    m_buffer[3] = p_addr64Bit >> 40U;
+    m_buffer[4] = p_addr64Bit >> 32U;
+    m_buffer[5] = p_addr64Bit >> 24U;
+    m_buffer[6] = p_addr64Bit >> 16U;
+    m_buffer[7] = p_addr64Bit >> 8U;
+    m_buffer[8] = p_addr64Bit;
+
+    m_buffer[9] = p_addr16Bit >> 8U;
+    m_buffer[10] = p_addr16Bit;
+
+    m_buffer[11] = 0;
+
+    m_buffer[12] = p_data[0];
+    m_buffer[13] = p_data[1];
+    
+    m_dataLen = sizeof( m_buffer );
+
+    /* TODO: This copy code isn't portable - it's assuming that the data in 
+     * p_data is little endian */
+     
+    dest = &( m_buffer[ m_dataLen - 1 ] );
+    
+    for( s = 0;
+         s < sizeof( T );
+         s++, dest--, src++ ) {
+        *dest = *src;         
+    }
+    
+    m_data = m_buffer;
+}
+
+template < typename T >
+XBeeApiCmdAtRemoteSet<T>::~XBeeApiCmdAtRemoteSet()
+{
+}
+
+XBeeApiCmdAtRemoteReq::XBeeApiCmdAtRemoteReq( const uint8_t        p_frameId,
+                                              const uint16_t       p_addr16Bit,
+                                              const uint64_t       p_addr64Bit,
+                                              const uint8_t* const p_data )
+{
+    m_apiId = XBEE_CMD_REMOTE_AT_CMD;
+    
+    m_buffer[0] = p_frameId;
+    
+    m_buffer[1] = p_addr64Bit >> 56U;
+    m_buffer[2] = p_addr64Bit >> 48U;
+    m_buffer[3] = p_addr64Bit >> 40U;
+    m_buffer[4] = p_addr64Bit >> 32U;
+    m_buffer[5] = p_addr64Bit >> 24U;
+    m_buffer[6] = p_addr64Bit >> 16U;
+    m_buffer[7] = p_addr64Bit >> 8U;
+    m_buffer[8] = p_addr64Bit;
+
+    m_buffer[9] = p_addr16Bit >> 8U;
+    m_buffer[10] = p_addr16Bit;
+
+    m_buffer[11] = 0;
+
+    m_buffer[12] = p_data[0];
+    m_buffer[13] = p_data[1];
+    
+    m_dataLen = sizeof( m_buffer );
+    m_data = m_buffer;
+}
+
+XBeeApiCmdAtRemoteReq::~XBeeApiCmdAtRemoteReq()
+{
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Remote/XBeeDeviceRemoteAt.hpp	Sun Jul 13 15:47:40 2014 +0000
@@ -0,0 +1,69 @@
+/**
+   @file
+   @brief Class to provide an abstract representation of a remote
+          XBee device's AT command interface
+      
+   @author John Bailey 
+
+   @copyright Copyright 2014 John Bailey
+
+   @section LICENSE
+   
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+
+#if !defined XBEEDEVICEREMOTEAT_HPP
+#define      XBEEDEVICEREMOTEAT_HPP
+
+#include "XBeeApiCfg.hpp"
+#include "XBeeApiFrame.hpp"
+#include "XBeeApiCmdAt.hpp"
+
+/** */
+class XBeeDeviceRemoteAt : public XBeeApiCmdAt
+{
+    protected:
+        /** Called by XBeeDevice in order to offer frame data to the object for
+            decoding
+           
+            \param p_data Pointer to the content of the received data
+            \param p_len Length of the data pointed to by p_data
+        */
+        virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len );
+
+        virtual void SendCmd_uint8_t( const uint8_t        p_frameId,
+                                      const uint8_t* const p_data,
+                                      const uint8_t&       p_val );
+        virtual void SendCmd_uint16_t( const uint8_t        p_frameId,
+                                       const uint8_t* const p_data,
+                                       const uint16_t&       p_val );
+        virtual void SendReq( const uint8_t             p_frameId,
+                              const uint8_t*            p_data );
+
+        virtual size_t getResponseStatusPos( void ) const;
+
+        uint16_t m_addr16Bit;
+        uint64_t m_addr64Bit;
+
+    public:
+        /** Constructor */
+        XBeeDeviceRemoteAt( XBeeDevice* p_device,
+                            const uint16_t& p_addr16Bit,
+                            const uint64_t& p_addr64Bit );
+        
+        /** Destructor */
+        virtual ~XBeeDeviceRemoteAt( void ); 
+};
+
+#endif
\ No newline at end of file
--- a/Utility/XBeeApiCmdAt.cpp	Mon Jul 07 19:14:46 2014 +0000
+++ b/Utility/XBeeApiCmdAt.cpp	Sun Jul 13 15:47:40 2014 +0000
@@ -40,6 +40,14 @@
 #define CMD_RESPONSE_GET_RN  'h'
 #define CMD_RESPONSE_SET_MM  'i'
 #define CMD_RESPONSE_GET_MM  'j'
+#define CMD_RESPONSE_GET_D0  'k'
+#define CMD_RESPONSE_GET_D1  'l'
+#define CMD_RESPONSE_GET_D2  'm'
+#define CMD_RESPONSE_GET_D3  'n'
+#define CMD_RESPONSE_GET_D4  'o'
+#define CMD_RESPONSE_GET_D5  'p'
+#define CMD_RESPONSE_GET_D6  'q'
+#define CMD_RESPONSE_GET_D7  'r'
 
 /** Lowest channel supported by the XBee S1 */
 #define XBEE_CHAN_MIN 0x0b
@@ -53,41 +61,118 @@
 
 /* Content for the various commands - value of 0 indicates a value to be populated (i.e. variable) */
 
-static const uint8_t cmd_vr[] =      { CMD_RESPONSE_GET_VR, 'V', 'R' };
-static const uint8_t cmd_hv[] =      { CMD_RESPONSE_GET_HV, 'H', 'V' };
-static const uint8_t cmd_sh[] =      { CMD_RESPONSE_GET_SH, 'S', 'H' };
-static const uint8_t cmd_sl[] =      { CMD_RESPONSE_GET_SL, 'S', 'L' };
+static const uint8_t cmd_vr[] =       { 'V', 'R' };
+static const uint8_t cmd_vr_get_fid = CMD_RESPONSE_GET_VR;
+
+static const uint8_t cmd_hv[] =       { 'H', 'V' };
+static const uint8_t cmd_hv_get_fid = CMD_RESPONSE_GET_HV;
+
+static const uint8_t cmd_sh[] =       { 'S', 'H' };
+static const uint8_t cmd_sh_get_fid = CMD_RESPONSE_GET_SH;
+
+static const uint8_t cmd_sl[] =       { 'S', 'L' };
+static const uint8_t cmd_sl_get_fid = CMD_RESPONSE_GET_SL;
 
-static const uint8_t cmd_ch[] =      { CMD_RESPONSE_GET_CH, 'C', 'H' };
-static const uint8_t cmd_set_ch[] =  { CMD_RESPONSE_SET_CH, 'C', 'H', 0 };
+static const uint8_t cmd_ch[] =       { 'C', 'H' };
+static const uint8_t cmd_ch_get_fid = CMD_RESPONSE_GET_CH;
+static const uint8_t cmd_ch_set[] =   { 'C', 'H', 0 };
+static const uint8_t cmd_ch_set_fid = CMD_RESPONSE_SET_CH;
+
+static const uint8_t cmd_ce[] =       { 'C', 'E' };
+static const uint8_t cmd_ce_get_fid = CMD_RESPONSE_GET_CE;
+static const uint8_t cmd_ce_set[] =   { 'C', 'E', 0 };
+static const uint8_t cmd_ce_set_fid = CMD_RESPONSE_SET_CE;
 
-static const uint8_t cmd_ce[] =      { CMD_RESPONSE_GET_CE, 'C', 'E' };
-static const uint8_t cmd_set_ce[] =  { CMD_RESPONSE_SET_CE, 'C', 'E', 0 };
+static const uint8_t cmd_eda[] =       { 'A', '1' };
+static const uint8_t cmd_eda_get_fid = CMD_RESPONSE_GET_EDA;
+static const uint8_t cmd_eda_set[]   = { 'A', '1', 0 };
+static const uint8_t cmd_eda_set_fid = CMD_RESPONSE_SET_EDA;
 
-static const uint8_t cmd_eda[] =     { CMD_RESPONSE_GET_EDA, 'A', '1' };
-static const uint8_t cmd_set_eda[] = { CMD_RESPONSE_SET_EDA, 'A', '1', 0 };
+static const uint8_t cmd_pid[] =       { 'I', 'D' };
+static const uint8_t cmd_pid_get_fid = CMD_RESPONSE_GET_PID;
+static const uint8_t cmd_pid_set[] =   { 'I', 'D', 0, 0 };
+static const uint8_t cmd_pid_set_fid = CMD_RESPONSE_SET_PID;
 
-static const uint8_t cmd_pid[] =     { CMD_RESPONSE_GET_PID, 'I', 'D' };
-static const uint8_t cmd_set_pid[] = { CMD_RESPONSE_SET_PID, 'I', 'D', 0, 0 };
+static const uint8_t cmd_my[] =        { 'M', 'Y' };
+static const uint8_t cmd_my_get_fid =  CMD_RESPONSE_GET_MY;
+static const uint8_t cmd_my_set[] =    { 'M', 'Y', 0, 0 };
+static const uint8_t cmd_my_set_fid =  CMD_RESPONSE_SET_MY;
 
-static const uint8_t cmd_my[] =      { CMD_RESPONSE_GET_MY,  'M', 'Y' };
-static const uint8_t cmd_set_my[] =  { CMD_RESPONSE_SET_MY,  'M', 'Y', 0, 0 };
+static const uint8_t cmd_rr[] =        { 'R', 'R' };
+static const uint8_t cmd_rr_get_fid =  CMD_RESPONSE_GET_RR;
+static const uint8_t cmd_rr_set[] =    { 'R', 'R', 0 };
+static const uint8_t cmd_rr_set_fid =  CMD_RESPONSE_SET_RR;
+
+static const uint8_t cmd_rn[] =        { 'R', 'N' };
+static const uint8_t cmd_rn_get_fid =  CMD_RESPONSE_GET_RN;
+static const uint8_t cmd_rn_set[] =    { 'R', 'N', 0 };
+static const uint8_t cmd_rn_set_fid =  CMD_RESPONSE_SET_RN;
 
-static const uint8_t cmd_rr[] =      { CMD_RESPONSE_GET_RR,  'R', 'R' };
-static const uint8_t cmd_set_rr[] =  { CMD_RESPONSE_SET_RR,  'R', 'R', 0 };
+static const uint8_t cmd_mm[] =        { 'M', 'M' };
+static const uint8_t cmd_mm_get_fid =  CMD_RESPONSE_GET_MM;
+static const uint8_t cmd_mm_set[] =    { 'M', 'M', 0 };
+static const uint8_t cmd_mm_set_fid =  CMD_RESPONSE_SET_MM;
 
-static const uint8_t cmd_rn[] =      { CMD_RESPONSE_GET_RN,  'R', 'N' };
-static const uint8_t cmd_set_rn[] =  { CMD_RESPONSE_SET_RN,  'R', 'N', 0 };
+static const uint8_t cmd_d[ XBEE_API_DIO_CHANNEL_COUNT ][2] = {{ 'D', '0' },
+                                                               { 'D', '1' },
+                                                               { 'D', '2' },
+                                                               { 'D', '3' },
+                                                               { 'D', '4' },
+                                                               { 'D', '5' },
+                                                               { 'D', '6' },
+                                                               { 'D', '7' }};
+static const uint8_t cmd_d_get_fid[ XBEE_API_DIO_CHANNEL_COUNT ] =  { CMD_RESPONSE_GET_D0,
+                                                                      CMD_RESPONSE_GET_D1,
+                                                                      CMD_RESPONSE_GET_D2,
+                                                                      CMD_RESPONSE_GET_D3,
+                                                                      CMD_RESPONSE_GET_D4,
+                                                                      CMD_RESPONSE_GET_D5,
+                                                                      CMD_RESPONSE_GET_D6,
+                                                                      CMD_RESPONSE_GET_D7 };
 
-static const uint8_t cmd_mm[] =      { CMD_RESPONSE_GET_MM,  'M', 'M' };
-static const uint8_t cmd_set_mm[] =  { CMD_RESPONSE_SET_MM,  'M', 'M', 0 };
-
-#define XBEE_CMD_POSN_FRAME_ID (4U)
+#define XBEE_CMD_POSN_FRAME_ID XBEE_CMD_POSN_ID_SPECIFIC_DATA
 #define XBEE_CMD_POSN_STATUS (7U)
 #define XBEE_CMD_POSN_PARAM_START (8U)
 
 #define XBEE_CMD_RESPONS_HAS_DATA( _p_len ) ((_p_len > ( XBEE_CMD_POSN_PARAM_START + 1 ))
 
+/** Template class to create an XBeeApiFrame which can be used to change
+    the value of one of the XBee parameters.  This class is used by the
+    setXXX methods in XBeeApiCmdAt */
+template< typename T >
+class XBeeApiCmdAtSet : public XBeeApiFrame {
+    uint8_t m_buffer[ XBEE_API_CMD_SET_HEADER_LEN + sizeof( T ) ];
+    public:
+        /** Constructor
+                   
+            \param p_data Pointer to a buffer of length 2 bytes identifying
+                          the command, e.g. 'V', 'R' would set up a version
+                          request
+            \param p_val New value for the parameter 
+        */
+        XBeeApiCmdAtSet( const uint8_t        p_frameId,
+                         const uint8_t* const p_data,
+                         const T p_val );
+        /** Destructor */
+        virtual ~XBeeApiCmdAtSet();
+};
+
+class XBeeApiCmdAtReq : public XBeeApiFrame {
+    uint8_t m_buffer[ XBEE_API_CMD_REQ_HEADER_LEN ];
+    public:
+        /** Constructor
+                   
+            \param p_data Pointer to a buffer of length 2 bytes identifying
+                          the command, e.g. 'V', 'R' would set up a version
+                          request
+            \param p_val New value for the parameter 
+        */
+        XBeeApiCmdAtReq( const uint8_t        p_frameId,
+                         const uint8_t* const p_data );
+        /** Destructor */
+        virtual ~XBeeApiCmdAtReq();
+};
+
 XBeeApiCmdAt::XBeeApiCmdAt( XBeeDevice* const p_device ) : XBeeApiFrameDecoder( p_device ) , 
     m_have_hwVer( false ),
     m_have_fwVer( false ),
@@ -107,9 +192,9 @@
 #define PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, _src, _t ) \
             case CMD_RESPONSE_SET_ ## _type: \
             case CMD_RESPONSE_GET_ ## _type: \
-                if( p_data[ XBEE_CMD_POSN_STATUS ] == 0 ) \
+                if( p_data[ statusPosn ] == 0 ) \
                 { \
-                    if( CMD_RESPONSE_GET_ ## _type == p_data[ XBEE_CMD_POSN_API_ID ] ) \
+                    if( CMD_RESPONSE_GET_ ## _type == p_data[ XBEE_CMD_POSN_FRAME_ID ] ) \
                     { \
                         m_ ##_var = (_t) (_src); \
                     } \
@@ -128,7 +213,7 @@
 
 #define PROCESS_GET_RESPONSE_GENERIC( _type, _var, _src ) \
             case CMD_RESPONSE_GET_ ## _type: \
-                if( p_data[ XBEE_CMD_POSN_STATUS ] == 0 ) \
+                if( p_data[ statusPosn ] == 0 ) \
                 { \
                     m_ ##_var = _src; \
                     m_have_ ## _var = true; \
@@ -140,39 +225,56 @@
                 ret_val = true; \
                 break;
 
-#define PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( _type, _var, _t )  PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ XBEE_CMD_POSN_PARAM_START ], _t )
-#define PROCESS_SET_GET_RESPONSE_8BIT( _type, _var )               PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ XBEE_CMD_POSN_PARAM_START ], uint8_t )
-#define PROCESS_SET_GET_RESPONSE_16BIT( _type, _var )              PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ XBEE_CMD_POSN_PARAM_START ] << 8) | p_data[ XBEE_CMD_POSN_PARAM_START + 1 ], uint16_t )
+#define PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( _type, _var, _t )  PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ dataPosn ], _t )
+#define PROCESS_SET_GET_RESPONSE_8BIT( _type, _var )               PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ dataPosn ], uint8_t )
+#define PROCESS_SET_GET_RESPONSE_16BIT( _type, _var )              PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ dataPosn ] << 8) | p_data[ dataPosn + 1 ], uint16_t )
+
+#define PROCESS_GET_RESPONSE_16BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ dataPosn ] << 8) | p_data[ dataPosn + 1 ] )
+#define PROCESS_GET_RESPONSE_32BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint32_t)p_data[ dataPosn ] << 24) |\
+                                                                                             ((uint32_t)p_data[ dataPosn + 1 ] << 16) |\
+                                                                                             ((uint32_t)p_data[ dataPosn + 2 ] << 8) |\
+                                                                                             ((uint32_t)p_data[ dataPosn + 3 ]))
+
+size_t XBeeApiCmdAt::getResponseStatusPos( void ) const
+{
+    return XBEE_CMD_POSN_STATUS;
+}
 
-#define PROCESS_GET_RESPONSE_16BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint16_t)p_data[ XBEE_CMD_POSN_PARAM_START ] << 8) | p_data[ XBEE_CMD_POSN_PARAM_START + 1 ] )
-#define PROCESS_GET_RESPONSE_32BIT( _type, _var ) PROCESS_GET_RESPONSE_GENERIC( _type, _var, ((uint32_t)p_data[ XBEE_CMD_POSN_PARAM_START ] << 24) |\
-                                                                                             ((uint32_t)p_data[ XBEE_CMD_POSN_PARAM_START + 1 ] << 16) |\
-                                                                                             ((uint32_t)p_data[ XBEE_CMD_POSN_PARAM_START + 2 ] << 8) |\
-                                                                                             ((uint32_t)p_data[ XBEE_CMD_POSN_PARAM_START + 3 ]))
+bool XBeeApiCmdAt::processResponseFrame( const uint8_t* const p_data, size_t p_len )
+{
+    bool ret_val = false;
+    size_t statusPosn = getResponseStatusPos();
+    size_t dataPosn = statusPosn + 1;
+    
+    switch( p_data[ XBEE_CMD_POSN_FRAME_ID ] ) 
+    {
+        
+        PROCESS_GET_RESPONSE_16BIT( HV, hwVer )
+        PROCESS_GET_RESPONSE_16BIT( VR, fwVer )
+        
+        PROCESS_SET_GET_RESPONSE_8BIT( CH, chan )
+        PROCESS_SET_GET_RESPONSE_8BIT( CE, CE )
+        PROCESS_SET_GET_RESPONSE_16BIT( PID, PANId )
+        PROCESS_SET_GET_RESPONSE_8BIT( EDA, EDA )
+        PROCESS_SET_GET_RESPONSE_8BIT( RR, retries )
+        PROCESS_SET_GET_RESPONSE_16BIT( MY, sourceAddress )
+        PROCESS_GET_RESPONSE_32BIT( SH, snHigh )
+        PROCESS_GET_RESPONSE_32BIT( SL, snLow )
+        PROCESS_SET_GET_RESPONSE_8BIT( RN, randomDelaySlots )
+        PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( MM, macMode, XBeeApiMACMode_e )
+        /* TODO: Add D0, D1, D2 response handling */
+    }
 
+    return ret_val;
+}
 
 bool XBeeApiCmdAt::decodeCallback( const uint8_t* const p_data, size_t p_len )
 {
     bool ret_val = false;
 
-    if( XBEE_CMD_AT_RESPONSE == p_data[ XBEE_CMD_POSN_API_ID ] ) {
-
-        switch( p_data[ XBEE_CMD_POSN_FRAME_ID ] ) {
-            
-            PROCESS_GET_RESPONSE_16BIT( HV, hwVer )
-            PROCESS_GET_RESPONSE_16BIT( VR, fwVer )
-            
-            PROCESS_SET_GET_RESPONSE_8BIT( CH, chan )
-            PROCESS_SET_GET_RESPONSE_8BIT( CE, CE )
-            PROCESS_SET_GET_RESPONSE_8BIT( PID, PANId )
-            PROCESS_SET_GET_RESPONSE_8BIT( EDA, EDA )
-            PROCESS_SET_GET_RESPONSE_8BIT( RR, retries )
-            PROCESS_SET_GET_RESPONSE_16BIT( MY, sourceAddress )
-            PROCESS_GET_RESPONSE_32BIT( SH, snHigh )
-            PROCESS_GET_RESPONSE_32BIT( SL, snLow )
-            PROCESS_SET_GET_RESPONSE_8BIT( RN, randomDelaySlots )
-            PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( MM, macMode, XBeeApiMACMode_e )
-        }
+    if( XBEE_CMD_AT_RESPONSE == p_data[ XBEE_CMD_POSN_API_ID ] ) 
+    {
+        ret_val = processResponseFrame( p_data, p_len );
     }
     return ret_val;
 }
@@ -188,45 +290,62 @@
         ( p_chan >= XBEE_PRO_CHAN_MIN ) &&
         ( p_chan <= XBEE_PRO_CHAN_MAX )))
     {
-        XBeeApiCmdAtSet<uint8_t> req( cmd_set_ch, p_chan );
-    
         m_chanPend = p_chan;
-        m_device->SendFrame( &req );
+        SendCmd_uint8_t( cmd_ch_set_fid, cmd_ch_set, p_chan );    
         ret_val = true;
     }
     return ret_val;
 }
 
+void XBeeApiCmdAt::SendReq( const uint8_t             p_frameId,
+                            const uint8_t*            p_data )
+{
+    XBeeApiCmdAtReq req( p_frameId, p_data );
+    m_device->SendFrame( &req );
+}
+
+
 #define MAKE_REQUEST( _name, _mnemonic, _cmd ) \
 bool XBeeApiCmdAt::request ## _name( void ) \
 {\
-    XBeeApiFrame req( XBEE_CMD_AT_CMD, _cmd, sizeof( _cmd ));\
-    m_have_ ## _mnemonic = false;\
-    m_device->SendFrame( &req );\
+    m_have_ ## _mnemonic = false;   \
+    SendReq( _cmd ## _get_fid, _cmd ); \
     return true;\
 }
 
-MAKE_REQUEST( HardwareVersion, hwVer, cmd_hv )
-MAKE_REQUEST( FirmwareVersion, fwVer, cmd_vr )
-MAKE_REQUEST( Channel, chan, cmd_ch )
-MAKE_REQUEST( PanId, PANId, cmd_pid )
-MAKE_REQUEST( CoordinatorEnabled, CE, cmd_ce )
-MAKE_REQUEST( EndDeviceAssociationEnabled, EDA, cmd_eda )
-MAKE_REQUEST( SourceAddress, sourceAddress, cmd_my )
-MAKE_REQUEST( Retries, retries, cmd_rr )
-MAKE_REQUEST( RandomDelaySlots, randomDelaySlots, cmd_rn )
-MAKE_REQUEST( MacMode, macMode, cmd_mm );
+MAKE_REQUEST( HardwareVersion,             hwVer,            cmd_hv )
+MAKE_REQUEST( FirmwareVersion,             fwVer,            cmd_vr )
+MAKE_REQUEST( Channel,                     chan,             cmd_ch )
+MAKE_REQUEST( PanId,                       PANId,            cmd_pid )
+MAKE_REQUEST( CoordinatorEnabled,          CE,               cmd_ce )
+MAKE_REQUEST( EndDeviceAssociationEnabled, EDA,              cmd_eda )
+MAKE_REQUEST( SourceAddress,               sourceAddress,    cmd_my )
+MAKE_REQUEST( Retries,                     retries,          cmd_rr )
+MAKE_REQUEST( RandomDelaySlots,            randomDelaySlots, cmd_rn )
+MAKE_REQUEST( MacMode,                     macMode,          cmd_mm );
+MAKE_REQUEST( SerialNumberHigh,            snHigh,           cmd_sh );
+MAKE_REQUEST( SerialNumberLow,             snLow,            cmd_sl );
 
 bool XBeeApiCmdAt::requestSerialNumber( void )
 {
-    XBeeApiFrame req1( XBEE_CMD_AT_CMD, cmd_sh, sizeof( cmd_sh ));
-    XBeeApiFrame req2( XBEE_CMD_AT_CMD, cmd_sl, sizeof( cmd_sl ));
-    m_have_snHigh = m_have_snLow = false;
-    m_device->SendFrame( &req1 );
-    m_device->SendFrame( &req2 );
+    requestSerialNumberHigh();
+    requestSerialNumberLow();
     return true;
 }
 
+bool XBeeApiCmdAt::requestDioConfig( const uint8_t p_chanNo )
+{
+    bool ret_val = false;
+    if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
+    {
+        m_have_d[ p_chanNo ] = false;   
+        SendReq( cmd_d_get_fid[ p_chanNo ], cmd_d[ p_chanNo ] );
+        ret_val = true;
+    }
+    return ret_val;
+}
+
+
 #define MAKE_GET(_name, _mnemonic, _type ) \
 bool XBeeApiCmdAt::get ## _name( _type* const p_param ) \
 {\
@@ -236,16 +355,16 @@
     return m_have_ ## _mnemonic; \
 }
 
-MAKE_GET( FirmwareVersion, fwVer, uint16_t )
-MAKE_GET( HardwareVersion, hwVer, uint16_t )
-MAKE_GET( Channel, chan, uint8_t )
-MAKE_GET( CoordinatorEnabled, CE, bool );
-MAKE_GET( EndDeviceAssociationEnabled, EDA, bool )
-MAKE_GET( PanId, PANId, panId_t )
-MAKE_GET( SourceAddress, sourceAddress, uint16_t )
-MAKE_GET( Retries, retries, uint8_t )
-MAKE_GET( RandomDelaySlots, randomDelaySlots, uint8_t )
-MAKE_GET( MacMode, macMode, XBeeApiMACMode_e )
+MAKE_GET( FirmwareVersion,             fwVer,            uint16_t )
+MAKE_GET( HardwareVersion,             hwVer,            uint16_t )
+MAKE_GET( Channel,                     chan,             uint8_t )
+MAKE_GET( CoordinatorEnabled,          CE,               bool )
+MAKE_GET( EndDeviceAssociationEnabled, EDA,              bool )
+MAKE_GET( PanId,                       PANId,            panId_t )
+MAKE_GET( SourceAddress,               sourceAddress,    uint16_t )
+MAKE_GET( Retries,                     retries,          uint8_t )
+MAKE_GET( RandomDelaySlots,            randomDelaySlots, uint8_t )
+MAKE_GET( MacMode,                     macMode,          XBeeApiMACMode_e )
 
 bool XBeeApiCmdAt::getSerialNumber( uint64_t* const p_sn )
 {
@@ -260,24 +379,65 @@
     return( have_sn );
 }
 
-#define MAKE_SET( _name, _mnemonic, _cmd, _type ) \
+bool XBeeApiCmdAt::getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf )
+{
+    bool ret_val = false;
+    if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
+    {
+        if( m_have_d[ p_chanNo ] )
+        {
+            *p_conf = m_d[ p_chanNo ];
+            ret_val = true;
+        }
+    }
+    return ret_val;   
+}
+
+#define MAKE_SET( _name, _mnemonic, _cmd, _type, _transmit_type ) \
 bool XBeeApiCmdAt::set ## _name( const _type p_param ) \
 {\
-    XBeeApiCmdAtSet<_type> req( _cmd, p_param );\
-\
     m_have_ ## _mnemonic = false;\
     m_## _mnemonic ## Pend = p_param;\
-    m_device->SendFrame( &req );\
+    SendCmd_ ## _transmit_type ( _cmd ## _fid, _cmd, p_param ); \
     return true;\
 }
 
-MAKE_SET( CoordinatorEnabled,          CE,               cmd_set_ce,  bool )
-MAKE_SET( EndDeviceAssociationEnabled, EDA,              cmd_set_eda, bool )
-MAKE_SET( PanId,                       PANId,            cmd_set_pid, panId_t )
-MAKE_SET( SourceAddress,               sourceAddress,    cmd_set_my,  uint16_t )
-MAKE_SET( Retries,                     retries,          cmd_set_rr,  uint8_t )
-MAKE_SET( RandomDelaySlots,            randomDelaySlots, cmd_set_rn,  uint8_t )
-MAKE_SET( MacMode,                     macMode,          cmd_set_mm,  XBeeApiMACMode_e )
+MAKE_SET( CoordinatorEnabled,          CE,               cmd_ce_set,  bool,             uint8_t )
+MAKE_SET( EndDeviceAssociationEnabled, EDA,              cmd_eda_set, bool,             uint8_t )
+MAKE_SET( PanId,                       PANId,            cmd_pid_set, uint16_t,         uint16_t )
+MAKE_SET( SourceAddress,               sourceAddress,    cmd_my_set,  uint16_t,         uint16_t )
+MAKE_SET( Retries,                     retries,          cmd_rr_set,  uint8_t,          uint16_t )
+MAKE_SET( RandomDelaySlots,            randomDelaySlots, cmd_rn_set,  uint8_t,          uint16_t )
+MAKE_SET( MacMode,                     macMode,          cmd_mm_set,  XBeeApiMACMode_e, uint8_t )
+
+
+bool XBeeApiCmdAt::setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf )
+{
+    bool ret_val = false;
+    if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
+    {
+        m_have_d[ p_chanNo ] = false;
+        m_dPend[ p_chanNo ] = p_conf;
+        SendCmd_uint8_t( cmd_d_get_fid[ p_chanNo ], cmd_d[ p_chanNo ], p_conf );
+    }
+    return ret_val;   
+}
+
+void XBeeApiCmdAt::SendCmd_uint8_t( const uint8_t        p_frameId,
+                                    const uint8_t* const p_data,
+                                    const uint8_t&       p_val )
+{
+     XBeeApiCmdAtSet<uint8_t> req( p_frameId, p_data, p_val );
+     m_device->SendFrame( &req );
+}
+
+void XBeeApiCmdAt::SendCmd_uint16_t( const uint8_t        p_frameId,
+                                     const uint8_t* const p_data,
+                                     const uint16_t&       p_val )
+{
+     XBeeApiCmdAtSet<uint16_t> req( p_frameId, p_data, p_val );
+     m_device->SendFrame( &req );
+}
 
 XBeeApiCmdAtBlocking::XBeeApiCmdAtBlocking( XBeeDevice* const p_device, const uint16_t p_timeout, const uint16_t p_slice ) :
     XBeeApiCmdAt( p_device ),
@@ -501,11 +661,22 @@
                   XBeeApiMACMode_e );
 }
 
+bool XBeeApiCmdAtBlocking::getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf )
+{
+    /* TODO */
+    return false;
+}
 
+bool XBeeApiCmdAtBlocking::setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf )
+{
+    /* TODO */
+    return false;
+}
 
 template < typename T >
-XBeeApiCmdAt::XBeeApiCmdAtSet<T>::XBeeApiCmdAtSet( const uint8_t* const p_data,
-                                                   const T p_val ) : XBeeApiFrame( )
+XBeeApiCmdAtSet<T>::XBeeApiCmdAtSet( const uint8_t        p_frameId,
+                                     const uint8_t* const p_data,
+                                                    const T p_val ) : XBeeApiFrame( )
 {
     size_t s;
     uint8_t* dest;
@@ -513,9 +684,9 @@
     
     m_apiId = XBEE_CMD_AT_CMD;
     
-    m_buffer[0] = p_data[0];
-    m_buffer[1] = p_data[1];
-    m_buffer[2] = p_data[2];
+    m_buffer[0] = p_frameId;
+    m_buffer[1] = p_data[0];
+    m_buffer[2] = p_data[1];
     
     m_dataLen = sizeof( m_buffer );
 
@@ -530,9 +701,27 @@
         *dest = *src;         
     }
     
-    m_data = m_buffer;}
+    m_data = m_buffer;
+}
 
 template < typename T >
-XBeeApiCmdAt::XBeeApiCmdAtSet<T>::~XBeeApiCmdAtSet()
+XBeeApiCmdAtSet<T>::~XBeeApiCmdAtSet()
+{
+}
+
+XBeeApiCmdAtReq::XBeeApiCmdAtReq( const uint8_t        p_frameId,
+                                  const uint8_t* const p_data )
+{
+    m_apiId = XBEE_CMD_AT_CMD;
+    
+    m_buffer[0] = p_frameId;
+    m_buffer[1] = p_data[0];
+    m_buffer[2] = p_data[1];
+    
+    m_dataLen = sizeof( m_buffer );
+    m_data = m_buffer;
+}
+
+XBeeApiCmdAtReq::~XBeeApiCmdAtReq()
 {
 }
\ No newline at end of file
--- a/Utility/XBeeApiCmdAt.hpp	Mon Jul 07 19:14:46 2014 +0000
+++ b/Utility/XBeeApiCmdAt.hpp	Sun Jul 13 15:47:40 2014 +0000
@@ -37,6 +37,9 @@
 #include <stdint.h>
 
 #define XBEE_API_CMD_SET_HEADER_LEN 3U
+#define XBEE_API_CMD_REQ_HEADER_LEN 3U
+
+#define XBEE_API_DIO_CHANNEL_COUNT 8U
 
 /** Class to access the configuration interface of the XBee.
     Requests to the XBee are non-blocking meaning that code
@@ -63,6 +66,17 @@
             XBEE_API_MAC_MODE_DIGI_NO_ACK     = 3,
         } XBeeApiMACMode_e;
     
+        typedef enum
+        {
+            XBEE_API_DIO_DISABLED             = 0,
+            XBEE_API_DIO_SPECIAL              = 1,
+            XBEE_API_DIO_INPUT                = 3,
+            XBEE_API_DIO_OUT_LOW              = 4,
+            XBEE_API_DIO_OUT_HIGH             = 5,
+            XBEE_API_DIO_RS485_TX_LOW         = 6,
+            XBEE_API_DIO_RS485_TX_HIGH        = 7
+        } XBeeApiDioConfig_e;
+    
     protected:
         /** Indicates whether or not m_hwVer contains data retrieved from the XBee */
         bool m_have_hwVer;
@@ -82,6 +96,7 @@
         bool m_have_retries;
         bool m_have_randomDelaySlots;
         bool m_have_macMode;
+        bool m_have_d[ XBEE_API_DIO_CHANNEL_COUNT ];
         
         uint16_t m_hwVer;
         uint16_t m_fwVer;
@@ -101,33 +116,28 @@
         uint8_t  m_retriesPend;
         uint8_t  m_randomDelaySlots;
         uint8_t  m_randomDelaySlotsPend;
-        XBeeApiMACMode_e m_macMode;
-        XBeeApiMACMode_e m_macModePend;
+        XBeeApiMACMode_e   m_macMode;
+        XBeeApiMACMode_e   m_macModePend;
+        XBeeApiDioConfig_e m_d[ XBEE_API_DIO_CHANNEL_COUNT ];
+        XBeeApiDioConfig_e m_dPend[ XBEE_API_DIO_CHANNEL_COUNT ];
 
-        /** Template class to create an XBeeApiFrame which can be used to change
-            the value of one of the XBee parameters.  This class is used by the
-            setXXX methods in XBeeApiCmdAt */
-        template< typename T >
-        class XBeeApiCmdAtSet : public XBeeApiFrame {
-            uint8_t m_buffer[ XBEE_API_CMD_SET_HEADER_LEN + sizeof( T ) ];
-            public:
-                /** Constructor
-                   
-                    \param p_data Pointer to a buffer of length 3 bytes containing a 
-                                  single byte frame ID followed by 2 bytes identifying
-                                  the command, e.g. '0', 'V', 'R' would set up a version
-                                  request with a frame identifier of 48 (ASCII value of 
-                                  '0').
-                    \param p_val New value for the parameter 
-                */
-                XBeeApiCmdAtSet( const uint8_t* const p_data,
-                                 const T p_val );
-                /** Destructor */
-                virtual ~XBeeApiCmdAtSet();
-        };
+        virtual void SendCmd_uint8_t( const uint8_t        p_frameId,
+                                      const uint8_t* const p_data,
+                                      const uint8_t&       p_val );
+        virtual void SendCmd_uint16_t( const uint8_t        p_frameId,
+                                       const uint8_t* const p_data,
+                                       const uint16_t&       p_val );
+        virtual void SendReq( const uint8_t             p_frameId,
+                              const uint8_t*            p_data );
 
-       /* Implement XBeeApiCmdDecoder interface */
-       virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len );
+        virtual size_t getResponseStatusPos( void ) const;
+
+
+        /* Implement XBeeApiCmdDecoder interface */
+        virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len );
+
+        virtual bool processResponseFrame( const uint8_t* const p_data, size_t p_len );
+
 
     public:
 
@@ -151,6 +161,11 @@
         bool requestPanId( void );
         bool requestSourceAddress( void );
         bool requestSerialNumber( void );
+        bool requestSerialNumberHigh( void );
+        bool requestSerialNumberLow( void );
+        bool requestDioConfig( const uint8_t p_chanNo );
+
+        
         /** Request the number of retries the XBee is configured to make.
             Note that the 802.15.4 MAC already allows 3 retries, so this parameter
             specifies an additional multiple of 3 retries
@@ -205,7 +220,10 @@
         virtual bool setRandomDelaySlots( const uint8_t p_addr );       
 
         virtual bool getMacMode( XBeeApiMACMode_e* const p_mode );       
-        virtual bool setMacMode( const XBeeApiMACMode_e p_mode );       
+        virtual bool setMacMode( const XBeeApiMACMode_e p_mode );  
+        
+        virtual bool getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf );
+        virtual bool setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf );
 };
 
 /** Class to access the configuration interface of the XBee.
@@ -249,24 +267,24 @@
  
        /* Implement XBeeApiCmdAt's virtual methods */
        
-       virtual bool getHardwareVersion( uint16_t* const p_ver );
-       virtual bool getFirmwareVersion( uint16_t* const p_ver );
+        virtual bool getHardwareVersion( uint16_t* const p_ver );
+        virtual bool getFirmwareVersion( uint16_t* const p_ver );
         virtual bool getSerialNumber( uint64_t* const p_sn );
 
-       virtual bool getChannel( uint8_t* const p_chan );
-       virtual bool setChannel( uint8_t const p_chan );
+        virtual bool getChannel( uint8_t* const p_chan );
+        virtual bool setChannel( uint8_t const p_chan );
         
-       virtual bool getCoordinatorEnabled( bool* constp_en );
-       virtual bool setCoordinatorEnabled( const bool p_en );
+        virtual bool getCoordinatorEnabled( bool* constp_en );
+        virtual bool setCoordinatorEnabled( const bool p_en );
        
-       virtual bool getEndDeviceAssociationEnabled( bool* const p_en ); 
-       virtual bool setEndDeviceAssociationEnabled( const bool p_en  );
+        virtual bool getEndDeviceAssociationEnabled( bool* const p_en ); 
+        virtual bool setEndDeviceAssociationEnabled( const bool p_en  );
        
-       virtual bool getPanId( panId_t* const p_id );       
-       virtual bool setPanId( const panId_t p_id );
+        virtual bool getPanId( panId_t* const p_id );       
+        virtual bool setPanId( const panId_t p_id );
 
-       virtual bool getSourceAddress( uint16_t* const p_addr );       
-       virtual bool setSourceAddress( const uint16_t p_addr );  
+        virtual bool getSourceAddress( uint16_t* const p_addr );       
+        virtual bool setSourceAddress( const uint16_t p_addr );  
        
         virtual bool getRetries( uint8_t* const p_addr );       
         virtual bool setRetries( const uint8_t p_addr );       
@@ -275,7 +293,11 @@
         virtual bool setRandomDelaySlots( const uint8_t p_addr );       
 
         virtual bool getMacMode( XBeeApiMACMode_e* const p_mode );       
-        virtual bool setMacMode( const XBeeApiMACMode_e p_mode );       
+        virtual bool setMacMode( const XBeeApiMACMode_e p_mode );  
+        
+        virtual bool getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf );
+        virtual bool setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf );
+     
 };
 
 #endif
\ No newline at end of file
--- a/Utility/xbeeapi.hpp	Mon Jul 07 19:14:46 2014 +0000
+++ b/Utility/xbeeapi.hpp	Sun Jul 13 15:47:40 2014 +0000
@@ -35,5 +35,6 @@
 #include "XBeeApiCmdAt.hpp"
 #include "XBeeApiSetupHelper.hpp"
 #include "XBeeApiRxFrameDecoder.hpp"
+#include "XBeeDeviceRemoteAt.hpp"
 
 #endif
\ No newline at end of file