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@11:bfcf1356027b, 2014-01-31 (annotated)
- Committer:
- johnb
- Date:
- Fri Jan 31 23:53:16 2014 +0000
- Revision:
- 11:bfcf1356027b
- Parent:
- 8:1b48b619d7f6
- Child:
- 13:302e7c1ea0b3
Switch to using macros to implement the access functions in XBeeApiCmdAtBlocking.; Implement XBeeApiCmdAtBlocking::setChannel()
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 | 8:1b48b619d7f6 | 41 | protected: |
johnb | 8:1b48b619d7f6 | 42 | bool m_haveHwVer; |
johnb | 8:1b48b619d7f6 | 43 | bool m_haveFwVer; |
johnb | 8:1b48b619d7f6 | 44 | bool m_haveChan; |
johnb | 8:1b48b619d7f6 | 45 | uint16_t m_hwVer; |
johnb | 8:1b48b619d7f6 | 46 | uint16_t m_fwVer; |
johnb | 8:1b48b619d7f6 | 47 | uint8_t m_chan; |
johnb | 8:1b48b619d7f6 | 48 | uint8_t m_chanPend; |
johnb | 8:1b48b619d7f6 | 49 | |
johnb | 8:1b48b619d7f6 | 50 | class XBeeApiCmdAtFirmwareVersionRequest : public XBeeApiFrame |
johnb | 8:1b48b619d7f6 | 51 | { |
johnb | 8:1b48b619d7f6 | 52 | public: |
johnb | 8:1b48b619d7f6 | 53 | XBeeApiCmdAtFirmwareVersionRequest( void ); |
johnb | 8:1b48b619d7f6 | 54 | }; |
johnb | 8:1b48b619d7f6 | 55 | |
johnb | 8:1b48b619d7f6 | 56 | class XBeeApiCmdAtHardwareVersionRequest : public XBeeApiFrame |
johnb | 8:1b48b619d7f6 | 57 | { |
johnb | 8:1b48b619d7f6 | 58 | public: |
johnb | 8:1b48b619d7f6 | 59 | XBeeApiCmdAtHardwareVersionRequest( void ); |
johnb | 8:1b48b619d7f6 | 60 | }; |
johnb | 8:1b48b619d7f6 | 61 | |
johnb | 8:1b48b619d7f6 | 62 | class XBeeApiCmdAtChannelRequest : public XBeeApiFrame |
johnb | 8:1b48b619d7f6 | 63 | { |
johnb | 8:1b48b619d7f6 | 64 | public: |
johnb | 8:1b48b619d7f6 | 65 | XBeeApiCmdAtChannelRequest( void ); |
johnb | 8:1b48b619d7f6 | 66 | }; |
johnb | 8:1b48b619d7f6 | 67 | |
johnb | 8:1b48b619d7f6 | 68 | class XBeeApiCmdAtChannelSet : public XBeeApiFrame |
johnb | 8:1b48b619d7f6 | 69 | { |
johnb | 8:1b48b619d7f6 | 70 | uint8_t m_buffer[ 10 ]; |
johnb | 8:1b48b619d7f6 | 71 | public: |
johnb | 8:1b48b619d7f6 | 72 | XBeeApiCmdAtChannelSet( const uint8_t p_chan ); |
johnb | 8:1b48b619d7f6 | 73 | }; |
johnb | 8:1b48b619d7f6 | 74 | |
johnb | 8:1b48b619d7f6 | 75 | public: |
johnb | 8:1b48b619d7f6 | 76 | XBeeApiCmdAt( ); |
johnb | 8:1b48b619d7f6 | 77 | virtual ~XBeeApiCmdAt( void ) {}; |
johnb | 8:1b48b619d7f6 | 78 | |
johnb | 8:1b48b619d7f6 | 79 | bool requestHardwareVersion( void ); |
johnb | 8:1b48b619d7f6 | 80 | bool requestFirmwareVersion( void ); |
johnb | 8:1b48b619d7f6 | 81 | bool requestChannel( void ); |
johnb | 8:1b48b619d7f6 | 82 | |
johnb | 8:1b48b619d7f6 | 83 | virtual bool getHardwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 84 | virtual bool getFirmwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 85 | virtual bool getChannel( uint8_t* const p_chan ); |
johnb | 8:1b48b619d7f6 | 86 | |
johnb | 8:1b48b619d7f6 | 87 | virtual bool setChannel( uint8_t const p_chan ); |
johnb | 8:1b48b619d7f6 | 88 | |
johnb | 8:1b48b619d7f6 | 89 | /* Implement XBeeApiCmdDecoder interface */ |
johnb | 8:1b48b619d7f6 | 90 | virtual bool decodeCallback( const uint8_t* const p_data, size_t p_len ); |
johnb | 8:1b48b619d7f6 | 91 | |
johnb | 8:1b48b619d7f6 | 92 | typedef uint16_t panId_t; |
johnb | 8:1b48b619d7f6 | 93 | typedef uint8_t channel_t; |
johnb | 8:1b48b619d7f6 | 94 | }; |
johnb | 8:1b48b619d7f6 | 95 | |
johnb | 8:1b48b619d7f6 | 96 | class XBeeApiCmdAtBlocking : public XBeeApiCmdAt |
johnb | 8:1b48b619d7f6 | 97 | { |
johnb | 8:1b48b619d7f6 | 98 | protected: |
johnb | 8:1b48b619d7f6 | 99 | uint16_t m_timeout; |
johnb | 8:1b48b619d7f6 | 100 | uint16_t m_slice; |
johnb | 8:1b48b619d7f6 | 101 | |
johnb | 8:1b48b619d7f6 | 102 | public: |
johnb | 8:1b48b619d7f6 | 103 | XBeeApiCmdAtBlocking( const uint16_t p_timeout = 1000, const uint16_t p_slice = 100); |
johnb | 8:1b48b619d7f6 | 104 | |
johnb | 8:1b48b619d7f6 | 105 | virtual ~XBeeApiCmdAtBlocking( void ) {}; |
johnb | 8:1b48b619d7f6 | 106 | /* Implement XBeeApiCmdAt's virtual methods */ |
johnb | 8:1b48b619d7f6 | 107 | virtual bool getHardwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 108 | virtual bool getFirmwareVersion( uint16_t* const p_ver ); |
johnb | 8:1b48b619d7f6 | 109 | virtual bool getChannel( uint8_t* const p_chan ); |
johnb | 8:1b48b619d7f6 | 110 | |
johnb | 8:1b48b619d7f6 | 111 | virtual bool setChannel( uint8_t const p_chan ); |
johnb | 8:1b48b619d7f6 | 112 | }; |
johnb | 8:1b48b619d7f6 | 113 | |
johnb | 8:1b48b619d7f6 | 114 | #endif |