MicroLabo / Mbed OS mbed-Dot-AT-Firmware

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Command.h Source File

Command.h

00001 /**
00002  ******************************************************************************
00003  * File Name          : Command.h
00004  * Date               : 18/04/2014 10:57:12
00005  * Description        : This file provides code for command line prompt
00006  ******************************************************************************
00007  *
00008  * COPYRIGHT(c) 2014 MultiTech Systems, Inc.
00009  *
00010  * Redistribution and use in source and binary forms, with or without modification,
00011  * are permitted provided that the following conditions are met:
00012  *   1. Redistributions of source code must retain the above copyright notice,
00013  *      this list of conditions and the following disclaimer.
00014  *   2. Redistributions in binary form must reproduce the above copyright notice,
00015  *      this list of conditions and the following disclaimer in the documentation
00016  *      and/or other materials provided with the distribution.
00017  *   3. Neither the name of STMicroelectronics nor the names of its contributors
00018  *      may be used to endorse or promote products derived from this software
00019  *      without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00024  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00025  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00026  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00027  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00029  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00030  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  ******************************************************************************
00033  */
00034 
00035 #include "mbed.h"
00036 #include "mDot.h"
00037 #include "MTSSerial.h"
00038 #include "MTSText.h"
00039 #include <cstdlib>
00040 #include <string>
00041 #include <vector>
00042 #include "limits.h"
00043 #include "mts_at_debug.h"
00044 #include "CommandTerminal.h"
00045 
00046 
00047 /* Define to prevent recursive inclusion -------------------------------------*/
00048 #ifndef __command_H
00049 #define __command_H
00050 
00051 #define KEY_LENGTH 16
00052 #define EUI_LENGTH 8
00053 #define PASSPHRASE_LENGTH 128
00054 
00055 class Command {
00056 
00057     public:
00058 
00059         Command();
00060         Command(const char* name, const char* text, const char* desc, const char* usage);
00061         virtual ~Command() {};
00062 
00063         const char* name() const { return _name; };
00064         const char* text() const { return _text; };
00065         const char* desc() const { return _desc; };
00066         const std::string help() const {
00067             return std::string(text()) + ": " + std::string(desc());
00068         };
00069 
00070         std::string usage() const;
00071         const std::string& errorMessage() const;
00072         bool queryable() const;
00073 
00074         static const char newline[];
00075         static void readByteArray(const std::string& input, std::vector<uint8_t>& out, size_t len);
00076 
00077         static bool isHexString(const std::string& str, size_t bytes);
00078         static bool isBaudRate(uint32_t baud);
00079 
00080     protected:
00081 
00082         bool _queryable;
00083 
00084     private:
00085 
00086         const char* _name;
00087         const char* _text;
00088         const char* _desc;
00089         const char* _usage;
00090 
00091 };
00092 
00093 #endif /*__ command_H */
00094 
00095 /************************ (C) COPYRIGHT MultiTech Systems, Inc *****END OF FILE****/