AT Command Set mDot firmware with updated libmDot, to fix endian problem with joining LoRaWAN network

Dependencies:   MTS-Serial libmDot mbed-rtos mbed-src

Fork of mDot_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 "debug.h"
00044 
00045 /* Define to prevent recursive inclusion -------------------------------------*/
00046 #ifndef __command_H
00047 #define __command_H
00048 
00049 #define KEY_LENGTH 16
00050 #define EUI_LENGTH 8
00051 #define PASSPHRASE_LENGTH 128
00052 
00053 class Command {
00054 
00055     public:
00056 
00057         Command(mDot* dot);
00058         Command(mDot* dot, const char* name, const char* text, const char* desc);
00059         virtual ~Command() {};
00060 
00061         const char* name() const { return _name; };
00062         const char* text() const { return _text; };
00063         const char* desc() const { return _desc; };
00064         const char* help() const { return _help.c_str(); };
00065 
00066         virtual uint32_t action(std::vector<std::string> args) = 0;
00067         virtual bool verify(std::vector<std::string> args);
00068         const std::string usage() const;
00069         std::string& errorMessage();
00070         const bool queryable();
00071 
00072         static const char newline[];
00073         static void readByteArray(const std::string& input, std::vector<uint8_t>& out, size_t len);
00074 
00075         static bool isHexString(const std::string& str, size_t bytes);
00076         static bool isBaudRate(uint32_t baud);
00077 
00078     protected:
00079 
00080         void setErrorMessage(const char* message);
00081         void setErrorMessage(const std::string& message);
00082         std::string _help;
00083         std::string _usage;
00084         bool _queryable;
00085         mDot* _dot;
00086 
00087     private:
00088 
00089         const char* _name;
00090         const char* _text;
00091         const char* _desc;
00092         std::string _errorMessage;
00093 
00094 };
00095 
00096 #endif /*__ command_H */
00097 
00098 /************************ (C) COPYRIGHT MultiTech Systems, Inc *****END OF FILE****/