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.

Revision:
51:a7d0d2ef9261
Parent:
50:f76b7e7959a2
Child:
52:0950b05d5270
--- a/Utility/XBeeApiCmdAt.cpp	Sun Jul 13 15:47:40 2014 +0000
+++ b/Utility/XBeeApiCmdAt.cpp	Mon Jul 28 10:24:16 2014 +0000
@@ -48,6 +48,27 @@
 #define CMD_RESPONSE_GET_D5  'p'
 #define CMD_RESPONSE_GET_D6  'q'
 #define CMD_RESPONSE_GET_D7  'r'
+#define CMD_RESPONSE_SET_D0  's'
+#define CMD_RESPONSE_SET_D1  't'
+#define CMD_RESPONSE_SET_D2  'u'
+#define CMD_RESPONSE_SET_D3  'v'
+#define CMD_RESPONSE_SET_D4  'w'
+#define CMD_RESPONSE_SET_D5  'x'
+#define CMD_RESPONSE_SET_D6  'y'
+#define CMD_RESPONSE_SET_D7  'z'
+#define CMD_RESPONSE_SET_IC  'A'
+#define CMD_RESPONSE_GET_IC  'B'
+#define CMD_RESPONSE_SET_IO  'C'
+#define CMD_RESPONSE_SET_IR  'D'
+#define CMD_RESPONSE_GET_IR  'E'
+#define CMD_RESPONSE_SET_DH  'F'
+#define CMD_RESPONSE_GET_DH  'G'
+#define CMD_RESPONSE_SET_DL  'H'
+#define CMD_RESPONSE_GET_DL  'I'
+#define CMD_RESPONSE_SET_WR  'J'
+#define CMD_RESPONSE_SET_AC  'K'
+#define CMD_RESPONSE_SET_FR  'L'
+#define CMD_RESPONSE_SET_IS  'M'
 
 /** Lowest channel supported by the XBee S1 */
 #define XBEE_CHAN_MIN 0x0b
@@ -113,6 +134,41 @@
 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_ic[] =        { 'I', 'C' };
