To read a tipping spoon rain guage

Dependencies:   DHT11 GPS MTS-Serial PulseCounter mbed-rtos mbed

Fork of mDot_LoRa_Connect_Example by MultiTech

Committer:
Mehrad
Date:
Fri Jun 10 00:07:31 2016 +0000
Revision:
5:72944fa033f9
Initial commit

Who changed what in which revision?

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