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: libmDot-Custom MTS-Serial
Fork of mDot_AT_firmware_CUSTOM by
To change channel plans replace AS923 with AU915, EU868, KR920 or US915 on line 15
#define CHANNEL_PLAN CP_AS923
CommandTerminal/Command.h@18:4e02a7a01625, 2016-09-28 (annotated)
- Committer:
- jreiss
- Date:
- Wed Sep 28 16:23:09 2016 +0000
- Revision:
- 18:4e02a7a01625
- Parent:
- 15:36db31c18231
update libmDot and channel plans
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Jason Reiss |
15:36db31c18231 | 1 | /** |
Jason Reiss |
15:36db31c18231 | 2 | ****************************************************************************** |
Jason Reiss |
15:36db31c18231 | 3 | * File Name : Command.h |
Jason Reiss |
15:36db31c18231 | 4 | * Date : 18/04/2014 10:57:12 |
Jason Reiss |
15:36db31c18231 | 5 | * Description : This file provides code for command line prompt |
Jason Reiss |
15:36db31c18231 | 6 | ****************************************************************************** |
Jason Reiss |
15:36db31c18231 | 7 | * |
Jason Reiss |
15:36db31c18231 | 8 | * COPYRIGHT(c) 2014 MultiTech Systems, Inc. |
Jason Reiss |
15:36db31c18231 | 9 | * |
Jason Reiss |
15:36db31c18231 | 10 | * Redistribution and use in source and binary forms, with or without modification, |
Jason Reiss |
15:36db31c18231 | 11 | * are permitted provided that the following conditions are met: |
Jason Reiss |
15:36db31c18231 | 12 | * 1. Redistributions of source code must retain the above copyright notice, |
Jason Reiss |
15:36db31c18231 | 13 | * this list of conditions and the following disclaimer. |
Jason Reiss |
15:36db31c18231 | 14 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
Jason Reiss |
15:36db31c18231 | 15 | * this list of conditions and the following disclaimer in the documentation |
Jason Reiss |
15:36db31c18231 | 16 | * and/or other materials provided with the distribution. |
Jason Reiss |
15:36db31c18231 | 17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
Jason Reiss |
15:36db31c18231 | 18 | * may be used to endorse or promote products derived from this software |
Jason Reiss |
15:36db31c18231 | 19 | * without specific prior written permission. |
Jason Reiss |
15:36db31c18231 | 20 | * |
Jason Reiss |
15:36db31c18231 | 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
Jason Reiss |
15:36db31c18231 | 22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
Jason Reiss |
15:36db31c18231 | 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
Jason Reiss |
15:36db31c18231 | 24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
Jason Reiss |
15:36db31c18231 | 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
Jason Reiss |
15:36db31c18231 | 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
Jason Reiss |
15:36db31c18231 | 27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
Jason Reiss |
15:36db31c18231 | 28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
Jason Reiss |
15:36db31c18231 | 29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
Jason Reiss |
15:36db31c18231 | 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Jason Reiss |
15:36db31c18231 | 31 | * |
Jason Reiss |
15:36db31c18231 | 32 | ****************************************************************************** |
Jason Reiss |
15:36db31c18231 | 33 | */ |
Jason Reiss |
15:36db31c18231 | 34 | |
Jason Reiss |
15:36db31c18231 | 35 | #include "mbed.h" |
Jason Reiss |
15:36db31c18231 | 36 | #include "mDot.h" |
Jason Reiss |
15:36db31c18231 | 37 | #include "MTSSerial.h" |
Jason Reiss |
15:36db31c18231 | 38 | #include "MTSText.h" |
Jason Reiss |
15:36db31c18231 | 39 | #include <cstdlib> |
Jason Reiss |
15:36db31c18231 | 40 | #include <string> |
Jason Reiss |
15:36db31c18231 | 41 | #include <vector> |
Jason Reiss |
15:36db31c18231 | 42 | #include "limits.h" |
Jason Reiss |
15:36db31c18231 | 43 | #include "CommandTerminal.h" |
Jason Reiss |
15:36db31c18231 | 44 | |
Jason Reiss |
15:36db31c18231 | 45 | |
Jason Reiss |
15:36db31c18231 | 46 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Jason Reiss |
15:36db31c18231 | 47 | #ifndef __command_H |
Jason Reiss |
15:36db31c18231 | 48 | #define __command_H |
Jason Reiss |
15:36db31c18231 | 49 | |
Jason Reiss |
15:36db31c18231 | 50 | #define KEY_LENGTH 16 |
Jason Reiss |
15:36db31c18231 | 51 | #define EUI_LENGTH 8 |
Jason Reiss |
15:36db31c18231 | 52 | #define PASSPHRASE_LENGTH 128 |
Jason Reiss |
15:36db31c18231 | 53 | |
Jason Reiss |
15:36db31c18231 | 54 | class Command { |
Jason Reiss |
15:36db31c18231 | 55 | |
Jason Reiss |
15:36db31c18231 | 56 | public: |
Jason Reiss |
15:36db31c18231 | 57 | |
Jason Reiss |
15:36db31c18231 | 58 | Command(); |
Jason Reiss |
15:36db31c18231 | 59 | Command(const char* name, const char* text, const char* desc, const char* usage); |
Jason Reiss |
15:36db31c18231 | 60 | virtual ~Command() {}; |
Jason Reiss |
15:36db31c18231 | 61 | |
Jason Reiss |
15:36db31c18231 | 62 | const char* name() const { return _name; }; |
Jason Reiss |
15:36db31c18231 | 63 | const char* text() const { return _text; }; |
Jason Reiss |
15:36db31c18231 | 64 | const char* desc() const { return _desc; }; |
Jason Reiss |
15:36db31c18231 | 65 | const std::string help() const { |
Jason Reiss |
15:36db31c18231 | 66 | return std::string(text()) + ": " + std::string(desc()); |
Jason Reiss |
15:36db31c18231 | 67 | }; |
Jason Reiss |
15:36db31c18231 | 68 | |
Jason Reiss |
15:36db31c18231 | 69 | std::string usage() const; |
Jason Reiss |
15:36db31c18231 | 70 | const std::string& errorMessage() const; |
Jason Reiss |
15:36db31c18231 | 71 | bool queryable() const; |
Jason Reiss |
15:36db31c18231 | 72 | |
Jason Reiss |
15:36db31c18231 | 73 | static const char newline[]; |
Jason Reiss |
15:36db31c18231 | 74 | static void readByteArray(const std::string& input, std::vector<uint8_t>& out, size_t len); |
Jason Reiss |
15:36db31c18231 | 75 | |
Jason Reiss |
15:36db31c18231 | 76 | static bool isHexString(const std::string& str, size_t bytes); |
Jason Reiss |
15:36db31c18231 | 77 | static bool isBaudRate(uint32_t baud); |
Jason Reiss |
15:36db31c18231 | 78 | |
Jason Reiss |
15:36db31c18231 | 79 | protected: |
Jason Reiss |
15:36db31c18231 | 80 | |
Jason Reiss |
15:36db31c18231 | 81 | bool _queryable; |
Jason Reiss |
15:36db31c18231 | 82 | |
Jason Reiss |
15:36db31c18231 | 83 | private: |
Jason Reiss |
15:36db31c18231 | 84 | |
Jason Reiss |
15:36db31c18231 | 85 | const char* _name; |
Jason Reiss |
15:36db31c18231 | 86 | const char* _text; |
Jason Reiss |
15:36db31c18231 | 87 | const char* _desc; |
Jason Reiss |
15:36db31c18231 | 88 | const char* _usage; |
Jason Reiss |
15:36db31c18231 | 89 | |
Jason Reiss |
15:36db31c18231 | 90 | }; |
Jason Reiss |
15:36db31c18231 | 91 | |
Jason Reiss |
15:36db31c18231 | 92 | #endif /*__ command_H */ |
Jason Reiss |
15:36db31c18231 | 93 | |
Jason Reiss |
15:36db31c18231 | 94 | /************************ (C) COPYRIGHT MultiTech Systems, Inc *****END OF FILE****/ |