+static const uint8_t cmd_ic_get_fid =  CMD_RESPONSE_GET_IC;
+static const uint8_t cmd_ic_set[] =    { 'I', 'C', 0 };
+static const uint8_t cmd_ic_set_fid =  CMD_RESPONSE_SET_IC;
+
+static const uint8_t cmd_io_set[] =    { 'I', 'O', 0 };
+static const uint8_t cmd_io_set_fid =  CMD_RESPONSE_SET_IO;
+
+static const uint8_t cmd_ir[] =        { 'I', 'R' };
+static const uint8_t cmd_ir_get_fid =  CMD_RESPONSE_GET_IR;
+static const uint8_t cmd_ir_set[] =    { 'I', 'R', 0, 0 };
+static const uint8_t cmd_ir_set_fid =  CMD_RESPONSE_SET_IR;
+
+static const uint8_t cmd_dh[] =        { 'D', 'H' };
+static const uint8_t cmd_dh_get_fid =  CMD_RESPONSE_GET_DH;
+static const uint8_t cmd_dh_set[] =    { 'D', 'H', 0, 0, 0, 0 };
+static const uint8_t cmd_dh_set_fid =  CMD_RESPONSE_SET_DH;
+
+static const uint8_t cmd_dl[] =        { 'D', 'L' };
+static const uint8_t cmd_dl_get_fid =  CMD_RESPONSE_GET_DL;
+static const uint8_t cmd_dl_set[] =    { 'D', 'L', 0, 0, 0, 0 };
+static const uint8_t cmd_dl_set_fid =  CMD_RESPONSE_SET_DL;
+
+static const uint8_t cmd_wr[] =        { 'W', 'R' };
+static const uint8_t cmd_wr_set_fid =  CMD_RESPONSE_SET_WR;
+
+static const uint8_t cmd_ac[] =        { 'A', 'C' };
+static const uint8_t cmd_ac_set_fid =  CMD_RESPONSE_SET_AC;
+
+static const uint8_t cmd_fr[] =        { 'F', 'R' };
+static const uint8_t cmd_fr_set_fid =  CMD_RESPONSE_SET_FR;
+
+static const uint8_t cmd_is[] =        { 'I', 'S' };
+static const uint8_t cmd_is_set_fid =  CMD_RESPONSE_SET_IS;
+
 static const uint8_t cmd_d[ XBEE_API_DIO_CHANNEL_COUNT ][2] = {{ 'D', '0' },
                                                                { 'D', '1' },
                                                                { 'D', '2' },
@@ -185,24 +241,55 @@
     m_have_snHigh( false ),
     m_have_retries( false ),
     m_have_randomDelaySlots( false ),
-    m_have_macMode( false )
+    m_have_macMode( false ),
+    m_have_dioChangeDetectMask( false ),
+    m_have_dioLevels( false ),
+    m_have_sampleRate( false ),
+    m_have_destHigh( false ),
+    m_have_destLow ( false ),
+    m_writeCount( 0 ),
+    m_applyCount( 0 ),
+    m_resetCount( 0 ),
+    m_sampleCount( 0 )
 {
+    for( uint8_t i = 0;
+         i < XBEE_API_DIO_CHANNEL_COUNT;
+         i++ )
+    {
+        m_have_d[ i ] = false;
+    }
 }
 
-#define PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, _src, _t ) \
+#define RESPONSE_OK( _data ) (_data[ statusPosn ] == 0)
+
+#define PROCESS_SET_RESPONSE( _type, _var ) \
+            case CMD_RESPONSE_SET_ ## _type: \
+                if( RESPONSE_OK( p_data )) \
+                { \
+                    m_ ## _var = m_ ## _var ## Pend; \
+                    m_have_ ## _var = true; \
+                } \
+                else \
+                { \
+                    /* TODO */ \
+                } \
+                ret_val = true; \
+                break;
+
+#define PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, _src, _t, _sfx ) \
             case CMD_RESPONSE_SET_ ## _type: \
             case CMD_RESPONSE_GET_ ## _type: \
-                if( p_data[ statusPosn ] == 0 ) \
+                if( RESPONSE_OK( p_data )) \
                 { \
                     if( CMD_RESPONSE_GET_ ## _type == p_data[ XBEE_CMD_POSN_FRAME_ID ] ) \
                     { \
-                        m_ ##_var = (_t) (_src); \
+                        m_ ##_var ##_sfx = (_t) (_src); \
                     } \
                     else \
                     { \
-                        m_ ## _var = m_ ## _var ## Pend; \
+                        m_ ##_var ##_sfx = m_ ## _var ## Pend ## _sfx; \
                     } \
-                    m_have_ ## _var = true; \
+                    m_have_ ##_var ##_sfx = true; \
                 } \
                 else \
                 { \
@@ -213,7 +300,7 @@
 
 #define PROCESS_GET_RESPONSE_GENERIC( _type, _var, _src ) \
             case CMD_RESPONSE_GET_ ## _type: \
-                if( p_data[ statusPosn ] == 0 ) \
+                if( RESPONSE_OK( p_data )) \
                 { \
                     m_ ##_var = _src; \
                     m_have_ ## _var = true; \
@@ -225,9 +312,13 @@
                 ret_val = true; \
                 break;
 
-#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_SET_GET_RESPONSE_8BIT_WITHCAST( _type, _var, _t, _sfx )  PROCESS_SET_GET_RESPONSE_GENERIC( _type, _var, p_data[ dataPosn ], _t, _sfx )
+#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_SET_GET_RESPONSE_32BIT( _type, _var )              PROCESS_SET_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 ]), uint32_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) |\
@@ -248,7 +339,34 @@
     
     switch( p_data[ XBEE_CMD_POSN_FRAME_ID ] ) 
     {
-        
+        case CMD_RESPONSE_SET_WR:
+            if( RESPONSE_OK( p_data )) 
+            {
+                m_writeCount++;
+            }
+            ret_val = true;
+            break;
+        case CMD_RESPONSE_SET_AC:
+            if( RESPONSE_OK( p_data )) 
+            {
+                m_applyCount++;
+            }
+            ret_val = true;
+            break;
+        case CMD_RESPONSE_SET_FR:
+            if( RESPONSE_OK( p_data )) 
+            {
+                m_resetCount++;
+            }
+            ret_val = true;
+            break;
+        case CMD_RESPONSE_SET_IS:
+            if( RESPONSE_OK( p_data )) 
+            {
+                m_sampleCount++;
+            }
+            ret_val = true;
+            break;
         PROCESS_GET_RESPONSE_16BIT( HV, hwVer )
         PROCESS_GET_RESPONSE_16BIT( VR, fwVer )
         
@@ -260,9 +378,15 @@
         PROCESS_SET_GET_RESPONSE_16BIT( MY, sourceAddress )
         PROCESS_GET_RESPONSE_32BIT( SH, snHigh )
         PROCESS_GET_RESPONSE_32BIT( SL, snLow )
+        PROCESS_SET_GET_RESPONSE_32BIT( DH, destHigh )
+        PROCESS_SET_GET_RESPONSE_32BIT( DL, destLow )
         PROCESS_SET_GET_RESPONSE_8BIT( RN, randomDelaySlots )
-        PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( MM, macMode, XBeeApiMACMode_e )
+        PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( MM, macMode, XBeeApiMACMode_e,  )
         /* TODO: Add D0, D1, D2 response handling */
+        PROCESS_SET_GET_RESPONSE_8BIT_WITHCAST( D0, d, XBeeApiDioConfig_e, [0] )
+        PROCESS_SET_GET_RESPONSE_8BIT( IC, dioChangeDetectMask )
+        PROCESS_SET_RESPONSE( IO, dioLevels )
+        PROCESS_SET_GET_RESPONSE_16BIT( IR, sampleRate )
     }
 
     return ret_val;
@@ -313,18 +437,46 @@
     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( SerialNumberHigh,            snHigh,           cmd_sh );
-MAKE_REQUEST( SerialNumberLow,             snLow,            cmd_sl );
+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 )
+MAKE_REQUEST( DioChangeDetectMask,         dioChangeDetectMask, cmd_ic )
+MAKE_REQUEST( SampleRate,                  sampleRate,          cmd_ir )
+MAKE_REQUEST( DestinationAddressHigh,      destHigh,            cmd_dh )
+MAKE_REQUEST( DestinationAddressLow,       destLow,             cmd_dl )
+
+bool XBeeApiCmdAt::requestWriteSettings( void )
+{
+    SendReq( cmd_wr_set_fid, cmd_wr );
+    return true;
+}
+
+bool XBeeApiCmdAt::requestApplyChanges( void )
+{
+    SendReq( cmd_ac_set_fid, cmd_ac );
+    return true;
+}
+
+bool XBeeApiCmdAt::requestReset( void )
+{
+    SendReq( cmd_fr_set_fid, cmd_fr );
+    return true;
+}
+
+bool XBeeApiCmdAt::requestForceSample( void )
+{
+    SendReq( cmd_is_set_fid, cmd_is );
+    return true;
+}
 
 bool XBeeApiCmdAt::requestSerialNumber( void )
 {
@@ -333,6 +485,13 @@
     return true;
 }
 
+bool XBeeApiCmdAt::requestDestinationAddress( void )
+{
+    requestDestinationAddressHigh();
+    requestDestinationAddressLow();
+    return true;
+}
+
 bool XBeeApiCmdAt::requestDioConfig( const uint8_t p_chanNo )
 {
     bool ret_val = false;
@@ -355,16 +514,21 @@
     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 )
+MAKE_GET( DioChangeDetectMask,         dioChangeDetectMask, uint8_t )
+MAKE_GET( DioLevels,                   dioLevels,           uint8_t )
+MAKE_GET( SampleRate,                  sampleRate,          uint16_t )
+MAKE_GET( DestinationAddressHigh,      destHigh,            uint32_t )
+MAKE_GET( DestinationAddressLow,       destLow,             uint32_t )
 
 bool XBeeApiCmdAt::getSerialNumber( uint64_t* const p_sn )
 {
@@ -379,6 +543,19 @@
     return( have_sn );
 }
 
+bool XBeeApiCmdAt::getDestinationAddress( uint64_t* const p_addr )
+{
+    bool have_da = m_have_destLow && m_have_destHigh;
+    if( have_da )
+    {
+        *p_addr = m_destHigh;
+        *p_addr = *p_addr << 32U;
+        *p_addr |= m_destLow;
+    }
+    return( have_da );
+   
+}
+
 bool XBeeApiCmdAt::getDioConfig( const uint8_t p_chanNo, XBeeApiDioConfig_e* const p_conf )
 {
     bool ret_val = false;
@@ -402,13 +579,18 @@
     return true;\
 }
 
-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 )
+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 )
+MAKE_SET( DioChangeDetectMask,         dioChangeDetectMask, cmd_ic_set,  uint8_t,          uint8_t )
+MAKE_SET( DioLevels,                   dioLevels,           cmd_io_set,  uint8_t,          uint8_t )
+MAKE_SET( SampleRate,                  sampleRate,          cmd_ir_set,  uint16_t,         uint16_t )
+MAKE_SET( DestinationAddressHigh,      destHigh,            cmd_dh_set,  uint32_t,         uint32_t )
+MAKE_SET( DestinationAddressLow,       destLow,             cmd_dl_set,  uint32_t,         uint32_t )
 
 
 bool XBeeApiCmdAt::setDioConfig( const uint8_t p_chanNo, const XBeeApiDioConfig_e p_conf )
@@ -416,6 +598,7 @@
     bool ret_val = false;
     if( p_chanNo < XBEE_API_DIO_CHANNEL_COUNT )
     {
+        /* TODO: Add check that p_conf is valid for this channel */
         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 );
@@ -423,6 +606,18 @@
     return ret_val;   
 }
 
