To read a light sensor

Dependencies:   DHT GPS MTS-Serial PulseCounter libmDot mbed-rtos mbed

Fork of mDot_LoRa_Connect_Example by MultiTech

Committer:
Mehrad
Date:
Fri Jun 10 00:04:08 2016 +0000
Revision:
5:951cfd165a58
Initial commit

Who changed what in which revision?

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