Factory firmware for the MultiTech Dotbox (MTDOT-BOX) and EVB (MTDOT-EVB) products.
Dependencies: NCP5623B GpsParser ISL29011 libmDot-mbed5 MTS-Serial MMA845x DOGS102 MPL3115A2
Command.h
00001 /* Copyright (c) <2016> <MultiTech Systems>, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 /** 00020 ****************************************************************************** 00021 * File Name : Command.h 00022 * Date : 18/04/2014 10:57:12 00023 * Description : This file provides code for command line prompt 00024 ****************************************************************************** 00025 * 00026 * COPYRIGHT(c) 2014 MultiTech Systems, Inc. 00027 * 00028 * Redistribution and use in source and binary forms, with or without modification, 00029 * are permitted provided that the following conditions are met: 00030 * 1. Redistributions of source code must retain the above copyright notice, 00031 * this list of conditions and the following disclaimer. 00032 * 2. Redistributions in binary form must reproduce the above copyright notice, 00033 * this list of conditions and the following disclaimer in the documentation 00034 * and/or other materials provided with the distribution. 00035 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00036 * may be used to endorse or promote products derived from this software 00037 * without specific prior written permission. 00038 * 00039 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00040 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00041 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00042 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00043 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00044 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00045 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00046 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00047 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00048 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00049 * 00050 ****************************************************************************** 00051 */ 00052 00053 #include "mbed.h" 00054 #include "mDot.h" 00055 #include "MTSSerial.h" 00056 #include "MTSText.h" 00057 #include <cstdlib> 00058 #include <string> 00059 #include <vector> 00060 #include "limits.h" 00061 #include "ChannelPlans.h" 00062 00063 /* Define to prevent recursive inclusion -------------------------------------*/ 00064 #ifndef __command_H 00065 #define __command_H 00066 00067 #define KEY_LENGTH 16 00068 #define EUI_LENGTH 8 00069 #define PASSPHRASE_LENGTH 128 00070 00071 class Command { 00072 00073 public: 00074 00075 Command(mDot* dot); 00076 Command(mDot* dot, const char* name, const char* text, const char* desc); 00077 virtual ~Command() {}; 00078 00079 const char* name() const { return _name; }; 00080 const char* text() const { return _text; }; 00081 const char* desc() const { return _desc; }; 00082 const char* help() const { return _help.c_str(); }; 00083 00084 virtual uint32_t action(std::vector<std::string> args) = 0; 00085 virtual bool verify(std::vector<std::string> args); 00086 const std::string usage() const; 00087 std::string& errorMessage(); 00088 const bool queryable(); 00089 00090 static const char newline[]; 00091 static void readByteArray(const std::string& input, std::vector<uint8_t>& out, size_t len); 00092 00093 static bool isHexString(const std::string& str, size_t bytes); 00094 static bool isBaudRate(uint32_t baud); 00095 00096 protected: 00097 00098 void setErrorMessage(const char* message); 00099 void setErrorMessage(const std::string& message); 00100 std::string _help; 00101 std::string _usage; 00102 bool _queryable; 00103 mDot* _dot; 00104 00105 private: 00106 00107 const char* _name; 00108 const char* _text; 00109 const char* _desc; 00110 std::string _errorMessage; 00111 00112 }; 00113 00114 #endif /*__ command_H */ 00115 00116 /************************ (C) COPYRIGHT MultiTech Systems, Inc *****END OF FILE****/
Generated on Tue Jul 12 2022 17:02:18 by 1.7.2