+bool XBeeApiCmdAt::setDestinationAddress( const uint64_t p_addr )
+{
+    m_have_destHigh = m_have_destLow = false;
+    
+    setDestinationAddressHigh( p_addr >> 32U );
+    setDestinationAddressLow( p_addr );
+
+    return true;
+}
+
+
+
 void XBeeApiCmdAt::SendCmd_uint8_t( const uint8_t        p_frameId,
                                     const uint8_t* const p_data,
                                     const uint8_t&       p_val )
@@ -439,238 +634,12 @@
      m_device->SendFrame( &req );
 }
 
-XBeeApiCmdAtBlocking::XBeeApiCmdAtBlocking( XBeeDevice* const p_device, const uint16_t p_timeout, const uint16_t p_slice ) :
-    XBeeApiCmdAt( p_device ),
-    m_timeout( p_timeout ),
-    m_slice( p_slice )
-{
-}
-
-/**
-   Macro to wrap around the "requestXXX" & "getXXX" methods and implement a blocking call.
-   This macro is used as the basis for getXXX functions in XBeeApiCmdAtBlocking.
-
-   Originally looked to achieve this using a template function passing method pointers, however
-   there's no way to get a method pointer to the parent class implementation as opposed to the
-   implementation in this class, meaning that the result was a recursive method call.  The joys of
-   polymorphism.
-
-   e.g. We pass a pointer to method getHardwareVersion().  The function receiving the pointer
-        uses it to make a function call.  The actual function that's called is (correctly)
-        the one implemented in this class, however what we actually wanted in this case
-        was to call the implementation in the base class.  Using static_cast<> doesn't have
-        any effect and taking the address of XBeeApiCmdAt::getHardwareVersion ends up with
-        XBeeApiCmdAtBlocking::getHardwareVersion being called due to polymorphism. */
-#define BLOCKING_GET( _REQ_FN, _GET_FN, _VAR ) \
-    bool ret_val = false; \
-\
-    if( _GET_FN( _VAR ) )\
-    {\
-        ret_val = true;\
-    } \
-    else if( _REQ_FN() )\
-    {\
-        uint16_t counter = m_timeout; \
-        bool cont;\
-\
-        do{\
-            cont = false; \
-            wait_ms( m_slice );\
-            if( _GET_FN( _VAR ) )\
-            {\
-                ret_val = true;\
-            }\
-            else if( counter > m_slice ) {\
-                counter -= m_slice;    \
-                cont = true;\
-            } \
-        } while( cont );\
-    }\
-    \
-    return( ret_val );
-
-/**
-   Macro to wrap around the "setXXX" & "getXXX" methods and implement a blocking call.
-   This macro is used as the basis for setXXX functions in XBeeApiCmdAtBlocking.
-*/
-#define BLOCKING_SET( _SET_FN, _GET_FN, _VAR, _TYPE ) \
-    bool ret_val = false; \
-    uint16_t counter = m_timeout; \
-    _TYPE readback; \
-\
-    if( _SET_FN( _VAR ) )\
-    {\
-        bool cont;\
-\
-        do{\
-            cont = false;\
-            wait_ms( m_slice );\
-            if( _GET_FN( &readback ) &&\
-               ( readback == _VAR ))\
-            {\
-                ret_val = true;\
-            }\
-            else if( counter > m_slice ) {\
-                counter -= m_slice;    \
-                cont = true;\
-            } \
-        } while( cont );\
-    }\
-    \
-    return( ret_val );
-
-
-bool XBeeApiCmdAtBlocking::getHardwareVersion( uint16_t* const p_ver )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestHardwareVersion,
-                  XBeeApiCmdAt::getHardwareVersion,
-                  p_ver );
-}
-
-bool XBeeApiCmdAtBlocking::getFirmwareVersion( uint16_t* const p_ver )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestFirmwareVersion,
-                  XBeeApiCmdAt::getFirmwareVersion,
-                  p_ver );
-}
-
-bool XBeeApiCmdAtBlocking::getSerialNumber( uint64_t* const p_sn )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestSerialNumber,
-                  XBeeApiCmdAt::getSerialNumber,
-                  p_sn );
-}
-
-bool XBeeApiCmdAtBlocking::getChannel( uint8_t* const p_chan )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestChannel,
-                  XBeeApiCmdAt::getChannel,
-                  p_chan );
-}
-
-bool XBeeApiCmdAtBlocking::setChannel( uint8_t const p_chan )
+void XBeeApiCmdAt::SendCmd_uint32_t( const uint8_t        p_frameId,
+                                     const uint8_t* const p_data,
+                                     const uint32_t&       p_val )
 {
-    BLOCKING_SET( XBeeApiCmdAt::setChannel,
-                  XBeeApiCmdAt::getChannel,
-                  p_chan,
-                  uint8_t );
-}
-
-bool XBeeApiCmdAtBlocking::getCoordinatorEnabled( bool* const p_en )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestCoordinatorEnabled,
-                  XBeeApiCmdAt::getCoordinatorEnabled,
-                  p_en );
-}
-
-bool XBeeApiCmdAtBlocking::setCoordinatorEnabled( const bool p_en )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setCoordinatorEnabled,
-                  XBeeApiCmdAt::getCoordinatorEnabled,
-                  p_en,
-                  bool );
-}
-
-bool XBeeApiCmdAtBlocking::getEndDeviceAssociationEnabled( bool* const p_en )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestEndDeviceAssociationEnabled,
-                  XBeeApiCmdAt::getEndDeviceAssociationEnabled,
-                  p_en );
-}
-
-bool XBeeApiCmdAtBlocking::setEndDeviceAssociationEnabled( const bool p_en )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setEndDeviceAssociationEnabled,
-                  XBeeApiCmdAt::getEndDeviceAssociationEnabled,
-                  p_en,
-                  bool );
-}
-
-bool XBeeApiCmdAtBlocking::getPanId( panId_t* const p_chan )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestPanId,
-                  XBeeApiCmdAt::getPanId,
-                  p_chan );
-}
-
-bool XBeeApiCmdAtBlocking::setPanId( const panId_t p_chan )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setPanId,
-                  XBeeApiCmdAt::getPanId,
-                  p_chan,
-                  panId_t );
-}
-
-bool XBeeApiCmdAtBlocking::getSourceAddress( uint16_t* const p_addr )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestSourceAddress,
-                  XBeeApiCmdAt::getSourceAddress,
-                  p_addr );
-}
-
-bool XBeeApiCmdAtBlocking::setSourceAddress( const uint16_t p_addr )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setSourceAddress,
-                  XBeeApiCmdAt::getSourceAddress,
-                  p_addr,
-                  uint16_t );
-}
-
-bool XBeeApiCmdAtBlocking::getRetries( uint8_t* const p_addr )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestRetries,
-                  XBeeApiCmdAt::getRetries,
-                  p_addr );
-}
-
-bool XBeeApiCmdAtBlocking::setRetries( const uint8_t p_addr )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setRetries,
-                  XBeeApiCmdAt::getRetries,
-                  p_addr,
-                  uint8_t );
-}
-
-bool XBeeApiCmdAtBlocking::getRandomDelaySlots( uint8_t* const p_addr )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestRandomDelaySlots,
-                  XBeeApiCmdAt::getRandomDelaySlots,
-                  p_addr );
-}
-
-bool XBeeApiCmdAtBlocking::setRandomDelaySlots( const uint8_t p_addr )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setRandomDelaySlots,
-                  XBeeApiCmdAt::getRandomDelaySlots,
-                  p_addr,
-                  uint8_t );
-}
-
-bool XBeeApiCmdAtBlocking::getMacMode( XBeeApiMACMode_e* const p_mode )
-{
-    BLOCKING_GET( XBeeApiCmdAt::requestMacMode,
-                  XBeeApiCmdAt::getMacMode,
-                  p_mode );
-}
-           
-bool XBeeApiCmdAtBlocking::setMacMode( const XBeeApiMACMode_e p_mode )
-{
-    BLOCKING_SET( XBeeApiCmdAt::setMacMode,
-                  XBeeApiCmdAt::getMacMode,
-                  p_mode,
-                  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;
+     XBeeApiCmdAtSet<uint32_t> req( p_frameId, p_data, p_val );
+     m_device->SendFrame( &req );
 }
 
 template < typename T >