Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: CircularBuffer FixedLengthList
Dependents: XBeeApiTest XBeeApiSimpleATCmdsExample XBeeApiBroadcastExample XBeeApiBroadcastExampleRTOS ... more
Utility/XBeeApiCmdAt.hpp@25:db6874b7ac4b, 2014-02-05 (annotated)
- Committer:
- johnb
- Date:
- Wed Feb 05 21:05:10 2014 +0000
- Revision:
- 25:db6874b7ac4b
- Parent:
- 24:2cd1094c4fd7
- Child:
- 26:f5df80e990f4
Add XBeeApiCmdAtSet to replace various classes in XBeeApiCmdAt
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
johnb | 8:1b48b619d7f6 | 1 | /** |
johnb | 8:1b48b619d7f6 | 2 | @file |
johnb | 8:1b48b619d7f6 | 3 | @brief Class to abstract AT commands send to the XBee API |
johnb | 8:1b48b619d7f6 | 4 | |
johnb | 8:1b48b619d7f6 | 5 | AT commands have the payload: |
johnb | 8:1b48b619d7f6 | 6 | |
johnb | 8:1b48b619d7f6 | 7 | Byte 1 : Frame ID |
johnb | 8:1b48b619d7f6 | 8 | Byte 2 & 3 : AT command |
johnb | 8:1b48b619d7f6 | 9 | Byte 4-n : Parameter Value |
johnb | 8:1b48b619d7f6 | 10 | |
johnb | 8:1b48b619d7f6 | 11 | @author John Bailey |
johnb | 8:1b48b619d7f6 | 12 | |
johnb | 8:1b48b619d7f6 | 13 | @copyright Copyright 2014 John Bailey |
johnb | 8:1b48b619d7f6 | 14 | |
johnb | 8:1b48b619d7f6 | 15 | @section LICENSE |
johnb | 8:1b48b619d7f6 | 16 | |
johnb | 8:1b48b619d7f6 | 17 | Licensed under the Apache License, Version 2.0 (the "License"); |
johnb | 8:1b48b619d7f6 | 18 | you may not use this file except in compliance with the License. |
johnb | 8:1b48b619d7f6 | 19 | You may obtain a copy of the License at |
johnb | 8:1b48b619d7f6 | 20 | |
johnb | 8:1b48b619d7f6 | 21 | http://www.apache.org/licenses/LICENSE-2.0 |
johnb | 8:1b48b619d7f6 | 22 | |
johnb | 8:1b48b619d7f6 | 23 | Unless required by applicable law or agreed to in writing, software |
johnb | 8:1b48b619d7f6 | 24 | distributed under the License is distributed on an "AS IS" BASIS, |
johnb | 8:1b48b619d7f6 | 25 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
johnb | 8:1b48b619d7f6 | 26 | See the License for the specific language governing permissions and |
johnb | 8:1b48b619d7f6 | 27 | limitations under the License. |
johnb | 8:1b48b619d7f6 | 28 | |
johnb | 8:1b48b619d7f6 | 29 | */ |
johnb | 8:1b48b619d7f6 | 30 | |
johnb | 8:1b48b619d7f6 | 31 | #if !defined XBEEAPICMDAT_HPP |
johnb | 8:1b48b619d7f6 | 32 | #define XBEEAPICMDAT_HPP |
johnb | 8:1b48b619d7f6 | 33 | |
johnb | 8:1b48b619d7f6 | 34 | #include "XBeeApiFrame.hpp" |
johnb | 8:1b48b619d7f6 | 35 | #include "XBeeDevice.hpp" |
johnb | 8:1b48b619d7f6 | 36 | |
johnb | 8:1b48b619d7f6 | 37 | #include <stdint.h> |
johnb | 8:1b48b619d7f6 | 38 | |
johnb | 8:1b48b619d7f6 | 39 | class XBeeApiCmdAt : public XBeeApiFrameDecoder |
johnb | 8:1b48b619d7f6 | 40 | { |
johnb | 13:302e7c1ea0b3 | 41 | public: |
johnb | 13:302e7c1ea0b3 | 42 | typedef uint16_t panId_t; |
johnb | 13:302e7c1ea0b3 | 43 | typedef uint8_t channel_t; |
johnb | 13:302e7c1ea0b3 | 44 | |
johnb | 8:1b48b619d7f6 | 45 | protected: |
johnb | 8:1b48b619d7f6 | 46 | bool m_haveHwVer; |
johnb | 8:1b48b619d7f6 | 47 | bool m_haveFwVer; |
johnb | 8:1b48b619d7f6 | 48 | bool m_haveChan; |
johnb | 13:302e7c1ea0b3 | 49 | bool m_havePANId; |
johnb | 13:302e7c1ea0b3 | 50 | bool m_haveEDA; |
johnb | 13:302e7c1ea0b3 | 51 | bool m_haveCE; |
johnb | 13:302e7c1ea0b3 | 52 | |
johnb | 8:1b48b619d7f6 | 53 | uint16_t m_hwVer; |
johnb | 8:1b48b619d7f6 | 54 | uint16_t m_fwVer; |
johnb | 13:302e7c1ea0b3 | 55 | channel_t m_chan; |
johnb | 13:302e7c1ea0b3 | 56 | channel_t m_chanPend; |
johnb | 13:302e7c1ea0b3 | 57 | panId_t m_PANId; |
johnb | 13:302e7c1ea0b3 | 58 | panId_t m_PANIdPend; |
johnb | 13:302e7c1ea0b3 | 59 | bool m_EDA; |
johnb | 13:302e7c1ea0b3 | 60 | bool m_EDAPend; |
johnb | 13:302e7c1ea0b3 | 61 | bool m_CE; |
johnb | 13:302e7c1ea0b3 | 62 | bool m_CEPend; |
johnb | 8:1b48b619d7f6 | 63 | |
johnb | 25:db6874b7ac4b | 64 | template< typename T > |
johnb | 25:db6874b7ac4b | 65 | class XBeeApiCmdAtSet : public XBeeApiFrame { |
johnb | 25:db6874b7ac4b | 66 | uint8_t m_buffer[ 3 + sizeof( T ) ]; |
johnb | 13:302e7c1ea0b3 | 67 | public: |
johnb | 25:db6874b7ac4b | 68 | XBeeApiCmdAtSet( const uint8_t* const p_data, |
johnb | 25:db6874b7ac4b | 69 | const T p_val ); |
johnb | 25:db6874b7ac4b | 70 | virtual ~XBeeApiCmdAtSet(); |
johnb | 13:302e7c1ea0b3 | 71 | }; |
johnb | 13:302e7c1ea0b3 | 72 | |
johnb | 8:1b48b619d7f6 | 73 | public: |
johnb | 13:302e7c1ea0b3 | 74 | |
johnb | 8:1b48b619d7f6 | 75 | XBeeApiCmdAt( ); |
johnb | 8:1b48b619d7f6 | 76 | virtual ~XBeeApiCmdAt( void ) {}; |
johnb | 8:1b48b619d7f6 | 77 | |
johnb | 8:1b48b619d7f6 | 78 | bool requestHardwareVersion( void ); |
johnb | 8:1b48b619d7f6 | 79 | bool requestFirmwareVersion( void ); |
johnb | 8:1b48b619d7f6 | 80 | bool requestChannel( void ); |
johnb | 13:302e7c1ea0b3 | 81 | bool requestCoordinatorEnabled( void ); |
johnb | 13:302e7c1ea0b3 | 82 | bool requestEndDeviceAssociationEnabled( void ); |
johnb | 13:302e7c1ea0b3 | 83 | bool requestPanId( void ); |
johnb | 8:1b48b619d7f6 | 84 | |
johnb | 8:1b48b619d7f6 | 85 | virtual bool getHardwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 86 | virtual bool getFirmwareVersion( uint16_t* const p_ver ); |
johnb | 13:302e7c1ea0b3 | 87 | |
johnb | 8:1b48b619d7f6 | 88 | virtual bool getChannel( uint8_t* const p_chan ); |
johnb | 13:302e7c1ea0b3 | 89 | virtual bool setChannel( uint8_t const p_chan ); |
johnb | 8:1b48b619d7f6 | 90 | |
johnb | 13:302e7c1ea0b3 | 91 | virtual bool getCoordinatorEnabled( bool* constp_en ); |
johnb | 13:302e7c1ea0b3 | 92 | virtual bool setCoordinatorEnabled( const bool p_en ); |
johnb | 13:302e7c1ea0b3 | 93 | |
johnb | 13:302e7c1ea0b3 | 94 | virtual bool getEndDeviceAssociationEnabled( bool* const p_en ); |
johnb | 13:302e7c1ea0b3 | 95 | virtual bool setEndDeviceAssociationEnabled( const bool p_en ); |
johnb | 13:302e7c1ea0b3 | 96 | |
johnb | 13:302e7c1ea0b3 | 97 | virtual bool getPanId( panId_t* const p_id ); |
johnb | 13:302e7c1ea0b3 | 98 | virtual bool setPanId( const panId_t p_id ); |
johnb | 8:1b48b619d7f6 | 99 | |
johnb | 8:1b48b619d7f6 | 100 | /* Implement XBeeApiCmdDecoder interface */ |
johnb | 8:1b48b619d7f6 | 101 | virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len ); |
johnb | 8:1b48b619d7f6 | 102 | |
johnb | 8:1b48b619d7f6 | 103 | }; |
johnb | 8:1b48b619d7f6 | 104 | |
johnb | 8:1b48b619d7f6 | 105 | class XBeeApiCmdAtBlocking : public XBeeApiCmdAt |
johnb | 8:1b48b619d7f6 | 106 | { |
johnb | 8:1b48b619d7f6 | 107 | protected: |
johnb | 8:1b48b619d7f6 | 108 | uint16_t m_timeout; |
johnb | 8:1b48b619d7f6 | 109 | uint16_t m_slice; |
johnb | 8:1b48b619d7f6 | 110 | |
johnb | 8:1b48b619d7f6 | 111 | public: |
johnb | 8:1b48b619d7f6 | 112 | XBeeApiCmdAtBlocking( const uint16_t p_timeout = 1000, const uint16_t p_slice = 100); |
johnb | 8:1b48b619d7f6 | 113 | |
johnb | 8:1b48b619d7f6 | 114 | virtual ~XBeeApiCmdAtBlocking( void ) {}; |
johnb | 8:1b48b619d7f6 | 115 | /* Implement XBeeApiCmdAt's virtual methods */ |
johnb | 8:1b48b619d7f6 | 116 | virtual bool getHardwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 117 | virtual bool getFirmwareVersion( uint16_t* const p_ver ); |
johnb | 13:302e7c1ea0b3 | 118 | |
johnb | 8:1b48b619d7f6 | 119 | virtual bool getChannel( uint8_t* const p_chan ); |
johnb | 13:302e7c1ea0b3 | 120 | virtual bool setChannel( uint8_t const p_chan ); |
johnb | 13:302e7c1ea0b3 | 121 | |
johnb | 13:302e7c1ea0b3 | 122 | virtual bool getCoordinatorEnabled( bool* constp_en ); |
johnb | 13:302e7c1ea0b3 | 123 | virtual bool setCoordinatorEnabled( const bool p_en ); |
johnb | 8:1b48b619d7f6 | 124 | |
johnb | 13:302e7c1ea0b3 | 125 | virtual bool getEndDeviceAssociationEnabled( bool* const p_en ); |
johnb | 13:302e7c1ea0b3 | 126 | virtual bool setEndDeviceAssociationEnabled( const bool p_en ); |
johnb | 13:302e7c1ea0b3 | 127 | |
johnb | 13:302e7c1ea0b3 | 128 | virtual bool getPanId( panId_t* const p_id ); |
johnb | 13:302e7c1ea0b3 | 129 | virtual bool setPanId( const panId_t p_id ); |
johnb | 13:302e7c1ea0b3 | 130 | |
johnb | 8:1b48b619d7f6 | 131 | }; |
johnb | 8:1b48b619d7f6 | 132 | |
johnb | 8:1b48b619d7f6 | 133 | #endif |