with 36errors

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

Fork of Dot-AT-Firmware by MultiTech

Committer:
faendder
Date:
Sun Jul 09 23:37:23 2017 +0000
Revision:
18:75cd82d6298c
Parent:
16:d5cf2af81a6d
i have 36 errors but i dont now how fixit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:e52ae6584f1c 1 /**
Mike Fiore 14:f9a77400b622 2 ******************************************************************************
Mike Fiore 14:f9a77400b622 3 * File Name : command.h
Mike Fiore 14:f9a77400b622 4 * Date : 18/04/2014 10:57:12
Mike Fiore 14:f9a77400b622 5 * Description : This file provides code for command line prompt
Mike Fiore 14:f9a77400b622 6 ******************************************************************************
Mike Fiore 14:f9a77400b622 7 *
Mike Fiore 14:f9a77400b622 8 * COPYRIGHT(c) 2014 MultiTech Systems, Inc.
Mike Fiore 14:f9a77400b622 9 *
Mike Fiore 14:f9a77400b622 10 * Redistribution and use in source and binary forms, with or without modification,
Mike Fiore 14:f9a77400b622 11 * are permitted provided that the following conditions are met:
Mike Fiore 14:f9a77400b622 12 * 1. Redistributions of source code must retain the above copyright notice,
Mike Fiore 14:f9a77400b622 13 * this list of conditions and the following disclaimer.
Mike Fiore 14:f9a77400b622 14 * 2. Redistributions in binary form must reproduce the above copyright notice,
Mike Fiore 14:f9a77400b622 15 * this list of conditions and the following disclaimer in the documentation
Mike Fiore 14:f9a77400b622 16 * and/or other materials provided with the distribution.
Mike Fiore 14:f9a77400b622 17 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Mike Fiore 14:f9a77400b622 18 * may be used to endorse or promote products derived from this software
Mike Fiore 14:f9a77400b622 19 * without specific prior written permission.
Mike Fiore 14:f9a77400b622 20 *
Mike Fiore 14:f9a77400b622 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Mike Fiore 14:f9a77400b622 22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Mike Fiore 14:f9a77400b622 23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Mike Fiore 14:f9a77400b622 24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Mike Fiore 14:f9a77400b622 25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Mike Fiore 14:f9a77400b622 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Mike Fiore 14:f9a77400b622 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Mike Fiore 14:f9a77400b622 28 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Mike Fiore 14:f9a77400b622 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Mike Fiore 14:f9a77400b622 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Mike Fiore 14:f9a77400b622 31 *
Mike Fiore 14:f9a77400b622 32 ******************************************************************************
Mike Fiore 14:f9a77400b622 33 */
Mike Fiore 14:f9a77400b622 34
Mike Fiore 1:e52ae6584f1c 35 #include "mbed.h"
Mike Fiore 9:ff62b20f7000 36 #include "ATSerial.h"
Mike Fiore 1:e52ae6584f1c 37 #include "MTSSerial.h"
Mike Fiore 9:ff62b20f7000 38 #include "MTSSerialFlowControl.h"
Mike Fiore 1:e52ae6584f1c 39 #include "Commands.h"
Mike Fiore 1:e52ae6584f1c 40 #include "mDot.h"
Mike Fiore 9:ff62b20f7000 41 #include "mDotEvent.h"
Mike Fiore 14:f9a77400b622 42
Mike Fiore 1:e52ae6584f1c 43 /* Define to prevent recursive inclusion -------------------------------------*/
Mike Fiore 1:e52ae6584f1c 44 #ifndef __command_terminal_H__
Mike Fiore 1:e52ae6584f1c 45 #define __command_terminal_H__
Mike Fiore 1:e52ae6584f1c 46
Mike Fiore 14:f9a77400b622 47 typedef uint32_t (*action_ptr_t)(std::vector<std::string> args);
Mike Fiore 14:f9a77400b622 48 typedef bool (*verify_ptr_t)(std::vector<std::string> args);
Mike Fiore 14:f9a77400b622 49
Mike Fiore 14:f9a77400b622 50 class Command;
Mike Fiore 14:f9a77400b622 51
Mike Fiore 1:e52ae6584f1c 52 class CommandTerminal {
Mike Fiore 1:e52ae6584f1c 53
Mike Fiore 14:f9a77400b622 54 class RadioEvent : public mDotEvent {
Mike Fiore 9:ff62b20f7000 55
Mike Fiore 14:f9a77400b622 56 public:
Mike Fiore 14:f9a77400b622 57 RadioEvent() : _sendAck(false) {}
Mike Fiore 9:ff62b20f7000 58
Mike Fiore 9:ff62b20f7000 59 virtual ~RadioEvent() {}
Mike Fiore 9:ff62b20f7000 60
Mike Fiore 14:f9a77400b622 61 virtual void TxDone(uint8_t dr) {
Mike Fiore 14:f9a77400b622 62 mDotEvent::TxDone(dr);
Mike Fiore 14:f9a77400b622 63
Mike Fiore 14:f9a77400b622 64 logDebug("RadioEvent - TxDone");
Mike Fiore 14:f9a77400b622 65 }
Mike Fiore 14:f9a77400b622 66
Mike Fiore 14:f9a77400b622 67 virtual void TxTimeout(void) {
Mike Fiore 14:f9a77400b622 68 mDotEvent::TxTimeout();
Mike Fiore 14:f9a77400b622 69
Mike Fiore 14:f9a77400b622 70 logDebug("RadioEvent - TxTimeout");
Mike Fiore 14:f9a77400b622 71 }
Mike Fiore 14:f9a77400b622 72
Mike Fiore 14:f9a77400b622 73 virtual void JoinAccept(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) {
Mike Fiore 14:f9a77400b622 74 mDotEvent::JoinAccept(payload, size, rssi, snr);
Mike Fiore 14:f9a77400b622 75
Mike Fiore 14:f9a77400b622 76 logDebug("RadioEvent - JoinAccept");
Mike Fiore 14:f9a77400b622 77 }
Mike Fiore 14:f9a77400b622 78
jenkins@jenkinsdm1 16:d5cf2af81a6d 79 virtual void JoinFailed(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) {
jenkins@jenkinsdm1 16:d5cf2af81a6d 80 mDotEvent::JoinFailed(payload, size, rssi, snr);
jenkins@jenkinsdm1 16:d5cf2af81a6d 81
jenkins@jenkinsdm1 16:d5cf2af81a6d 82 logDebug("RadioEvent - JoinFailed");
jenkins@jenkinsdm1 16:d5cf2af81a6d 83 }
jenkins@jenkinsdm1 16:d5cf2af81a6d 84
Mike Fiore 14:f9a77400b622 85 virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries = 0);
Mike Fiore 14:f9a77400b622 86
Mike Fiore 14:f9a77400b622 87 virtual void RxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot) {
Mike Fiore 14:f9a77400b622 88 mDotEvent::RxDone(payload, size, rssi, snr, ctrl, slot);
Mike Fiore 14:f9a77400b622 89
Mike Fiore 14:f9a77400b622 90 logDebug("RadioEvent - RxDone");
Mike Fiore 14:f9a77400b622 91 }
Mike Fiore 14:f9a77400b622 92
Mike Fiore 14:f9a77400b622 93 virtual void Pong(int16_t m_rssi, int8_t m_snr, int16_t s_rssi, int8_t s_snr) {
Mike Fiore 14:f9a77400b622 94 mDotEvent::Pong(m_rssi, m_snr, s_rssi, s_snr);
Mike Fiore 14:f9a77400b622 95
Mike Fiore 14:f9a77400b622 96 logDebug("RadioEvent - Pong");
Mike Fiore 14:f9a77400b622 97 }
Mike Fiore 14:f9a77400b622 98
Mike Fiore 14:f9a77400b622 99 virtual void NetworkLinkCheck(int16_t m_rssi, int8_t m_snr, int8_t s_snr, uint8_t s_gateways) {
Mike Fiore 14:f9a77400b622 100 mDotEvent::NetworkLinkCheck(m_rssi, m_snr, s_snr, s_gateways);
Mike Fiore 14:f9a77400b622 101
Mike Fiore 14:f9a77400b622 102 logDebug("RadioEvent - NetworkLinkCheck");
Mike Fiore 14:f9a77400b622 103 }
Mike Fiore 14:f9a77400b622 104
Mike Fiore 14:f9a77400b622 105 virtual void RxTimeout(uint8_t slot) {
Mike Fiore 14:f9a77400b622 106 mDotEvent::RxTimeout(slot);
Mike Fiore 14:f9a77400b622 107
Mike Fiore 14:f9a77400b622 108 // logDebug("RadioEvent - RxTimeout");
Mike Fiore 14:f9a77400b622 109 }
Mike Fiore 14:f9a77400b622 110
Mike Fiore 14:f9a77400b622 111 virtual void RxError(uint8_t slot) {
Mike Fiore 14:f9a77400b622 112 mDotEvent::RxError(slot);
Mike Fiore 14:f9a77400b622 113
Mike Fiore 14:f9a77400b622 114 logDebug("RadioEvent - RxError");
Mike Fiore 14:f9a77400b622 115 }
Mike Fiore 9:ff62b20f7000 116
Mike Fiore 9:ff62b20f7000 117 virtual uint8_t MeasureBattery(void) {
Mike Fiore 9:ff62b20f7000 118 return 255;
Mike Fiore 9:ff62b20f7000 119 }
Mike Fiore 9:ff62b20f7000 120
jenkins@jenkinsdm1 16:d5cf2af81a6d 121 virtual void MissedAck(uint8_t retries) {
jenkins@jenkinsdm1 16:d5cf2af81a6d 122 mDotEvent::MissedAck(retries);
jenkins@jenkinsdm1 16:d5cf2af81a6d 123 }
jenkins@jenkinsdm1 16:d5cf2af81a6d 124
Mike Fiore 14:f9a77400b622 125 bool SendAck() {
Mike Fiore 14:f9a77400b622 126 bool val = _sendAck;
Mike Fiore 14:f9a77400b622 127 _sendAck = false;
Mike Fiore 14:f9a77400b622 128 return val;
Mike Fiore 14:f9a77400b622 129 }
Mike Fiore 9:ff62b20f7000 130
Mike Fiore 14:f9a77400b622 131 bool _sendAck;
Mike Fiore 14:f9a77400b622 132 };
Mike Fiore 14:f9a77400b622 133
Mike Fiore 14:f9a77400b622 134 public:
Mike Fiore 1:e52ae6584f1c 135
Mike Fiore 1:e52ae6584f1c 136 enum WaitType {
Mike Fiore 1:e52ae6584f1c 137 WAIT_JOIN,
Mike Fiore 1:e52ae6584f1c 138 WAIT_RECV,
Mike Fiore 1:e52ae6584f1c 139 WAIT_LINK,
Mike Fiore 1:e52ae6584f1c 140 WAIT_SEND,
Mike Fiore 1:e52ae6584f1c 141 WAIT_NA
Mike Fiore 1:e52ae6584f1c 142 };
Mike Fiore 1:e52ae6584f1c 143
Mike Fiore 14:f9a77400b622 144 CommandTerminal(mts::ATSerial& serial);
Mike Fiore 9:ff62b20f7000 145 virtual ~CommandTerminal();
Mike Fiore 14:f9a77400b622 146
Mike Fiore 14:f9a77400b622 147 void init();
Mike Fiore 14:f9a77400b622 148
Mike Fiore 1:e52ae6584f1c 149 // Command prompt text...
Mike Fiore 1:e52ae6584f1c 150 static const char banner[];
Mike Fiore 1:e52ae6584f1c 151 static const char helpline[];
Mike Fiore 1:e52ae6584f1c 152 static const char prompt[];
Mike Fiore 14:f9a77400b622 153
Mike Fiore 1:e52ae6584f1c 154 // Command error text...
Mike Fiore 1:e52ae6584f1c 155 static const char command_error[];
Mike Fiore 14:f9a77400b622 156
Mike Fiore 1:e52ae6584f1c 157 // Response texts...
Mike Fiore 1:e52ae6584f1c 158 static const char help[];
Mike Fiore 1:e52ae6584f1c 159 static const char cmd_error[];
Mike Fiore 1:e52ae6584f1c 160 static const char newline[];
Mike Fiore 9:ff62b20f7000 161 static const char connect[];
Mike Fiore 9:ff62b20f7000 162 static const char no_carrier[];
Mike Fiore 1:e52ae6584f1c 163 static const char done[];
Mike Fiore 1:e52ae6584f1c 164 static const char error[];
Mike Fiore 1:e52ae6584f1c 165
Mike Fiore 1:e52ae6584f1c 166 // Escape sequence
Mike Fiore 1:e52ae6584f1c 167 static const char escape_sequence[];
Mike Fiore 14:f9a77400b622 168
Mike Fiore 1:e52ae6584f1c 169 static std::string formatPacketData(const std::vector<uint8_t>& data, const uint8_t& format);
Mike Fiore 1:e52ae6584f1c 170 static bool waitForEscape(int timeout, mDot* dot=NULL, WaitType wait=WAIT_NA);
Mike Fiore 1:e52ae6584f1c 171
Mike Fiore 1:e52ae6584f1c 172 void start();
Mike Fiore 14:f9a77400b622 173
Mike Fiore 14:f9a77400b622 174 static mts::ATSerial* Serial() {return _serialp;}
Mike Fiore 14:f9a77400b622 175 static mDot* Dot() {return _dot;}
Mike Fiore 14:f9a77400b622 176 static mDot* _dot;
Mike Fiore 1:e52ae6584f1c 177
Mike Fiore 14:f9a77400b622 178 static void setErrorMessage(const char* message);
Mike Fiore 14:f9a77400b622 179 static void setErrorMessage(const std::string& message);
Mike Fiore 14:f9a77400b622 180
Mike Fiore 14:f9a77400b622 181 protected:
Mike Fiore 14:f9a77400b622 182
Mike Fiore 14:f9a77400b622 183 static std::string _errorMessage;
Mike Fiore 14:f9a77400b622 184
Mike Fiore 14:f9a77400b622 185 private:
Mike Fiore 4:666017851052 186
Mike Fiore 9:ff62b20f7000 187 mts::ATSerial& _serial;
Mike Fiore 9:ff62b20f7000 188 static mts::ATSerial* _serialp;
Mike Fiore 1:e52ae6584f1c 189
Mike Fiore 14:f9a77400b622 190 static CommandTerminal::RadioEvent* _events;
Mike Fiore 1:e52ae6584f1c 191 mDot::Mode _mode;
Mike Fiore 14:f9a77400b622 192
Mike Fiore 14:f9a77400b622 193 static const Command _commands[NO_OF_COMMANDS];
Mike Fiore 14:f9a77400b622 194 static const verify_ptr_t _verify[NO_OF_COMMANDS];
Mike Fiore 14:f9a77400b622 195 static const action_ptr_t _action[NO_OF_COMMANDS];
Mike Fiore 14:f9a77400b622 196
Mike Fiore 1:e52ae6584f1c 197 bool _sleep_standby;
Mike Fiore 1:e52ae6584f1c 198 DigitalOut _xbee_on_sleep;
Mike Fiore 14:f9a77400b622 199 bool _autoOTAEnabled;
Mike Fiore 1:e52ae6584f1c 200
Mike Fiore 9:ff62b20f7000 201 void serialLoop();
Mike Fiore 1:e52ae6584f1c 202 bool autoJoinCheck();
Mike Fiore 1:e52ae6584f1c 203
Mike Fiore 1:e52ae6584f1c 204 void printHelp();
Mike Fiore 1:e52ae6584f1c 205
Mike Fiore 14:f9a77400b622 206 static bool readable();
Mike Fiore 14:f9a77400b622 207 static bool writeable();
Mike Fiore 14:f9a77400b622 208 static char read();
Mike Fiore 14:f9a77400b622 209 static void write(const char* message);
Mike Fiore 14:f9a77400b622 210 static void writef(const char* format, ... );
Mike Fiore 1:e52ae6584f1c 211
Mike Fiore 1:e52ae6584f1c 212 void sleep(bool standby);
Mike Fiore 9:ff62b20f7000 213 void wakeup(void);
Mike Fiore 14:f9a77400b622 214
Mike Fiore 1:e52ae6584f1c 215 };
Mike Fiore 1:e52ae6584f1c 216
Mike Fiore 1:e52ae6584f1c 217 #endif // __command_terminal_H__