firm newest

Dependencies:   MTS-Serial libmDot-dev-mbed5-deprecated

Committer:
nguyenhoang9x5555
Date:
Mon Oct 22 01:56:09 2018 +0000
Revision:
1:c1c6549b9333
Parent:
0:3c869a8cb8f8
hey

Who changed what in which revision?

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