![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CommandTerminal.cpp@14:f9a77400b622, 2016-11-04 (annotated)
- Committer:
- Mike Fiore
- Date:
- Fri Nov 04 14:25:43 2016 -0500
- Revision:
- 14:f9a77400b622
- Parent:
- 11:05e0f30c03a6
- Child:
- 16:d5cf2af81a6d
update from git revision 2.0.16
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "ctype.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | #include "CommandTerminal.h" |
Mike Fiore |
1:e52ae6584f1c | 3 | #include "Command.h" |
Mike Fiore |
4:666017851052 | 4 | #include "MTSLog.h" |
Mike Fiore |
1:e52ae6584f1c | 5 | #include <cstdarg> |
Mike Fiore |
4:666017851052 | 6 | #include <deque> |
Mike Fiore |
14:f9a77400b622 | 7 | #if defined(TARGET_XDOT_L151CC) |
Mike Fiore |
14:f9a77400b622 | 8 | #include "xdot_low_power.h" |
Mike Fiore |
14:f9a77400b622 | 9 | #endif |
Mike Fiore |
1:e52ae6584f1c | 10 | |
Mike Fiore |
14:f9a77400b622 | 11 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
1:e52ae6584f1c | 12 | const char CommandTerminal::banner[] = "\r\n\nMultiTech Systems LoRa XBee Module\r\n\n"; |
Mike Fiore |
14:f9a77400b622 | 13 | #else |
Mike Fiore |
14:f9a77400b622 | 14 | const char CommandTerminal::banner[] = "\r\n\nMultiTech Systems LoRa xDot Module\r\n\n"; |
Mike Fiore |
14:f9a77400b622 | 15 | #endif |
Mike Fiore |
1:e52ae6584f1c | 16 | const char CommandTerminal::helpline[] = "Enter '?' for help\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 17 | |
Mike Fiore |
1:e52ae6584f1c | 18 | const char CommandTerminal::newline[] = "\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 19 | |
Mike Fiore |
1:e52ae6584f1c | 20 | // Command error text... |
Mike Fiore |
1:e52ae6584f1c | 21 | const char CommandTerminal::command_error[] = "Command not found!\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 22 | |
Mike Fiore |
1:e52ae6584f1c | 23 | // Response texts... |
Mike Fiore |
1:e52ae6584f1c | 24 | const char CommandTerminal::help[] = "\r\nHelp\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 25 | const char CommandTerminal::cmd_error[] = "Invalid command\r\n"; |
Mike Fiore |
9:ff62b20f7000 | 26 | const char CommandTerminal::connect[] = "\r\nCONNECT\r\n"; |
Mike Fiore |
9:ff62b20f7000 | 27 | const char CommandTerminal::no_carrier[] = "\r\nNO CARRIER\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 28 | const char CommandTerminal::done[] = "\r\nOK\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 29 | const char CommandTerminal::error[] = "\r\nERROR\r\n"; |
Mike Fiore |
1:e52ae6584f1c | 30 | |
Mike Fiore |
1:e52ae6584f1c | 31 | // Escape sequence... |
Mike Fiore |
1:e52ae6584f1c | 32 | const char CommandTerminal::escape_sequence[] = "+++"; |
Mike Fiore |
1:e52ae6584f1c | 33 | |
Mike Fiore |
9:ff62b20f7000 | 34 | mts::ATSerial* CommandTerminal::_serialp = NULL; |
Mike Fiore |
14:f9a77400b622 | 35 | mDot* CommandTerminal::_dot = NULL; |
Mike Fiore |
14:f9a77400b622 | 36 | |
Mike Fiore |
14:f9a77400b622 | 37 | CommandTerminal::RadioEvent* CommandTerminal::_events = new RadioEvent(); |
Mike Fiore |
9:ff62b20f7000 | 38 | |
Mike Fiore |
9:ff62b20f7000 | 39 | static bool serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 40 | static bool peer_to_peer = false; |
Mike Fiore |
1:e52ae6584f1c | 41 | |
Mike Fiore |
14:f9a77400b622 | 42 | std::string CommandTerminal::_errorMessage = ""; |
Mike Fiore |
14:f9a77400b622 | 43 | |
Mike Fiore |
14:f9a77400b622 | 44 | void CommandTerminal::setErrorMessage(const char* message) { |
Mike Fiore |
14:f9a77400b622 | 45 | _errorMessage.assign(message); |
Mike Fiore |
14:f9a77400b622 | 46 | } |
Mike Fiore |
14:f9a77400b622 | 47 | |
Mike Fiore |
14:f9a77400b622 | 48 | void CommandTerminal::setErrorMessage(const std::string& message) { |
Mike Fiore |
14:f9a77400b622 | 49 | _errorMessage.assign(message); |
Mike Fiore |
1:e52ae6584f1c | 50 | } |
Mike Fiore |
1:e52ae6584f1c | 51 | |
Mike Fiore |
14:f9a77400b622 | 52 | const Command CommandTerminal::_commands[NO_OF_COMMANDS] = { |
Mike Fiore |
14:f9a77400b622 | 53 | CmdAttention(), |
Mike Fiore |
14:f9a77400b622 | 54 | CmdIdentification(), |
Mike Fiore |
14:f9a77400b622 | 55 | CmdResetCpu(), |
Mike Fiore |
14:f9a77400b622 | 56 | CmdDummy("Enable/Disable Echo", "ATE", "ATE0: disable, ATE1: enable", "(0,1)"), |
Mike Fiore |
14:f9a77400b622 | 57 | CmdDummy("Enable/Disable Verbose", "ATV", "ATV0: disable, ATV1: enable", "(0,1)"), |
Mike Fiore |
14:f9a77400b622 | 58 | CmdDummy("Hardware Flow Control", "AT&K", "AT&K0: disable, AT&K3: enable", "(0,3)"), |
Mike Fiore |
14:f9a77400b622 | 59 | |
Mike Fiore |
14:f9a77400b622 | 60 | CmdFactoryDefault(), |
Mike Fiore |
14:f9a77400b622 | 61 | CmdSaveConfig(), |
Mike Fiore |
14:f9a77400b622 | 62 | CmdDisplayConfig(), |
Mike Fiore |
14:f9a77400b622 | 63 | CmdDisplayStats(), |
Mike Fiore |
14:f9a77400b622 | 64 | CmdResetStats(), |
Mike Fiore |
14:f9a77400b622 | 65 | CmdSerialBaudRate(), |
Mike Fiore |
14:f9a77400b622 | 66 | CmdDebugBaudRate(), |
Mike Fiore |
14:f9a77400b622 | 67 | CmdStartUpMode(), |
Mike Fiore |
14:f9a77400b622 | 68 | |
Mike Fiore |
14:f9a77400b622 | 69 | CmdFrequencyBand(), |
Mike Fiore |
14:f9a77400b622 | 70 | CmdFrequencySubBand(), |
Mike Fiore |
14:f9a77400b622 | 71 | CmdPublicNetwork(), |
Mike Fiore |
14:f9a77400b622 | 72 | CmdDeviceId(), |
Mike Fiore |
14:f9a77400b622 | 73 | CmdDeviceClass(), |
Mike Fiore |
14:f9a77400b622 | 74 | |
Mike Fiore |
14:f9a77400b622 | 75 | CmdAppPort(), |
Mike Fiore |
14:f9a77400b622 | 76 | CmdNetworkAddress(), |
Mike Fiore |
14:f9a77400b622 | 77 | CmdNetworkSessionKey(), |
Mike Fiore |
14:f9a77400b622 | 78 | CmdDataSessionKey(), |
Mike Fiore |
14:f9a77400b622 | 79 | CmdUplinkCounter(), |
Mike Fiore |
14:f9a77400b622 | 80 | CmdDownlinkCounter(), |
Mike Fiore |
14:f9a77400b622 | 81 | CmdSaveSession(), |
Mike Fiore |
14:f9a77400b622 | 82 | CmdRestoreSession(), |
Mike Fiore |
14:f9a77400b622 | 83 | CmdNetworkKey(), |
Mike Fiore |
14:f9a77400b622 | 84 | CmdNetworkId(), |
Mike Fiore |
1:e52ae6584f1c | 85 | |
Mike Fiore |
14:f9a77400b622 | 86 | CmdJoinDelay(), |
Mike Fiore |
14:f9a77400b622 | 87 | // Remove join settings commands until valid case for changing default settings |
Mike Fiore |
14:f9a77400b622 | 88 | // CmdJoinRx1Offset(), |
Mike Fiore |
14:f9a77400b622 | 89 | // CmdJoinRx2Datarate(), |
Mike Fiore |
14:f9a77400b622 | 90 | // CmdJoinRx2Frequency(), |
Mike Fiore |
14:f9a77400b622 | 91 | CmdJoinRequest(), |
Mike Fiore |
14:f9a77400b622 | 92 | CmdJoinRetries(), |
Mike Fiore |
14:f9a77400b622 | 93 | CmdJoinByteOrder(), |
Mike Fiore |
14:f9a77400b622 | 94 | CmdNetworkJoinMode(), |
Mike Fiore |
14:f9a77400b622 | 95 | CmdPreserveSession(), |
Mike Fiore |
14:f9a77400b622 | 96 | CmdNetworkJoinStatus(), |
Mike Fiore |
14:f9a77400b622 | 97 | CmdNetworkLinkCheck(), |
Mike Fiore |
14:f9a77400b622 | 98 | CmdLinkCheckCount(), |
Mike Fiore |
14:f9a77400b622 | 99 | CmdLinkCheckThreshold(), |
Mike Fiore |
14:f9a77400b622 | 100 | CmdEncryption(), |
Mike Fiore |
14:f9a77400b622 | 101 | |
Mike Fiore |
14:f9a77400b622 | 102 | CmdRssi(), |
Mike Fiore |
14:f9a77400b622 | 103 | CmdSnr(), |
Mike Fiore |
14:f9a77400b622 | 104 | CmdDataPending(), |
Mike Fiore |
14:f9a77400b622 | 105 | |
Mike Fiore |
14:f9a77400b622 | 106 | CmdSessionDataRate(), |
Mike Fiore |
14:f9a77400b622 | 107 | CmdChannelMask(), |
Mike Fiore |
1:e52ae6584f1c | 108 | |
Mike Fiore |
14:f9a77400b622 | 109 | CmdTxDataRate(), |
Mike Fiore |
14:f9a77400b622 | 110 | CmdTxPower(), |
Mike Fiore |
14:f9a77400b622 | 111 | CmdAntennaGain(), |
Mike Fiore |
14:f9a77400b622 | 112 | CmdTxFrequency(), |
Mike Fiore |
14:f9a77400b622 | 113 | CmdTxInverted(), |
Mike Fiore |
14:f9a77400b622 | 114 | CmdTxWait(), |
Mike Fiore |
14:f9a77400b622 | 115 | CmdTxChannel(), |
Mike Fiore |
14:f9a77400b622 | 116 | CmdTxNextMs(), |
Mike Fiore |
14:f9a77400b622 | 117 | CmdTimeOnAir(), |
Mike Fiore |
14:f9a77400b622 | 118 | |
Mike Fiore |
14:f9a77400b622 | 119 | CmdRxDelay(), |
Mike Fiore |
14:f9a77400b622 | 120 | CmdRxOutput(), |
Mike Fiore |
14:f9a77400b622 | 121 | CmdRxInverted(), |
Mike Fiore |
14:f9a77400b622 | 122 | |
Mike Fiore |
14:f9a77400b622 | 123 | CmdErrorCorrection(), |
Mike Fiore |
14:f9a77400b622 | 124 | CmdCRC(), |
Mike Fiore |
14:f9a77400b622 | 125 | CmdAdaptiveDataRate(), |
Mike Fiore |
14:f9a77400b622 | 126 | |
Mike Fiore |
14:f9a77400b622 | 127 | CmdACKAttempts(), |
Mike Fiore |
14:f9a77400b622 | 128 | CmdRepeat(), |
Mike Fiore |
14:f9a77400b622 | 129 | CmdMacCmd(), |
Mike Fiore |
14:f9a77400b622 | 130 | |
Mike Fiore |
14:f9a77400b622 | 131 | CmdSendString(), |
Mike Fiore |
14:f9a77400b622 | 132 | CmdSendBinary(), |
Mike Fiore |
14:f9a77400b622 | 133 | CmdReceiveOnce(), |
Mike Fiore |
1:e52ae6584f1c | 134 | |
Mike Fiore |
14:f9a77400b622 | 135 | CmdDummy("Serial Data Mode", "AT+SD", "Enter serial data mode, exit with '+++'", "NONE"), |
Mike Fiore |
14:f9a77400b622 | 136 | CmdDummy("Sleep Mode", "AT+SLEEP", "Enter sleep mode (0:deepsleep,1:sleep)", "(0,1)"), |
Mike Fiore |
14:f9a77400b622 | 137 | CmdSerialClearOnError(), |
Mike Fiore |
14:f9a77400b622 | 138 | CmdWakeMode(), |
Mike Fiore |
14:f9a77400b622 | 139 | CmdWakeInterval(), |
Mike Fiore |
14:f9a77400b622 | 140 | CmdWakePin(), |
Mike Fiore |
14:f9a77400b622 | 141 | CmdWakeDelay(), |
Mike Fiore |
14:f9a77400b622 | 142 | CmdWakeTimeout(), |
Mike Fiore |
14:f9a77400b622 | 143 | CmdPing(), |
Mike Fiore |
14:f9a77400b622 | 144 | CmdLogLevel(), |
Mike Fiore |
14:f9a77400b622 | 145 | |
Mike Fiore |
14:f9a77400b622 | 146 | CmdDummy("***** Test Commands *****", "", "", ""), |
Mike Fiore |
14:f9a77400b622 | 147 | CmdRxDataRate(), |
Mike Fiore |
14:f9a77400b622 | 148 | CmdRxFrequency(), |
Mike Fiore |
14:f9a77400b622 | 149 | CmdReceiveContinuous(), |
Mike Fiore |
14:f9a77400b622 | 150 | CmdSendStringOnInterval(), |
Mike Fiore |
14:f9a77400b622 | 151 | |
Mike Fiore |
14:f9a77400b622 | 152 | #ifdef MTS_RADIO_DEBUG_COMMANDS |
Mike Fiore |
14:f9a77400b622 | 153 | CmdDummy("***** Debug Commands *****", "", "", ""), |
Mike Fiore |
14:f9a77400b622 | 154 | CmdSendContinuous(), |
Mike Fiore |
14:f9a77400b622 | 155 | CmdWriteProtectedConfig(), |
Mike Fiore |
14:f9a77400b622 | 156 | CmdDumpRegisters(), |
Mike Fiore |
14:f9a77400b622 | 157 | CmdEraseFlash(), |
Mike Fiore |
14:f9a77400b622 | 158 | CmdDisableDutyCycle(), |
Mike Fiore |
14:f9a77400b622 | 159 | #endif |
Mike Fiore |
14:f9a77400b622 | 160 | |
Mike Fiore |
14:f9a77400b622 | 161 | }; |
Mike Fiore |
14:f9a77400b622 | 162 | |
Mike Fiore |
14:f9a77400b622 | 163 | const verify_ptr_t CommandTerminal::_verify[NO_OF_COMMANDS] = { |
Mike Fiore |
14:f9a77400b622 | 164 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 165 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 166 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 167 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 168 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 169 | CmdDummy::verify, |
Mike Fiore |
1:e52ae6584f1c | 170 | |
Mike Fiore |
14:f9a77400b622 | 171 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 172 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 173 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 174 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 175 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 176 | CmdSerialBaudRate::verify, |
Mike Fiore |
14:f9a77400b622 | 177 | CmdDebugBaudRate::verify, |
Mike Fiore |
14:f9a77400b622 | 178 | CmdStartUpMode::verify, |
Mike Fiore |
14:f9a77400b622 | 179 | |
Mike Fiore |
14:f9a77400b622 | 180 | CmdFrequencyBand::verify, |
Mike Fiore |
14:f9a77400b622 | 181 | CmdFrequencySubBand::verify, |
Mike Fiore |
14:f9a77400b622 | 182 | CmdPublicNetwork::verify, |
Mike Fiore |
14:f9a77400b622 | 183 | CmdDeviceId::verify, |
Mike Fiore |
14:f9a77400b622 | 184 | CmdDeviceClass::verify, |
Mike Fiore |
1:e52ae6584f1c | 185 | |
Mike Fiore |
14:f9a77400b622 | 186 | CmdAppPort::verify, |
Mike Fiore |
14:f9a77400b622 | 187 | CmdNetworkAddress::verify, |
Mike Fiore |
14:f9a77400b622 | 188 | CmdNetworkSessionKey::verify, |
Mike Fiore |
14:f9a77400b622 | 189 | CmdDataSessionKey::verify, |
Mike Fiore |
14:f9a77400b622 | 190 | CmdUplinkCounter::verify, |
Mike Fiore |
14:f9a77400b622 | 191 | CmdDownlinkCounter::verify, |
Mike Fiore |
14:f9a77400b622 | 192 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 193 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 194 | CmdNetworkKey::verify, |
Mike Fiore |
14:f9a77400b622 | 195 | CmdNetworkId::verify, |
Mike Fiore |
14:f9a77400b622 | 196 | |
Mike Fiore |
14:f9a77400b622 | 197 | CmdJoinDelay::verify, |
Mike Fiore |
14:f9a77400b622 | 198 | // Remove join settings commands until valid case for changing default settings |
Mike Fiore |
14:f9a77400b622 | 199 | // CmdJoinRx1Offset::verify, |
Mike Fiore |
14:f9a77400b622 | 200 | // CmdJoinRx2Datarate::verify, |
Mike Fiore |
14:f9a77400b622 | 201 | // CmdJoinRx2Frequency::verify, |
Mike Fiore |
14:f9a77400b622 | 202 | CmdJoinRequest::verify, |
Mike Fiore |
14:f9a77400b622 | 203 | CmdJoinRetries::verify, |
Mike Fiore |
14:f9a77400b622 | 204 | CmdJoinByteOrder::verify, |
Mike Fiore |
14:f9a77400b622 | 205 | CmdNetworkJoinMode::verify, |
Mike Fiore |
14:f9a77400b622 | 206 | CmdPreserveSession::verify, |
Mike Fiore |
14:f9a77400b622 | 207 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 208 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 209 | CmdLinkCheckCount::verify, |
Mike Fiore |
14:f9a77400b622 | 210 | CmdLinkCheckThreshold::verify, |
Mike Fiore |
14:f9a77400b622 | 211 | CmdEncryption::verify, |
Mike Fiore |
14:f9a77400b622 | 212 | |
Mike Fiore |
14:f9a77400b622 | 213 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 214 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 215 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 216 | |
Mike Fiore |
14:f9a77400b622 | 217 | CmdSessionDataRate::verify, |
Mike Fiore |
14:f9a77400b622 | 218 | CmdChannelMask::verify, |
Mike Fiore |
1:e52ae6584f1c | 219 | |
Mike Fiore |
14:f9a77400b622 | 220 | CmdTxDataRate::verify, |
Mike Fiore |
14:f9a77400b622 | 221 | CmdTxPower::verify, |
Mike Fiore |
14:f9a77400b622 | 222 | CmdAntennaGain::verify, |
Mike Fiore |
14:f9a77400b622 | 223 | CmdTxFrequency::verify, |
Mike Fiore |
14:f9a77400b622 | 224 | CmdTxInverted::verify, |
Mike Fiore |
14:f9a77400b622 | 225 | CmdTxWait::verify, |
Mike Fiore |
14:f9a77400b622 | 226 | CmdTxChannel::verify, |
Mike Fiore |
14:f9a77400b622 | 227 | CmdTxNextMs::verify, |
Mike Fiore |
14:f9a77400b622 | 228 | CmdTimeOnAir::verify, |
Mike Fiore |
14:f9a77400b622 | 229 | |
Mike Fiore |
14:f9a77400b622 | 230 | CmdRxDelay::verify, |
Mike Fiore |
14:f9a77400b622 | 231 | CmdRxOutput::verify, |
Mike Fiore |
14:f9a77400b622 | 232 | CmdRxInverted::verify, |
Mike Fiore |
14:f9a77400b622 | 233 | |
Mike Fiore |
14:f9a77400b622 | 234 | CmdErrorCorrection::verify, |
Mike Fiore |
14:f9a77400b622 | 235 | CmdCRC::verify, |
Mike Fiore |
14:f9a77400b622 | 236 | CmdAdaptiveDataRate::verify, |
Mike Fiore |
14:f9a77400b622 | 237 | |
Mike Fiore |
14:f9a77400b622 | 238 | CmdACKAttempts::verify, |
Mike Fiore |
14:f9a77400b622 | 239 | CmdRepeat::verify, |
Mike Fiore |
14:f9a77400b622 | 240 | CmdMacCmd::verify, |
Mike Fiore |
14:f9a77400b622 | 241 | |
Mike Fiore |
14:f9a77400b622 | 242 | CmdSendString::verify, |
Mike Fiore |
14:f9a77400b622 | 243 | CmdSendBinary::verify, |
Mike Fiore |
14:f9a77400b622 | 244 | CmdReceiveOnce::verify, |
Mike Fiore |
14:f9a77400b622 | 245 | |
Mike Fiore |
14:f9a77400b622 | 246 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 247 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 248 | CmdSerialClearOnError::verify, |
Mike Fiore |
14:f9a77400b622 | 249 | CmdWakeMode::verify, |
Mike Fiore |
14:f9a77400b622 | 250 | CmdWakeInterval::verify, |
Mike Fiore |
14:f9a77400b622 | 251 | CmdWakePin::verify, |
Mike Fiore |
14:f9a77400b622 | 252 | CmdWakeDelay::verify, |
Mike Fiore |
14:f9a77400b622 | 253 | CmdWakeTimeout::verify, |
Mike Fiore |
14:f9a77400b622 | 254 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 255 | CmdLogLevel::verify, |
Mike Fiore |
14:f9a77400b622 | 256 | |
Mike Fiore |
14:f9a77400b622 | 257 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 258 | CmdRxDataRate::verify, |
Mike Fiore |
14:f9a77400b622 | 259 | CmdRxFrequency::verify, |
Mike Fiore |
14:f9a77400b622 | 260 | CmdReceiveContinuous::verify, |
Mike Fiore |
14:f9a77400b622 | 261 | CmdSendStringOnInterval::verify, |
Mike Fiore |
1:e52ae6584f1c | 262 | |
Mike Fiore |
14:f9a77400b622 | 263 | #ifdef MTS_RADIO_DEBUG_COMMANDS |
Mike Fiore |
14:f9a77400b622 | 264 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 265 | CmdSendContinuous::verify, |
Mike Fiore |
14:f9a77400b622 | 266 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 267 | CmdDummy::verify, |
Mike Fiore |
14:f9a77400b622 | 268 | CmdEraseFlash::verify, |
Mike Fiore |
14:f9a77400b622 | 269 | CmdDisableDutyCycle::verify, |
Mike Fiore |
14:f9a77400b622 | 270 | #endif |
Mike Fiore |
1:e52ae6584f1c | 271 | |
Mike Fiore |
14:f9a77400b622 | 272 | }; |
Mike Fiore |
14:f9a77400b622 | 273 | |
Mike Fiore |
14:f9a77400b622 | 274 | const action_ptr_t CommandTerminal::_action[NO_OF_COMMANDS] = { |
Mike Fiore |
14:f9a77400b622 | 275 | CmdAttention::action, |
Mike Fiore |
14:f9a77400b622 | 276 | CmdIdentification::action, |
Mike Fiore |
14:f9a77400b622 | 277 | CmdResetCpu::action, |
Mike Fiore |
14:f9a77400b622 | 278 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 279 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 280 | CmdDummy::action, |
Mike Fiore |
9:ff62b20f7000 | 281 | |
Mike Fiore |
14:f9a77400b622 | 282 | CmdFactoryDefault::action, |
Mike Fiore |
14:f9a77400b622 | 283 | CmdSaveConfig::action, |
Mike Fiore |
14:f9a77400b622 | 284 | CmdDisplayConfig::action, |
Mike Fiore |
14:f9a77400b622 | 285 | CmdDisplayStats::action, |
Mike Fiore |
14:f9a77400b622 | 286 | CmdResetStats::action, |
Mike Fiore |
14:f9a77400b622 | 287 | CmdSerialBaudRate::action, |
Mike Fiore |
14:f9a77400b622 | 288 | CmdDebugBaudRate::action, |
Mike Fiore |
14:f9a77400b622 | 289 | CmdStartUpMode::action, |
Mike Fiore |
14:f9a77400b622 | 290 | |
Mike Fiore |
14:f9a77400b622 | 291 | CmdFrequencyBand::action, |
Mike Fiore |
14:f9a77400b622 | 292 | CmdFrequencySubBand::action, |
Mike Fiore |
14:f9a77400b622 | 293 | CmdPublicNetwork::action, |
Mike Fiore |
14:f9a77400b622 | 294 | CmdDeviceId::action, |
Mike Fiore |
14:f9a77400b622 | 295 | CmdDeviceClass::action, |
Mike Fiore |
14:f9a77400b622 | 296 | |
Mike Fiore |
14:f9a77400b622 | 297 | CmdAppPort::action, |
Mike Fiore |
14:f9a77400b622 | 298 | CmdNetworkAddress::action, |
Mike Fiore |
14:f9a77400b622 | 299 | CmdNetworkSessionKey::action, |
Mike Fiore |
14:f9a77400b622 | 300 | CmdDataSessionKey::action, |
Mike Fiore |
14:f9a77400b622 | 301 | CmdUplinkCounter::action, |
Mike Fiore |
14:f9a77400b622 | 302 | CmdDownlinkCounter::action, |
Mike Fiore |
14:f9a77400b622 | 303 | CmdSaveSession::action, |
Mike Fiore |
14:f9a77400b622 | 304 | CmdRestoreSession::action, |
Mike Fiore |
14:f9a77400b622 | 305 | CmdNetworkKey::action, |
Mike Fiore |
14:f9a77400b622 | 306 | CmdNetworkId::action, |
Mike Fiore |
1:e52ae6584f1c | 307 | |
Mike Fiore |
14:f9a77400b622 | 308 | CmdJoinDelay::action, |
Mike Fiore |
14:f9a77400b622 | 309 | // Remove join settings commands until valid case for changing default settings |
Mike Fiore |
14:f9a77400b622 | 310 | // CmdJoinRx1Offset::action, |
Mike Fiore |
14:f9a77400b622 | 311 | // CmdJoinRx2Datarate::action, |
Mike Fiore |
14:f9a77400b622 | 312 | // CmdJoinRx2Frequency::action, |
Mike Fiore |
14:f9a77400b622 | 313 | CmdJoinRequest::action, |
Mike Fiore |
14:f9a77400b622 | 314 | CmdJoinRetries::action, |
Mike Fiore |
14:f9a77400b622 | 315 | CmdJoinByteOrder::action, |
Mike Fiore |
14:f9a77400b622 | 316 | CmdNetworkJoinMode::action, |
Mike Fiore |
14:f9a77400b622 | 317 | CmdPreserveSession::action, |
Mike Fiore |
14:f9a77400b622 | 318 | CmdNetworkJoinStatus::action, |
Mike Fiore |
14:f9a77400b622 | 319 | CmdNetworkLinkCheck::action, |
Mike Fiore |
14:f9a77400b622 | 320 | CmdLinkCheckCount::action, |
Mike Fiore |
14:f9a77400b622 | 321 | CmdLinkCheckThreshold::action, |
Mike Fiore |
14:f9a77400b622 | 322 | CmdEncryption::action, |
Mike Fiore |
14:f9a77400b622 | 323 | |
Mike Fiore |
14:f9a77400b622 | 324 | CmdRssi::action, |
Mike Fiore |
14:f9a77400b622 | 325 | CmdSnr::action, |
Mike Fiore |
14:f9a77400b622 | 326 | CmdDataPending::action, |
Mike Fiore |
1:e52ae6584f1c | 327 | |
Mike Fiore |
14:f9a77400b622 | 328 | CmdSessionDataRate::action, |
Mike Fiore |
14:f9a77400b622 | 329 | CmdChannelMask::action, |
Mike Fiore |
1:e52ae6584f1c | 330 | |
Mike Fiore |
14:f9a77400b622 | 331 | CmdTxDataRate::action, |
Mike Fiore |
14:f9a77400b622 | 332 | CmdTxPower::action, |
Mike Fiore |
14:f9a77400b622 | 333 | CmdAntennaGain::action, |
Mike Fiore |
14:f9a77400b622 | 334 | CmdTxFrequency::action, |
Mike Fiore |
14:f9a77400b622 | 335 | CmdTxInverted::action, |
Mike Fiore |
14:f9a77400b622 | 336 | CmdTxWait::action, |
Mike Fiore |
14:f9a77400b622 | 337 | CmdTxChannel::action, |
Mike Fiore |
14:f9a77400b622 | 338 | CmdTxNextMs::action, |
Mike Fiore |
14:f9a77400b622 | 339 | CmdTimeOnAir::action, |
Mike Fiore |
1:e52ae6584f1c | 340 | |
Mike Fiore |
14:f9a77400b622 | 341 | CmdRxDelay::action, |
Mike Fiore |
14:f9a77400b622 | 342 | CmdRxOutput::action, |
Mike Fiore |
14:f9a77400b622 | 343 | CmdRxInverted::action, |
Mike Fiore |
14:f9a77400b622 | 344 | |
Mike Fiore |
14:f9a77400b622 | 345 | CmdErrorCorrection::action, |
Mike Fiore |
14:f9a77400b622 | 346 | CmdCRC::action, |
Mike Fiore |
14:f9a77400b622 | 347 | CmdAdaptiveDataRate::action, |
Mike Fiore |
14:f9a77400b622 | 348 | |
Mike Fiore |
14:f9a77400b622 | 349 | CmdACKAttempts::action, |
Mike Fiore |
14:f9a77400b622 | 350 | CmdRepeat::action, |
Mike Fiore |
14:f9a77400b622 | 351 | CmdMacCmd::action, |
Mike Fiore |
1:e52ae6584f1c | 352 | |
Mike Fiore |
14:f9a77400b622 | 353 | CmdSendString::action, |
Mike Fiore |
14:f9a77400b622 | 354 | CmdSendBinary::action, |
Mike Fiore |
14:f9a77400b622 | 355 | CmdReceiveOnce::action, |
Mike Fiore |
14:f9a77400b622 | 356 | |
Mike Fiore |
14:f9a77400b622 | 357 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 358 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 359 | CmdSerialClearOnError::action, |
Mike Fiore |
14:f9a77400b622 | 360 | CmdWakeMode::action, |
Mike Fiore |
14:f9a77400b622 | 361 | CmdWakeInterval::action, |
Mike Fiore |
14:f9a77400b622 | 362 | CmdWakePin::action, |
Mike Fiore |
14:f9a77400b622 | 363 | CmdWakeDelay::action, |
Mike Fiore |
14:f9a77400b622 | 364 | CmdWakeTimeout::action, |
Mike Fiore |
14:f9a77400b622 | 365 | CmdPing::action, |
Mike Fiore |
14:f9a77400b622 | 366 | CmdLogLevel::action, |
Mike Fiore |
14:f9a77400b622 | 367 | |
Mike Fiore |
14:f9a77400b622 | 368 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 369 | CmdRxDataRate::action, |
Mike Fiore |
14:f9a77400b622 | 370 | CmdRxFrequency::action, |
Mike Fiore |
14:f9a77400b622 | 371 | CmdReceiveContinuous::action, |
Mike Fiore |
14:f9a77400b622 | 372 | CmdSendStringOnInterval::action, |
Mike Fiore |
9:ff62b20f7000 | 373 | |
Mike Fiore |
14:f9a77400b622 | 374 | #ifdef MTS_RADIO_DEBUG_COMMANDS |
Mike Fiore |
14:f9a77400b622 | 375 | CmdDummy::action, |
Mike Fiore |
14:f9a77400b622 | 376 | CmdSendContinuous::action, |
Mike Fiore |
14:f9a77400b622 | 377 | CmdWriteProtectedConfig::action, |
Mike Fiore |
14:f9a77400b622 | 378 | CmdDumpRegisters::action, |
Mike Fiore |
14:f9a77400b622 | 379 | CmdEraseFlash::action, |
Mike Fiore |
14:f9a77400b622 | 380 | CmdDisableDutyCycle::action, |
Mike Fiore |
14:f9a77400b622 | 381 | #endif |
Mike Fiore |
14:f9a77400b622 | 382 | |
Mike Fiore |
14:f9a77400b622 | 383 | }; |
Mike Fiore |
14:f9a77400b622 | 384 | |
Mike Fiore |
14:f9a77400b622 | 385 | CommandTerminal::CommandTerminal(mts::ATSerial& serial) : |
Mike Fiore |
14:f9a77400b622 | 386 | _serial(serial), |
Mike Fiore |
14:f9a77400b622 | 387 | _mode(mDot::COMMAND_MODE), |
Mike Fiore |
14:f9a77400b622 | 388 | _sleep_standby(true), |
Mike Fiore |
14:f9a77400b622 | 389 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
14:f9a77400b622 | 390 | _xbee_on_sleep(XBEE_ON_SLEEP), |
Mike Fiore |
14:f9a77400b622 | 391 | #else |
Mike Fiore |
14:f9a77400b622 | 392 | _xbee_on_sleep(GPIO2), |
Mike Fiore |
14:f9a77400b622 | 393 | #endif |
Mike Fiore |
14:f9a77400b622 | 394 | _autoOTAEnabled(false) |
Mike Fiore |
14:f9a77400b622 | 395 | { |
Mike Fiore |
14:f9a77400b622 | 396 | _serialp = &serial; |
Mike Fiore |
14:f9a77400b622 | 397 | } |
Mike Fiore |
14:f9a77400b622 | 398 | |
Mike Fiore |
14:f9a77400b622 | 399 | void CommandTerminal::init() { |
Mike Fiore |
14:f9a77400b622 | 400 | _dot->setEvents(_events); |
Mike Fiore |
1:e52ae6584f1c | 401 | } |
Mike Fiore |
1:e52ae6584f1c | 402 | |
Mike Fiore |
1:e52ae6584f1c | 403 | void CommandTerminal::printHelp() { |
Mike Fiore |
1:e52ae6584f1c | 404 | const char* name = NULL; |
Mike Fiore |
1:e52ae6584f1c | 405 | const char* text = NULL; |
Mike Fiore |
1:e52ae6584f1c | 406 | const char* desc = NULL; |
Mike Fiore |
1:e52ae6584f1c | 407 | const char* tab = "\t"; |
Mike Fiore |
1:e52ae6584f1c | 408 | |
Mike Fiore |
1:e52ae6584f1c | 409 | std::string header("Command"); |
Mike Fiore |
1:e52ae6584f1c | 410 | header.append(tab); |
Mike Fiore |
1:e52ae6584f1c | 411 | header.append(tab); |
Mike Fiore |
1:e52ae6584f1c | 412 | header.append("Name"); |
Mike Fiore |
1:e52ae6584f1c | 413 | header.append(tab); |
Mike Fiore |
1:e52ae6584f1c | 414 | header.append(tab); |
Mike Fiore |
1:e52ae6584f1c | 415 | header.append(tab); |
Mike Fiore |
1:e52ae6584f1c | 416 | header.append("Description"); |
Mike Fiore |
1:e52ae6584f1c | 417 | |
Mike Fiore |
1:e52ae6584f1c | 418 | write(newline); |
Mike Fiore |
1:e52ae6584f1c | 419 | write(header.c_str()); |
Mike Fiore |
1:e52ae6584f1c | 420 | write(newline); |
Mike Fiore |
1:e52ae6584f1c | 421 | write(newline); |
Mike Fiore |
14:f9a77400b622 | 422 | |
Mike Fiore |
14:f9a77400b622 | 423 | for (int i = 0; i < NO_OF_COMMANDS; i++) { |
Mike Fiore |
14:f9a77400b622 | 424 | name = _commands[i].name(); |
Mike Fiore |
14:f9a77400b622 | 425 | text = _commands[i].text(); |
Mike Fiore |
14:f9a77400b622 | 426 | desc = _commands[i].desc(); |
Mike Fiore |
1:e52ae6584f1c | 427 | write(text); |
Mike Fiore |
1:e52ae6584f1c | 428 | if (strlen(text) < 8) |
Mike Fiore |
1:e52ae6584f1c | 429 | write(tab); |
Mike Fiore |
1:e52ae6584f1c | 430 | write(tab); |
Mike Fiore |
1:e52ae6584f1c | 431 | write(name); |
Mike Fiore |
1:e52ae6584f1c | 432 | if (strlen(name) < 8) |
Mike Fiore |
1:e52ae6584f1c | 433 | write(tab); |
Mike Fiore |
1:e52ae6584f1c | 434 | if (strlen(name) < 16) |
Mike Fiore |
1:e52ae6584f1c | 435 | write(tab); |
Mike Fiore |
1:e52ae6584f1c | 436 | write(tab); |
Mike Fiore |
1:e52ae6584f1c | 437 | write(desc); |
Mike Fiore |
1:e52ae6584f1c | 438 | write(newline); |
Mike Fiore |
1:e52ae6584f1c | 439 | } |
Mike Fiore |
1:e52ae6584f1c | 440 | |
Mike Fiore |
1:e52ae6584f1c | 441 | write(newline); |
Mike Fiore |
1:e52ae6584f1c | 442 | } |
Mike Fiore |
1:e52ae6584f1c | 443 | |
Mike Fiore |
1:e52ae6584f1c | 444 | bool CommandTerminal::writeable() { |
Mike Fiore |
14:f9a77400b622 | 445 | return _serialp->writeable(); |
Mike Fiore |
1:e52ae6584f1c | 446 | } |
Mike Fiore |
1:e52ae6584f1c | 447 | |
Mike Fiore |
1:e52ae6584f1c | 448 | bool CommandTerminal::readable() { |
Mike Fiore |
14:f9a77400b622 | 449 | return _serialp->readable(); |
Mike Fiore |
1:e52ae6584f1c | 450 | } |
Mike Fiore |
1:e52ae6584f1c | 451 | |
Mike Fiore |
1:e52ae6584f1c | 452 | char CommandTerminal::read() { |
Mike Fiore |
1:e52ae6584f1c | 453 | char ch; |
Mike Fiore |
14:f9a77400b622 | 454 | _serialp->read(&ch, 1); |
Mike Fiore |
1:e52ae6584f1c | 455 | return ch; |
Mike Fiore |
1:e52ae6584f1c | 456 | } |
Mike Fiore |
1:e52ae6584f1c | 457 | |
Mike Fiore |
1:e52ae6584f1c | 458 | void CommandTerminal::write(const char* message) { |
Mike Fiore |
1:e52ae6584f1c | 459 | while (!writeable()) |
Mike Fiore |
1:e52ae6584f1c | 460 | ; |
Mike Fiore |
14:f9a77400b622 | 461 | _serialp->write(message, strlen(message)); |
Mike Fiore |
1:e52ae6584f1c | 462 | } |
Mike Fiore |
1:e52ae6584f1c | 463 | |
Mike Fiore |
1:e52ae6584f1c | 464 | void CommandTerminal::writef(const char* format, ...) { |
Mike Fiore |
1:e52ae6584f1c | 465 | char buff[256]; |
Mike Fiore |
1:e52ae6584f1c | 466 | |
Mike Fiore |
1:e52ae6584f1c | 467 | va_list ap; |
Mike Fiore |
1:e52ae6584f1c | 468 | va_start(ap, format); |
Mike Fiore |
1:e52ae6584f1c | 469 | int size = vsnprintf(buff, 256, format, ap); |
Mike Fiore |
1:e52ae6584f1c | 470 | while (!writeable()) |
Mike Fiore |
1:e52ae6584f1c | 471 | ; |
Mike Fiore |
14:f9a77400b622 | 472 | _serialp->write(buff, size); |
Mike Fiore |
1:e52ae6584f1c | 473 | va_end(ap); |
Mike Fiore |
1:e52ae6584f1c | 474 | } |
Mike Fiore |
1:e52ae6584f1c | 475 | |
Mike Fiore |
9:ff62b20f7000 | 476 | void CommandTerminal::serialLoop() { |
Mike Fiore |
1:e52ae6584f1c | 477 | Timer serial_read_timer; |
Mike Fiore |
1:e52ae6584f1c | 478 | std::vector<uint8_t> serial_buffer; |
Mike Fiore |
9:ff62b20f7000 | 479 | std::vector<uint8_t> data; |
Mike Fiore |
9:ff62b20f7000 | 480 | int timeout = 0; |
Mike Fiore |
1:e52ae6584f1c | 481 | |
Mike Fiore |
9:ff62b20f7000 | 482 | serial_read_timer.start(); |
Mike Fiore |
1:e52ae6584f1c | 483 | |
Mike Fiore |
9:ff62b20f7000 | 484 | if (_dot->getStartUpMode() == mDot::SERIAL_MODE) { |
Mike Fiore |
9:ff62b20f7000 | 485 | _xbee_on_sleep = GPIO_PIN_SET; |
Mike Fiore |
1:e52ae6584f1c | 486 | |
Mike Fiore |
9:ff62b20f7000 | 487 | timeout = _dot->getWakeDelay(); |
Mike Fiore |
1:e52ae6584f1c | 488 | |
Mike Fiore |
9:ff62b20f7000 | 489 | // wait for timeout or start of serial data |
Mike Fiore |
14:f9a77400b622 | 490 | while (!readable() && serial_read_timer.read_ms() < timeout && !_serialp->escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 491 | osDelay(2); |
Mike Fiore |
1:e52ae6584f1c | 492 | } |
Mike Fiore |
1:e52ae6584f1c | 493 | } |
Mike Fiore |
1:e52ae6584f1c | 494 | |
Mike Fiore |
14:f9a77400b622 | 495 | if (!readable() && _events->SendAck()) { |
Mike Fiore |
14:f9a77400b622 | 496 | logDebug("SERIAL NOT READABLE and ACK REQUESTED"); |
Mike Fiore |
14:f9a77400b622 | 497 | goto L_SEND; |
Mike Fiore |
14:f9a77400b622 | 498 | } |
Mike Fiore |
14:f9a77400b622 | 499 | |
Mike Fiore |
14:f9a77400b622 | 500 | if (readable() && !_serialp->escaped()) { |
Mike Fiore |
6:e27eaad36a0c | 501 | |
Mike Fiore |
6:e27eaad36a0c | 502 | serial_read_timer.reset(); |
Mike Fiore |
6:e27eaad36a0c | 503 | timeout = _dot->getWakeTimeout(); |
Mike Fiore |
9:ff62b20f7000 | 504 | |
Mike Fiore |
9:ff62b20f7000 | 505 | while (serial_read_timer.read_ms() < timeout && serial_buffer.size() <= _dot->getMaxPacketLength()) { |
Mike Fiore |
9:ff62b20f7000 | 506 | while (readable() && serial_buffer.size() < _dot->getMaxPacketLength()) { |
Mike Fiore |
1:e52ae6584f1c | 507 | serial_buffer.push_back(read()); |
Mike Fiore |
1:e52ae6584f1c | 508 | serial_read_timer.reset(); |
Mike Fiore |
9:ff62b20f7000 | 509 | |
Mike Fiore |
14:f9a77400b622 | 510 | if (_serialp->escaped()) |
Mike Fiore |
9:ff62b20f7000 | 511 | break; |
Mike Fiore |
1:e52ae6584f1c | 512 | } |
Mike Fiore |
1:e52ae6584f1c | 513 | } |
Mike Fiore |
9:ff62b20f7000 | 514 | |
Mike Fiore |
1:e52ae6584f1c | 515 | serial_read_timer.stop(), serial_read_timer.reset(); |
Mike Fiore |
1:e52ae6584f1c | 516 | |
Mike Fiore |
1:e52ae6584f1c | 517 | if (!serial_buffer.empty()) { |
Mike Fiore |
9:ff62b20f7000 | 518 | if (_dot->getStartUpMode() == mDot::SERIAL_MODE) |
Mike Fiore |
14:f9a77400b622 | 519 | _xbee_on_sleep = GPIO_PIN_RESET; |
Mike Fiore |
9:ff62b20f7000 | 520 | |
Mike Fiore |
14:f9a77400b622 | 521 | L_SEND: |
Mike Fiore |
9:ff62b20f7000 | 522 | // wait for any duty cycle limit to expire |
Mike Fiore |
14:f9a77400b622 | 523 | while (_dot->getNextTxMs() > 0 && !_serialp->escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 524 | osDelay(10); |
Mike Fiore |
9:ff62b20f7000 | 525 | } |
Mike Fiore |
9:ff62b20f7000 | 526 | |
Mike Fiore |
14:f9a77400b622 | 527 | if (_dot->getIsIdle()) { |
Mike Fiore |
9:ff62b20f7000 | 528 | logDebug("Received serial data, sending out radio."); |
Mike Fiore |
9:ff62b20f7000 | 529 | |
Mike Fiore |
9:ff62b20f7000 | 530 | if (_dot->send(serial_buffer, false) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 531 | logDebug("Send failed."); |
Mike Fiore |
9:ff62b20f7000 | 532 | // If the data should be tossed after send failure, clear buffer |
Mike Fiore |
9:ff62b20f7000 | 533 | if (_dot->getSerialClearOnError()) { |
Mike Fiore |
9:ff62b20f7000 | 534 | serial_buffer.clear(); |
Mike Fiore |
9:ff62b20f7000 | 535 | } |
Mike Fiore |
9:ff62b20f7000 | 536 | } else { |
Mike Fiore |
1:e52ae6584f1c | 537 | |
Mike Fiore |
9:ff62b20f7000 | 538 | // wait for send to finish |
Mike Fiore |
14:f9a77400b622 | 539 | while (!_dot->getIsIdle() && !_serialp->escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 540 | osDelay(10); |
Mike Fiore |
14:f9a77400b622 | 541 | } |
Mike Fiore |
9:ff62b20f7000 | 542 | |
Mike Fiore |
9:ff62b20f7000 | 543 | // call recv to wait for any packet before sending again |
Mike Fiore |
14:f9a77400b622 | 544 | if (!_serialp->escaped()) |
Mike Fiore |
9:ff62b20f7000 | 545 | _dot->recv(data); |
Mike Fiore |
9:ff62b20f7000 | 546 | |
Mike Fiore |
9:ff62b20f7000 | 547 | // Clear the serial buffer if send is success |
Mike Fiore |
9:ff62b20f7000 | 548 | serial_buffer.clear(); |
Mike Fiore |
14:f9a77400b622 | 549 | |
Mike Fiore |
14:f9a77400b622 | 550 | // In class C mode pending data will be sent automatically without uplink |
Mike Fiore |
14:f9a77400b622 | 551 | if (_dot->getClass() != "C") { |
Mike Fiore |
14:f9a77400b622 | 552 | if (_dot->getDataPending()) { |
Mike Fiore |
14:f9a77400b622 | 553 | logDebug("Data is pending"); |
Mike Fiore |
14:f9a77400b622 | 554 | goto L_SEND; |
Mike Fiore |
14:f9a77400b622 | 555 | } |
Mike Fiore |
14:f9a77400b622 | 556 | if (_dot->getAckRequested()) { |
Mike Fiore |
14:f9a77400b622 | 557 | logDebug("Ack requested"); |
Mike Fiore |
14:f9a77400b622 | 558 | goto L_SEND; |
Mike Fiore |
14:f9a77400b622 | 559 | } |
Mike Fiore |
14:f9a77400b622 | 560 | } |
Mike Fiore |
9:ff62b20f7000 | 561 | } |
Mike Fiore |
1:e52ae6584f1c | 562 | } else { |
Mike Fiore |
6:e27eaad36a0c | 563 | logDebug("Radio is busy, cannot send.\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 564 | osDelay(10); |
Mike Fiore |
1:e52ae6584f1c | 565 | } |
Mike Fiore |
1:e52ae6584f1c | 566 | |
Mike Fiore |
1:e52ae6584f1c | 567 | } else { |
Mike Fiore |
6:e27eaad36a0c | 568 | logDebug("No data received from serial to send.\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 569 | } |
Mike Fiore |
9:ff62b20f7000 | 570 | } |
Mike Fiore |
9:ff62b20f7000 | 571 | |
Mike Fiore |
14:f9a77400b622 | 572 | if (!_serialp->readable() && _dot->getStartUpMode() == mDot::SERIAL_MODE && !_serialp->escaped()) { |
Mike Fiore |
14:f9a77400b622 | 573 | sleep(true); |
Mike Fiore |
1:e52ae6584f1c | 574 | } |
Mike Fiore |
9:ff62b20f7000 | 575 | |
Mike Fiore |
14:f9a77400b622 | 576 | if (_serialp->escaped()) { |
Mike Fiore |
14:f9a77400b622 | 577 | _serialp->clearEscaped(); |
Mike Fiore |
14:f9a77400b622 | 578 | _serialp->rxClear(); |
Mike Fiore |
9:ff62b20f7000 | 579 | serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 580 | _mode = mDot::COMMAND_MODE; |
Mike Fiore |
9:ff62b20f7000 | 581 | logDebug("Exit Serial Mode"); |
Mike Fiore |
9:ff62b20f7000 | 582 | write(done); |
Mike Fiore |
9:ff62b20f7000 | 583 | return; |
Mike Fiore |
9:ff62b20f7000 | 584 | } |
Mike Fiore |
9:ff62b20f7000 | 585 | |
Mike Fiore |
9:ff62b20f7000 | 586 | if (!_dot->getNetworkJoinStatus()) { |
Mike Fiore |
9:ff62b20f7000 | 587 | serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 588 | _mode = mDot::COMMAND_MODE; |
Mike Fiore |
9:ff62b20f7000 | 589 | logDebug("Exit Serial Mode"); |
Mike Fiore |
9:ff62b20f7000 | 590 | write(no_carrier); |
Mike Fiore |
9:ff62b20f7000 | 591 | return; |
Mike Fiore |
9:ff62b20f7000 | 592 | } |
Mike Fiore |
1:e52ae6584f1c | 593 | } |
Mike Fiore |
1:e52ae6584f1c | 594 | |
Mike Fiore |
1:e52ae6584f1c | 595 | bool CommandTerminal::autoJoinCheck() { |
Mike Fiore |
1:e52ae6584f1c | 596 | |
Mike Fiore |
1:e52ae6584f1c | 597 | std::string escape_buffer; |
Mike Fiore |
1:e52ae6584f1c | 598 | int sleep = 1000; |
Mike Fiore |
1:e52ae6584f1c | 599 | Timer tmr; |
Mike Fiore |
9:ff62b20f7000 | 600 | tmr.start(); |
Mike Fiore |
1:e52ae6584f1c | 601 | int cnt = 0; |
Mike Fiore |
1:e52ae6584f1c | 602 | |
Mike Fiore |
1:e52ae6584f1c | 603 | while (!_dot->getNetworkJoinStatus()) { |
Mike Fiore |
14:f9a77400b622 | 604 | if (!serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 605 | write("\r\nJoining network... "); |
Mike Fiore |
14:f9a77400b622 | 606 | } |
Mike Fiore |
14:f9a77400b622 | 607 | logInfo("Joining network... "); |
Mike Fiore |
1:e52ae6584f1c | 608 | |
Mike Fiore |
9:ff62b20f7000 | 609 | if (_dot->getNextTxMs() > 0) { |
Mike Fiore |
14:f9a77400b622 | 610 | if (!serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 611 | writef("\r\nWaiting %lu s before next join attempt\r\n", _dot->getNextTxMs() / 1000); |
Mike Fiore |
14:f9a77400b622 | 612 | } |
Mike Fiore |
14:f9a77400b622 | 613 | logInfo("Waiting %lu s before next join attempt", _dot->getNextTxMs() / 1000); |
Mike Fiore |
9:ff62b20f7000 | 614 | |
Mike Fiore |
9:ff62b20f7000 | 615 | tmr.reset(); |
Mike Fiore |
9:ff62b20f7000 | 616 | while (_dot->getNextTxMs() > 0 && !_serial.escaped()) { |
Mike Fiore |
14:f9a77400b622 | 617 | osDelay(20); |
Mike Fiore |
1:e52ae6584f1c | 618 | } |
Mike Fiore |
1:e52ae6584f1c | 619 | } |
Mike Fiore |
1:e52ae6584f1c | 620 | |
Mike Fiore |
9:ff62b20f7000 | 621 | if (!_serial.escaped() && _dot->joinNetworkOnce() == mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 622 | if (!serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 623 | write("Network Joined\r\n"); |
Mike Fiore |
14:f9a77400b622 | 624 | write(done); |
Mike Fiore |
14:f9a77400b622 | 625 | } |
Mike Fiore |
14:f9a77400b622 | 626 | logInfo("Network Joined"); |
Mike Fiore |
1:e52ae6584f1c | 627 | return false; |
Mike Fiore |
1:e52ae6584f1c | 628 | } |
Mike Fiore |
1:e52ae6584f1c | 629 | |
Mike Fiore |
14:f9a77400b622 | 630 | if (!serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 631 | write("Network Join failed\r\n"); |
Mike Fiore |
14:f9a77400b622 | 632 | write(error); |
Mike Fiore |
14:f9a77400b622 | 633 | } |
Mike Fiore |
14:f9a77400b622 | 634 | logInfo("Network Join failed"); |
Mike Fiore |
1:e52ae6584f1c | 635 | |
Mike Fiore |
14:f9a77400b622 | 636 | if (!_serial.escaped() && _dot->getFrequencySubBand() != 0 && _dot->getJoinRetries() > 0 && cnt++ > _dot->getJoinRetries()) { |
Mike Fiore |
1:e52ae6584f1c | 637 | cnt = 0; |
Mike Fiore |
1:e52ae6584f1c | 638 | |
Mike Fiore |
14:f9a77400b622 | 639 | if (_dot->getFrequencyBand() == mDot::FB_US915 || _dot->getFrequencyBand() == mDot::FB_AU915 ) { |
Mike Fiore |
1:e52ae6584f1c | 640 | uint8_t band = ((_dot->getFrequencySubBand()) % 8) + 1; |
Mike Fiore |
9:ff62b20f7000 | 641 | logWarning("Join retries exhausted, switching to sub band %u", band); |
Mike Fiore |
1:e52ae6584f1c | 642 | _dot->setFrequencySubBand(band); |
Mike Fiore |
1:e52ae6584f1c | 643 | } |
Mike Fiore |
1:e52ae6584f1c | 644 | } |
Mike Fiore |
1:e52ae6584f1c | 645 | |
Mike Fiore |
1:e52ae6584f1c | 646 | tmr.reset(); |
Mike Fiore |
9:ff62b20f7000 | 647 | while (tmr.read_ms() < sleep && !_serial.escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 648 | osDelay(10); |
Mike Fiore |
1:e52ae6584f1c | 649 | } |
Mike Fiore |
1:e52ae6584f1c | 650 | |
Mike Fiore |
9:ff62b20f7000 | 651 | if (_serial.escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 652 | _serial.clearEscaped(); |
Mike Fiore |
9:ff62b20f7000 | 653 | serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 654 | _mode = mDot::COMMAND_MODE; |
Mike Fiore |
14:f9a77400b622 | 655 | if (!serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 656 | write("Join Canceled\r\n"); |
Mike Fiore |
14:f9a77400b622 | 657 | write(done); |
Mike Fiore |
14:f9a77400b622 | 658 | } |
Mike Fiore |
14:f9a77400b622 | 659 | logInfo("Join Canceled\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 660 | return true; |
Mike Fiore |
9:ff62b20f7000 | 661 | } |
Mike Fiore |
1:e52ae6584f1c | 662 | } |
Mike Fiore |
1:e52ae6584f1c | 663 | |
Mike Fiore |
1:e52ae6584f1c | 664 | return false; |
Mike Fiore |
1:e52ae6584f1c | 665 | } |
Mike Fiore |
1:e52ae6584f1c | 666 | |
Mike Fiore |
1:e52ae6584f1c | 667 | void CommandTerminal::start() { |
Mike Fiore |
1:e52ae6584f1c | 668 | |
Mike Fiore |
1:e52ae6584f1c | 669 | char ch; |
Mike Fiore |
1:e52ae6584f1c | 670 | bool running = true; |
Mike Fiore |
1:e52ae6584f1c | 671 | bool echo = _dot->getEcho(); |
Mike Fiore |
1:e52ae6584f1c | 672 | std::string command; |
Mike Fiore |
14:f9a77400b622 | 673 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
4:666017851052 | 674 | std::deque<std::string> history; |
Mike Fiore |
4:666017851052 | 675 | int history_index = -1; |
Mike Fiore |
14:f9a77400b622 | 676 | #endif |
Mike Fiore |
1:e52ae6584f1c | 677 | std::vector<std::string> args; |
Mike Fiore |
9:ff62b20f7000 | 678 | bool join_canceled = false; |
Mike Fiore |
1:e52ae6584f1c | 679 | |
Mike Fiore |
14:f9a77400b622 | 680 | _autoOTAEnabled = _dot->getJoinMode() == mDot::AUTO_OTA; |
Mike Fiore |
14:f9a77400b622 | 681 | |
Mike Fiore |
1:e52ae6584f1c | 682 | if (_dot->getStartUpMode() == mDot::SERIAL_MODE) { |
Mike Fiore |
9:ff62b20f7000 | 683 | |
Mike Fiore |
9:ff62b20f7000 | 684 | serial_data_mode = true; |
Mike Fiore |
9:ff62b20f7000 | 685 | _mode = mDot::SERIAL_MODE; |
Mike Fiore |
1:e52ae6584f1c | 686 | |
Mike Fiore |
1:e52ae6584f1c | 687 | std::string escape_buffer; |
Mike Fiore |
1:e52ae6584f1c | 688 | char ch; |
Mike Fiore |
1:e52ae6584f1c | 689 | |
Mike Fiore |
9:ff62b20f7000 | 690 | if (!_dot->getStandbyFlag()) { |
Mike Fiore |
9:ff62b20f7000 | 691 | // wake up from power-on/reset |
Mike Fiore |
9:ff62b20f7000 | 692 | |
Mike Fiore |
9:ff62b20f7000 | 693 | int escape_timeout = 1000; |
Mike Fiore |
9:ff62b20f7000 | 694 | Timer tmr; |
Mike Fiore |
9:ff62b20f7000 | 695 | Timer escape_tmr; |
Mike Fiore |
1:e52ae6584f1c | 696 | |
Mike Fiore |
9:ff62b20f7000 | 697 | // wait one second for possible escape by user pressing '+' key |
Mike Fiore |
9:ff62b20f7000 | 698 | tmr.reset(); |
Mike Fiore |
9:ff62b20f7000 | 699 | tmr.start(); |
Mike Fiore |
9:ff62b20f7000 | 700 | escape_tmr.reset(); |
Mike Fiore |
9:ff62b20f7000 | 701 | escape_tmr.start(); |
Mike Fiore |
9:ff62b20f7000 | 702 | while (tmr.read_ms() < escape_timeout) { |
Mike Fiore |
9:ff62b20f7000 | 703 | if (_serial.readable()) { |
Mike Fiore |
9:ff62b20f7000 | 704 | _serial.read(&ch, 1); |
Mike Fiore |
9:ff62b20f7000 | 705 | escape_buffer += ch; |
Mike Fiore |
9:ff62b20f7000 | 706 | } |
Mike Fiore |
1:e52ae6584f1c | 707 | |
Mike Fiore |
9:ff62b20f7000 | 708 | if (escape_buffer.find("+") != std::string::npos) { |
Mike Fiore |
9:ff62b20f7000 | 709 | logInfo("Escape detected"); |
Mike Fiore |
9:ff62b20f7000 | 710 | join_canceled = true; |
Mike Fiore |
9:ff62b20f7000 | 711 | serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 712 | _mode = mDot::COMMAND_MODE; |
Mike Fiore |
9:ff62b20f7000 | 713 | command.clear(); |
Mike Fiore |
9:ff62b20f7000 | 714 | break; |
Mike Fiore |
9:ff62b20f7000 | 715 | } |
Mike Fiore |
9:ff62b20f7000 | 716 | |
Mike Fiore |
9:ff62b20f7000 | 717 | if (escape_tmr.read_ms() > escape_timeout) |
Mike Fiore |
9:ff62b20f7000 | 718 | escape_buffer.clear(); |
Mike Fiore |
9:ff62b20f7000 | 719 | |
Mike Fiore |
9:ff62b20f7000 | 720 | osDelay(1); |
Mike Fiore |
1:e52ae6584f1c | 721 | } |
Mike Fiore |
1:e52ae6584f1c | 722 | } |
Mike Fiore |
1:e52ae6584f1c | 723 | |
Mike Fiore |
9:ff62b20f7000 | 724 | if (_mode == mDot::SERIAL_MODE && !_dot->getNetworkJoinStatus() && _dot->getJoinMode() == mDot::OTA) { |
Mike Fiore |
9:ff62b20f7000 | 725 | if (_dot->joinNetworkOnce() != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 726 | serial_data_mode = false; |
Mike Fiore |
9:ff62b20f7000 | 727 | _mode = mDot::COMMAND_MODE; |
Mike Fiore |
9:ff62b20f7000 | 728 | |
Mike Fiore |
9:ff62b20f7000 | 729 | logWarning("Start Up Mode set to SERIAL_MODE, but join failed."); |
Mike Fiore |
9:ff62b20f7000 | 730 | _serial.writef("Network Not Joined\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 731 | _serial.writef(error); |
Mike Fiore |
9:ff62b20f7000 | 732 | } |
Mike Fiore |
9:ff62b20f7000 | 733 | } |
Mike Fiore |
1:e52ae6584f1c | 734 | } |
Mike Fiore |
1:e52ae6584f1c | 735 | |
Mike Fiore |
9:ff62b20f7000 | 736 | if (_dot->getJoinMode() == mDot::PEER_TO_PEER) { |
Mike Fiore |
9:ff62b20f7000 | 737 | peer_to_peer = true; |
Mike Fiore |
9:ff62b20f7000 | 738 | } else { |
Mike Fiore |
9:ff62b20f7000 | 739 | peer_to_peer = false; |
Mike Fiore |
9:ff62b20f7000 | 740 | } |
Mike Fiore |
9:ff62b20f7000 | 741 | |
Mike Fiore |
1:e52ae6584f1c | 742 | //Run terminal session |
Mike Fiore |
1:e52ae6584f1c | 743 | while (running) { |
Mike Fiore |
9:ff62b20f7000 | 744 | |
Mike Fiore |
9:ff62b20f7000 | 745 | // wait for input to reduce at command idle current |
Mike Fiore |
9:ff62b20f7000 | 746 | while (!readable() || _mode == mDot::SERIAL_MODE) { |
Mike Fiore |
14:f9a77400b622 | 747 | if (!join_canceled && _autoOTAEnabled) { |
Mike Fiore |
9:ff62b20f7000 | 748 | join_canceled = autoJoinCheck(); |
Mike Fiore |
9:ff62b20f7000 | 749 | if (join_canceled) |
Mike Fiore |
9:ff62b20f7000 | 750 | command.clear(); |
Mike Fiore |
9:ff62b20f7000 | 751 | } |
Mike Fiore |
1:e52ae6584f1c | 752 | |
Mike Fiore |
14:f9a77400b622 | 753 | if (!_autoOTAEnabled || (!join_canceled && _autoOTAEnabled)) { |
Mike Fiore |
9:ff62b20f7000 | 754 | switch (_mode) { |
Mike Fiore |
9:ff62b20f7000 | 755 | case mDot::SERIAL_MODE: |
Mike Fiore |
9:ff62b20f7000 | 756 | // signal wakeup, read serial and output to radio |
Mike Fiore |
9:ff62b20f7000 | 757 | serialLoop(); |
Mike Fiore |
9:ff62b20f7000 | 758 | continue; |
Mike Fiore |
9:ff62b20f7000 | 759 | break; |
Mike Fiore |
9:ff62b20f7000 | 760 | default: |
Mike Fiore |
9:ff62b20f7000 | 761 | break; |
Mike Fiore |
9:ff62b20f7000 | 762 | } |
Mike Fiore |
1:e52ae6584f1c | 763 | } |
Mike Fiore |
9:ff62b20f7000 | 764 | |
Mike Fiore |
9:ff62b20f7000 | 765 | ch = '\0'; |
Mike Fiore |
1:e52ae6584f1c | 766 | |
Mike Fiore |
9:ff62b20f7000 | 767 | wait(0.00001); // 10 us |
Mike Fiore |
9:ff62b20f7000 | 768 | _serial.escaped(); |
Mike Fiore |
9:ff62b20f7000 | 769 | } |
Mike Fiore |
1:e52ae6584f1c | 770 | |
Mike Fiore |
1:e52ae6584f1c | 771 | // read characters |
Mike Fiore |
1:e52ae6584f1c | 772 | if (readable()) { |
Mike Fiore |
1:e52ae6584f1c | 773 | ch = read(); |
Mike Fiore |
1:e52ae6584f1c | 774 | |
Mike Fiore |
4:666017851052 | 775 | if (ch == '\b' || ch == 0x7f) { |
Mike Fiore |
1:e52ae6584f1c | 776 | if (!command.empty()) { |
Mike Fiore |
1:e52ae6584f1c | 777 | writef("\b \b"); |
Mike Fiore |
1:e52ae6584f1c | 778 | command.erase(command.size() - 1); |
Mike Fiore |
1:e52ae6584f1c | 779 | } |
Mike Fiore |
1:e52ae6584f1c | 780 | continue; |
Mike Fiore |
4:666017851052 | 781 | } else if (ch == 0x1b || ch == 0x09) { |
Mike Fiore |
4:666017851052 | 782 | osDelay(20); |
Mike Fiore |
4:666017851052 | 783 | // catch escape sequence, or tab |
Mike Fiore |
9:ff62b20f7000 | 784 | char ch1 = 0x00, ch2 = 0x00; |
Mike Fiore |
4:666017851052 | 785 | |
Mike Fiore |
4:666017851052 | 786 | if (readable()) { |
Mike Fiore |
4:666017851052 | 787 | ch1 = read(); |
Mike Fiore |
4:666017851052 | 788 | if (readable()) |
Mike Fiore |
4:666017851052 | 789 | ch2 = read(); |
Mike Fiore |
4:666017851052 | 790 | |
Mike Fiore |
14:f9a77400b622 | 791 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
4:666017851052 | 792 | if (ch1 == 0x5b && ch2 == 0x41) { |
Mike Fiore |
4:666017851052 | 793 | // up key |
Mike Fiore |
9:ff62b20f7000 | 794 | for (size_t i = 0; i < command.size() + 1; i++) { |
Mike Fiore |
4:666017851052 | 795 | writef("\b \b"); |
Mike Fiore |
4:666017851052 | 796 | } |
Mike Fiore |
4:666017851052 | 797 | if (history.size() > 0) { |
Mike Fiore |
9:ff62b20f7000 | 798 | if (++history_index >= int(history.size() - 1)) |
Mike Fiore |
4:666017851052 | 799 | history_index = history.size() - 1; |
Mike Fiore |
4:666017851052 | 800 | |
Mike Fiore |
4:666017851052 | 801 | command = history[history_index]; |
Mike Fiore |
4:666017851052 | 802 | writef("%s", history[history_index].c_str()); |
Mike Fiore |
4:666017851052 | 803 | } else { |
Mike Fiore |
4:666017851052 | 804 | command.clear(); |
Mike Fiore |
4:666017851052 | 805 | } |
Mike Fiore |
4:666017851052 | 806 | } else if (ch1 == 0x5b && ch2 == 0x42) { |
Mike Fiore |
4:666017851052 | 807 | |
Mike Fiore |
4:666017851052 | 808 | // down key |
Mike Fiore |
9:ff62b20f7000 | 809 | for (size_t i = 0; i < command.size() + 1; i++) { |
Mike Fiore |
4:666017851052 | 810 | writef("\b \b"); |
Mike Fiore |
4:666017851052 | 811 | } |
Mike Fiore |
4:666017851052 | 812 | |
Mike Fiore |
4:666017851052 | 813 | if (--history_index < 0) { |
Mike Fiore |
4:666017851052 | 814 | history_index = -1; |
Mike Fiore |
4:666017851052 | 815 | command.clear(); |
Mike Fiore |
4:666017851052 | 816 | } else { |
Mike Fiore |
4:666017851052 | 817 | command = history[history_index]; |
Mike Fiore |
4:666017851052 | 818 | writef("%s", history[history_index].c_str()); |
Mike Fiore |
4:666017851052 | 819 | } |
Mike Fiore |
4:666017851052 | 820 | } |
Mike Fiore |
14:f9a77400b622 | 821 | #endif |
Mike Fiore |
4:666017851052 | 822 | } |
Mike Fiore |
9:ff62b20f7000 | 823 | while (readable()) |
Mike Fiore |
9:ff62b20f7000 | 824 | read(); |
Mike Fiore |
4:666017851052 | 825 | continue; |
Mike Fiore |
1:e52ae6584f1c | 826 | } else { |
Mike Fiore |
1:e52ae6584f1c | 827 | command += ch; |
Mike Fiore |
1:e52ae6584f1c | 828 | } |
Mike Fiore |
1:e52ae6584f1c | 829 | |
Mike Fiore |
1:e52ae6584f1c | 830 | // echo chars if enabled |
Mike Fiore |
1:e52ae6584f1c | 831 | if (echo && !(ch == '\r' || ch == '\n')) |
Mike Fiore |
1:e52ae6584f1c | 832 | writef("%c", ch); |
Mike Fiore |
1:e52ae6584f1c | 833 | } |
Mike Fiore |
1:e52ae6584f1c | 834 | |
Mike Fiore |
1:e52ae6584f1c | 835 | // look for end of command line |
Mike Fiore |
1:e52ae6584f1c | 836 | if (command.find("\n") != std::string::npos || command.find("\r") != std::string::npos) { |
Mike Fiore |
1:e52ae6584f1c | 837 | // remove new line or cr character |
Mike Fiore |
1:e52ae6584f1c | 838 | command.erase(command.size() - 1); |
Mike Fiore |
1:e52ae6584f1c | 839 | write("\r"); // match standard modem output |
Mike Fiore |
1:e52ae6584f1c | 840 | write(newline); |
Mike Fiore |
1:e52ae6584f1c | 841 | } else { |
Mike Fiore |
1:e52ae6584f1c | 842 | continue; |
Mike Fiore |
1:e52ae6584f1c | 843 | } |
Mike Fiore |
1:e52ae6584f1c | 844 | |
Mike Fiore |
1:e52ae6584f1c | 845 | // trim whitespace from command |
Mike Fiore |
1:e52ae6584f1c | 846 | mts::Text::trim(command, "\r\n\t "); |
Mike Fiore |
1:e52ae6584f1c | 847 | |
Mike Fiore |
1:e52ae6584f1c | 848 | if (command.size() < 1) { |
Mike Fiore |
1:e52ae6584f1c | 849 | command.clear(); |
Mike Fiore |
1:e52ae6584f1c | 850 | continue; |
Mike Fiore |
1:e52ae6584f1c | 851 | } |
Mike Fiore |
1:e52ae6584f1c | 852 | |
Mike Fiore |
1:e52ae6584f1c | 853 | // parse command and args |
Mike Fiore |
1:e52ae6584f1c | 854 | args.clear(); |
Mike Fiore |
1:e52ae6584f1c | 855 | |
Mike Fiore |
1:e52ae6584f1c | 856 | // find first '=' character |
Mike Fiore |
1:e52ae6584f1c | 857 | size_t delim_index = command.find("="); |
Mike Fiore |
1:e52ae6584f1c | 858 | if (delim_index != std::string::npos) { |
Mike Fiore |
1:e52ae6584f1c | 859 | args.push_back(command.substr(0, delim_index)); |
Mike Fiore |
1:e52ae6584f1c | 860 | } else { |
Mike Fiore |
1:e52ae6584f1c | 861 | // find first ' ' character |
Mike Fiore |
1:e52ae6584f1c | 862 | delim_index = command.find(" "); |
Mike Fiore |
1:e52ae6584f1c | 863 | if (delim_index != std::string::npos) { |
Mike Fiore |
1:e52ae6584f1c | 864 | args.push_back(command.substr(0, delim_index)); |
Mike Fiore |
1:e52ae6584f1c | 865 | } else { |
Mike Fiore |
1:e52ae6584f1c | 866 | args.push_back(command); |
Mike Fiore |
1:e52ae6584f1c | 867 | } |
Mike Fiore |
1:e52ae6584f1c | 868 | } |
Mike Fiore |
1:e52ae6584f1c | 869 | |
Mike Fiore |
1:e52ae6584f1c | 870 | if (delim_index != std::string::npos) { |
Mike Fiore |
1:e52ae6584f1c | 871 | std::vector<std::string> params = mts::Text::split(command.substr(delim_index + 1), ","); |
Mike Fiore |
1:e52ae6584f1c | 872 | args.insert(args.end(), params.begin(), params.end()); |
Mike Fiore |
1:e52ae6584f1c | 873 | } |
Mike Fiore |
1:e52ae6584f1c | 874 | |
Mike Fiore |
1:e52ae6584f1c | 875 | args[0] = mts::Text::toUpper(args[0]); |
Mike Fiore |
1:e52ae6584f1c | 876 | |
Mike Fiore |
1:e52ae6584f1c | 877 | // print help |
Mike Fiore |
1:e52ae6584f1c | 878 | if ((args[0].find("?") == 0 || args[0].find("HELP") == 0) && args.size() == 1) { |
Mike Fiore |
1:e52ae6584f1c | 879 | printHelp(); |
Mike Fiore |
1:e52ae6584f1c | 880 | command.clear(); |
Mike Fiore |
9:ff62b20f7000 | 881 | } else if ((args[0].find("ATE?") == 0 && args[0].length() == 4) || (args[0].find("ATE") == 0 && args[0].length() == 3)) { |
Mike Fiore |
9:ff62b20f7000 | 882 | writef("%d\r\n", _dot->getEcho()); |
Mike Fiore |
9:ff62b20f7000 | 883 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 884 | } else if (args[0].find("ATE0") == 0 && args[0].length() == 4) { |
Mike Fiore |
1:e52ae6584f1c | 885 | _dot->setEcho(false); |
Mike Fiore |
1:e52ae6584f1c | 886 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 887 | echo = _dot->getEcho(); |
Mike Fiore |
1:e52ae6584f1c | 888 | } else if (args[0].find("ATE1") == 0 && args[0].length() == 4) { |
Mike Fiore |
1:e52ae6584f1c | 889 | _dot->setEcho(true); |
Mike Fiore |
1:e52ae6584f1c | 890 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 891 | echo = _dot->getEcho(); |
Mike Fiore |
9:ff62b20f7000 | 892 | } else if ((args[0].find("ATV?") == 0 && args[0].length() == 4) || (args[0].find("ATV") == 0 && args[0].length() == 3)) { |
Mike Fiore |
9:ff62b20f7000 | 893 | writef("%d\r\n", _dot->getVerbose()); |
Mike Fiore |
9:ff62b20f7000 | 894 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 895 | } else if (args[0].find("ATV0") == 0 && args[0].length() == 4) { |
Mike Fiore |
1:e52ae6584f1c | 896 | _dot->setVerbose(false); |
Mike Fiore |
1:e52ae6584f1c | 897 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 898 | } else if (args[0].find("ATV1") == 0 && args[0].length() == 4) { |
Mike Fiore |
1:e52ae6584f1c | 899 | _dot->setVerbose(true); |
Mike Fiore |
1:e52ae6584f1c | 900 | write(done); |
Mike Fiore |
9:ff62b20f7000 | 901 | } else if ((args[0].find("AT&K?") == 0 && args[0].length() == 5) || (args[0].find("AT&K") == 0 && args[0].length() == 4)) { |
Mike Fiore |
9:ff62b20f7000 | 902 | writef("%d\r\n", (_dot->getFlowControl() ? 3 : 0)); |
Mike Fiore |
9:ff62b20f7000 | 903 | write(done); |
Mike Fiore |
9:ff62b20f7000 | 904 | } else if (args[0].find("AT&K0") == 0 && args[0].length() == 5) { |
Mike Fiore |
9:ff62b20f7000 | 905 | _dot->setFlowControl(false); |
Mike Fiore |
9:ff62b20f7000 | 906 | write(done); |
Mike Fiore |
9:ff62b20f7000 | 907 | } else if (args[0].find("AT&K3") == 0 && args[0].length() == 5) { |
Mike Fiore |
9:ff62b20f7000 | 908 | _dot->setFlowControl(true); |
Mike Fiore |
9:ff62b20f7000 | 909 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 910 | } else if (args[0] == "AT+SD") { |
Mike Fiore |
9:ff62b20f7000 | 911 | if (_dot->getNetworkJoinStatus()) { |
Mike Fiore |
9:ff62b20f7000 | 912 | logDebug("Enter Serial Mode"); |
Mike Fiore |
9:ff62b20f7000 | 913 | write(connect); |
Mike Fiore |
9:ff62b20f7000 | 914 | serial_data_mode = true; |
Mike Fiore |
9:ff62b20f7000 | 915 | _mode = mDot::SERIAL_MODE; |
Mike Fiore |
9:ff62b20f7000 | 916 | } else { |
Mike Fiore |
9:ff62b20f7000 | 917 | logDebug("Network Not Joined"); |
Mike Fiore |
9:ff62b20f7000 | 918 | write("Network Not Joined\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 919 | write(error); |
Mike Fiore |
9:ff62b20f7000 | 920 | } |
Mike Fiore |
4:666017851052 | 921 | } else if (args[0] == "AT+SLEEP") { |
Mike Fiore |
9:ff62b20f7000 | 922 | if (args.size() > 2 && (args[1] != "?")) { |
Mike Fiore |
4:666017851052 | 923 | write("Invalid argument\r\n"); |
Mike Fiore |
4:666017851052 | 924 | write(error); |
Mike Fiore |
4:666017851052 | 925 | } else { |
Mike Fiore |
4:666017851052 | 926 | if (args.size() > 1 && args[1] == "?") { |
Mike Fiore |
9:ff62b20f7000 | 927 | write("(0:deepsleep,1:sleep)\r\n"); |
Mike Fiore |
4:666017851052 | 928 | write(done); |
Mike Fiore |
4:666017851052 | 929 | } else { |
Mike Fiore |
4:666017851052 | 930 | _sleep_standby = !(args.size() > 1 && args[1] == "1"); |
Mike Fiore |
14:f9a77400b622 | 931 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
14:f9a77400b622 | 932 | //Read the board ID. If all 0's, it is revision B. This hardware does not support deep sleep. |
Mike Fiore |
14:f9a77400b622 | 933 | DigitalIn ID2(PC_4); |
Mike Fiore |
14:f9a77400b622 | 934 | DigitalIn ID1(PC_5); |
Mike Fiore |
14:f9a77400b622 | 935 | DigitalIn ID0(PD_2); |
Mike Fiore |
14:f9a77400b622 | 936 | if(ID2 == 0 && ID1 == 0 && ID0 == 0 && _sleep_standby == 1){ |
Mike Fiore |
14:f9a77400b622 | 937 | _sleep_standby = 0; |
Mike Fiore |
14:f9a77400b622 | 938 | logWarning("This hardware version does not support deep sleep. Using sleep mode instead."); |
Mike Fiore |
14:f9a77400b622 | 939 | } |
Mike Fiore |
14:f9a77400b622 | 940 | #endif |
Mike Fiore |
9:ff62b20f7000 | 941 | write(done); |
Mike Fiore |
14:f9a77400b622 | 942 | osDelay(5); |
Mike Fiore |
4:666017851052 | 943 | this->sleep(_sleep_standby); |
Mike Fiore |
14:f9a77400b622 | 944 | osDelay(1); |
Mike Fiore |
4:666017851052 | 945 | } |
Mike Fiore |
4:666017851052 | 946 | } |
Mike Fiore |
1:e52ae6584f1c | 947 | } else { |
Mike Fiore |
1:e52ae6584f1c | 948 | bool found = false; |
Mike Fiore |
1:e52ae6584f1c | 949 | bool query = false; |
Mike Fiore |
1:e52ae6584f1c | 950 | |
Mike Fiore |
1:e52ae6584f1c | 951 | std::string lookfor = args[0]; |
Mike Fiore |
1:e52ae6584f1c | 952 | |
Mike Fiore |
1:e52ae6584f1c | 953 | // per command help |
Mike Fiore |
1:e52ae6584f1c | 954 | if ((args[0].find("?") == 0 || args[0].find("HELP") == 0)) |
Mike Fiore |
1:e52ae6584f1c | 955 | lookfor = mts::Text::toUpper(args[1]); |
Mike Fiore |
1:e52ae6584f1c | 956 | |
Mike Fiore |
1:e52ae6584f1c | 957 | // trim off any trailing '?' and mark as a query command |
Mike Fiore |
1:e52ae6584f1c | 958 | if (args[0].rfind("?") == args[0].length() - 1) { |
Mike Fiore |
1:e52ae6584f1c | 959 | query = true; |
Mike Fiore |
1:e52ae6584f1c | 960 | lookfor = args[0].substr(0, args[0].length() - 1); |
Mike Fiore |
1:e52ae6584f1c | 961 | } |
Mike Fiore |
1:e52ae6584f1c | 962 | |
Mike Fiore |
1:e52ae6584f1c | 963 | // search for command |
Mike Fiore |
14:f9a77400b622 | 964 | for (int i = 0; i < NO_OF_COMMANDS; i++) { |
Mike Fiore |
1:e52ae6584f1c | 965 | |
Mike Fiore |
1:e52ae6584f1c | 966 | // match CMD or CMD? syntax if command is queryable |
Mike Fiore |
14:f9a77400b622 | 967 | if (lookfor == _commands[i].text() && (!query || (query && _commands[i].queryable()))) { |
Mike Fiore |
1:e52ae6584f1c | 968 | found = true; |
Mike Fiore |
1:e52ae6584f1c | 969 | if (args[0] == "HELP") { |
Mike Fiore |
14:f9a77400b622 | 970 | writef("%s%s", _commands[i].help().c_str(), newline); |
Mike Fiore |
1:e52ae6584f1c | 971 | write(done); |
Mike Fiore |
1:e52ae6584f1c | 972 | } |
Mike Fiore |
1:e52ae6584f1c | 973 | |
Mike Fiore |
1:e52ae6584f1c | 974 | else if (args.size() > 1 && args[1] == "?") { |
Mike Fiore |
14:f9a77400b622 | 975 | writef("%s%s", _commands[i].usage().c_str(), newline); |
Mike Fiore |
1:e52ae6584f1c | 976 | write(done); |
Mike Fiore |
14:f9a77400b622 | 977 | } else if (!_verify[i](args)) { |
Mike Fiore |
14:f9a77400b622 | 978 | writef("%s%s", _errorMessage.c_str(), newline); |
Mike Fiore |
1:e52ae6584f1c | 979 | writef("%s", error); |
Mike Fiore |
1:e52ae6584f1c | 980 | } else { |
Mike Fiore |
14:f9a77400b622 | 981 | if (_action[i](args) == 0) { |
Mike Fiore |
1:e52ae6584f1c | 982 | writef("%s", done); |
Mike Fiore |
1:e52ae6584f1c | 983 | } else { |
Mike Fiore |
14:f9a77400b622 | 984 | writef("%s%s", _errorMessage.c_str(), newline); |
Mike Fiore |
1:e52ae6584f1c | 985 | writef("%s", error); |
Mike Fiore |
1:e52ae6584f1c | 986 | } |
Mike Fiore |
1:e52ae6584f1c | 987 | } |
Mike Fiore |
1:e52ae6584f1c | 988 | } |
Mike Fiore |
1:e52ae6584f1c | 989 | } |
Mike Fiore |
1:e52ae6584f1c | 990 | |
Mike Fiore |
1:e52ae6584f1c | 991 | if (!found) { |
Mike Fiore |
1:e52ae6584f1c | 992 | writef("%s", command_error); |
Mike Fiore |
1:e52ae6584f1c | 993 | writef("%s", error); |
Mike Fiore |
1:e52ae6584f1c | 994 | } |
Mike Fiore |
1:e52ae6584f1c | 995 | } |
Mike Fiore |
1:e52ae6584f1c | 996 | |
Mike Fiore |
14:f9a77400b622 | 997 | #if defined(TARGET_MTS_MDOT_F411RE) |
Mike Fiore |
4:666017851052 | 998 | if (history.size() == 0 || history.front() != command) |
Mike Fiore |
4:666017851052 | 999 | history.push_front(command); |
Mike Fiore |
4:666017851052 | 1000 | history_index = -1; |
Mike Fiore |
1:e52ae6584f1c | 1001 | command.clear(); |
Mike Fiore |
1:e52ae6584f1c | 1002 | |
Mike Fiore |
4:666017851052 | 1003 | while (history.size() > 10) |
Mike Fiore |
4:666017851052 | 1004 | history.pop_back(); |
Mike Fiore |
14:f9a77400b622 | 1005 | #else |
Mike Fiore |
14:f9a77400b622 | 1006 | command.clear(); |
Mike Fiore |
14:f9a77400b622 | 1007 | #endif |
Mike Fiore |
1:e52ae6584f1c | 1008 | } |
Mike Fiore |
1:e52ae6584f1c | 1009 | } |
Mike Fiore |
1:e52ae6584f1c | 1010 | |
Mike Fiore |
1:e52ae6584f1c | 1011 | void CommandTerminal::sleep(bool standby) { |
Mike Fiore |
1:e52ae6584f1c | 1012 | _xbee_on_sleep = GPIO_PIN_RESET; |
Mike Fiore |
1:e52ae6584f1c | 1013 | |
Mike Fiore |
4:666017851052 | 1014 | _serial.rxClear(); |
Mike Fiore |
4:666017851052 | 1015 | _serial.txClear(); |
Mike Fiore |
1:e52ae6584f1c | 1016 | |
Mike Fiore |
14:f9a77400b622 | 1017 | #if defined(TARGET_XDOT_L151CC) |
Mike Fiore |
14:f9a77400b622 | 1018 | xdot_save_gpio_state(); |
Mike Fiore |
14:f9a77400b622 | 1019 | |
Mike Fiore |
14:f9a77400b622 | 1020 | /* GPIO Ports Clock Enable */ |
Mike Fiore |
14:f9a77400b622 | 1021 | __GPIOA_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1022 | __GPIOB_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1023 | __GPIOC_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1024 | __GPIOH_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1025 | |
Mike Fiore |
14:f9a77400b622 | 1026 | GPIO_InitTypeDef GPIO_InitStruct; |
Mike Fiore |
14:f9a77400b622 | 1027 | |
Mike Fiore |
14:f9a77400b622 | 1028 | // UART1_TX, UART1_RTS & UART1_CTS to analog nopull - RX could be a wakeup source |
Mike Fiore |
14:f9a77400b622 | 1029 | GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_11 | GPIO_PIN_12; |
Mike Fiore |
14:f9a77400b622 | 1030 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1031 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1032 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1033 | |
Mike Fiore |
14:f9a77400b622 | 1034 | // I2C_SDA & I2C_SCL to analog nopull |
Mike Fiore |
14:f9a77400b622 | 1035 | GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9; |
Mike Fiore |
14:f9a77400b622 | 1036 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1037 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1038 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1039 | |
Mike Fiore |
14:f9a77400b622 | 1040 | // SPI_MOSI, SPI_MISO, SPI_SCK, & SPI_NSS to analog nopull |
Mike Fiore |
14:f9a77400b622 | 1041 | GPIO_InitStruct.Pin = GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
Mike Fiore |
14:f9a77400b622 | 1042 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1043 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1044 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1045 | |
Mike Fiore |
14:f9a77400b622 | 1046 | // iterate through potential wake pins - leave the configured wake pin alone if one is needed |
Mike Fiore |
14:f9a77400b622 | 1047 | if (_dot->getWakePin() != WAKE || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1048 | GPIO_InitStruct.Pin = GPIO_PIN_0; |
Mike Fiore |
14:f9a77400b622 | 1049 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1050 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1051 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1052 | } |
Mike Fiore |
14:f9a77400b622 | 1053 | if (_dot->getWakePin() != GPIO0 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1054 | GPIO_InitStruct.Pin = GPIO_PIN_4; |
Mike Fiore |
14:f9a77400b622 | 1055 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1056 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1057 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1058 | } |
Mike Fiore |
14:f9a77400b622 | 1059 | if (_dot->getWakePin() != GPIO1 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1060 | GPIO_InitStruct.Pin = GPIO_PIN_5; |
Mike Fiore |
14:f9a77400b622 | 1061 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1062 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1063 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1064 | } |
Mike Fiore |
14:f9a77400b622 | 1065 | if (_dot->getWakePin() != GPIO2 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1066 | GPIO_InitStruct.Pin = GPIO_PIN_0; |
Mike Fiore |
14:f9a77400b622 | 1067 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1068 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1069 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1070 | } |
Mike Fiore |
14:f9a77400b622 | 1071 | if (_dot->getWakePin() != GPIO3 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1072 | GPIO_InitStruct.Pin = GPIO_PIN_2; |
Mike Fiore |
14:f9a77400b622 | 1073 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1074 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1075 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1076 | } |
Mike Fiore |
14:f9a77400b622 | 1077 | if (_dot->getWakePin() != UART1_RX || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1078 | GPIO_InitStruct.Pin = GPIO_PIN_10; |
Mike Fiore |
14:f9a77400b622 | 1079 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1080 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1081 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1082 | } |
Mike Fiore |
14:f9a77400b622 | 1083 | #else |
Mike Fiore |
14:f9a77400b622 | 1084 | uint32_t portA[6]; |
Mike Fiore |
14:f9a77400b622 | 1085 | uint32_t portB[6]; |
Mike Fiore |
14:f9a77400b622 | 1086 | uint32_t portC[6]; |
Mike Fiore |
14:f9a77400b622 | 1087 | uint32_t portD[6]; |
Mike Fiore |
14:f9a77400b622 | 1088 | uint32_t portH[6]; |
Mike Fiore |
14:f9a77400b622 | 1089 | |
Mike Fiore |
14:f9a77400b622 | 1090 | //Save the GPIO state. |
Mike Fiore |
14:f9a77400b622 | 1091 | portA[0] = GPIOA->MODER; |
Mike Fiore |
14:f9a77400b622 | 1092 | portA[1] = GPIOA->OTYPER; |
Mike Fiore |
14:f9a77400b622 | 1093 | portA[2] = GPIOA->OSPEEDR; |
Mike Fiore |
14:f9a77400b622 | 1094 | portA[3] = GPIOA->PUPDR; |
Mike Fiore |
14:f9a77400b622 | 1095 | portA[4] = GPIOA->AFR[0]; |
Mike Fiore |
14:f9a77400b622 | 1096 | portA[5] = GPIOA->AFR[1]; |
Mike Fiore |
14:f9a77400b622 | 1097 | |
Mike Fiore |
14:f9a77400b622 | 1098 | portB[0] = GPIOB->MODER; |
Mike Fiore |
14:f9a77400b622 | 1099 | portB[1] = GPIOB->OTYPER; |
Mike Fiore |
14:f9a77400b622 | 1100 | portB[2] = GPIOB->OSPEEDR; |
Mike Fiore |
14:f9a77400b622 | 1101 | portB[3] = GPIOB->PUPDR; |
Mike Fiore |
14:f9a77400b622 | 1102 | portB[4] = GPIOB->AFR[0]; |
Mike Fiore |
14:f9a77400b622 | 1103 | portB[5] = GPIOB->AFR[1]; |
Mike Fiore |
14:f9a77400b622 | 1104 | |
Mike Fiore |
14:f9a77400b622 | 1105 | portC[0] = GPIOC->MODER; |
Mike Fiore |
14:f9a77400b622 | 1106 | portC[1] = GPIOC->OTYPER; |
Mike Fiore |
14:f9a77400b622 | 1107 | portC[2] = GPIOC->OSPEEDR; |
Mike Fiore |
14:f9a77400b622 | 1108 | portC[3] = GPIOC->PUPDR; |
Mike Fiore |
14:f9a77400b622 | 1109 | portC[4] = GPIOC->AFR[0]; |
Mike Fiore |
14:f9a77400b622 | 1110 | portC[5] = GPIOC->AFR[1]; |
Mike Fiore |
14:f9a77400b622 | 1111 | |
Mike Fiore |
14:f9a77400b622 | 1112 | portD[0] = GPIOD->MODER; |
Mike Fiore |
14:f9a77400b622 | 1113 | portD[1] = GPIOD->OTYPER; |
Mike Fiore |
14:f9a77400b622 | 1114 | portD[2] = GPIOD->OSPEEDR; |
Mike Fiore |
14:f9a77400b622 | 1115 | portD[3] = GPIOD->PUPDR; |
Mike Fiore |
14:f9a77400b622 | 1116 | portD[4] = GPIOD->AFR[0]; |
Mike Fiore |
14:f9a77400b622 | 1117 | portD[5] = GPIOD->AFR[1]; |
Mike Fiore |
14:f9a77400b622 | 1118 | |
Mike Fiore |
14:f9a77400b622 | 1119 | portH[0] = GPIOH->MODER; |
Mike Fiore |
14:f9a77400b622 | 1120 | portH[1] = GPIOH->OTYPER; |
Mike Fiore |
14:f9a77400b622 | 1121 | portH[2] = GPIOH->OSPEEDR; |
Mike Fiore |
14:f9a77400b622 | 1122 | portH[3] = GPIOH->PUPDR; |
Mike Fiore |
14:f9a77400b622 | 1123 | portH[4] = GPIOH->AFR[0]; |
Mike Fiore |
14:f9a77400b622 | 1124 | portH[5] = GPIOH->AFR[1]; |
Mike Fiore |
14:f9a77400b622 | 1125 | |
Mike Fiore |
14:f9a77400b622 | 1126 | /* GPIO Ports Clock Enable */ |
Mike Fiore |
14:f9a77400b622 | 1127 | __GPIOA_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1128 | __GPIOB_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1129 | __GPIOC_CLK_ENABLE(); |
Mike Fiore |
14:f9a77400b622 | 1130 | |
Mike Fiore |
14:f9a77400b622 | 1131 | GPIO_InitTypeDef GPIO_InitStruct; |
Mike Fiore |
14:f9a77400b622 | 1132 | |
Mike Fiore |
14:f9a77400b622 | 1133 | // Set port A pins to analog nopull |
Mike Fiore |
14:f9a77400b622 | 1134 | GPIO_InitStruct.Pin = GPIO_PIN_2 | GPIO_PIN_6 | GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 |
Mike Fiore |
14:f9a77400b622 | 1135 | | GPIO_PIN_12 | GPIO_PIN_13 | GPIO_PIN_14 | GPIO_PIN_15; |
Mike Fiore |
14:f9a77400b622 | 1136 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1137 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1138 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1139 | |
Mike Fiore |
14:f9a77400b622 | 1140 | // Set port B pins to analog nopull |
Mike Fiore |
14:f9a77400b622 | 1141 | GPIO_InitStruct.Pin = GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3 | GPIO_PIN_4; |
Mike Fiore |
14:f9a77400b622 | 1142 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1143 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1144 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1145 | |
Mike Fiore |
14:f9a77400b622 | 1146 | // Set port C pins to analog nopull |
Mike Fiore |
14:f9a77400b622 | 1147 | GPIO_InitStruct.Pin = GPIO_PIN_9 | GPIO_PIN_13; |
Mike Fiore |
14:f9a77400b622 | 1148 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1149 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1150 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1151 | |
Mike Fiore |
14:f9a77400b622 | 1152 | // iterate through potential wake pins - leave the configured wake pin alone if one is needed |
Mike Fiore |
14:f9a77400b622 | 1153 | // XBEE_DIN - PA3 |
Mike Fiore |
14:f9a77400b622 | 1154 | // XBEE_DIO2 - PA5 |
Mike Fiore |
14:f9a77400b622 | 1155 | // XBEE_DIO3 - PA4 |
Mike Fiore |
14:f9a77400b622 | 1156 | // XBEE_DIO4 - PA7 |
Mike Fiore |
14:f9a77400b622 | 1157 | // XBEE_DIO5 - PC1 |
Mike Fiore |
14:f9a77400b622 | 1158 | // XBEE_DIO6 - PA1 |
Mike Fiore |
14:f9a77400b622 | 1159 | // XBEE_DIO7 - PA0 |
Mike Fiore |
14:f9a77400b622 | 1160 | // XBEE_SLEEPRQ - PA11 |
Mike Fiore |
14:f9a77400b622 | 1161 | |
Mike Fiore |
14:f9a77400b622 | 1162 | if (_dot->getWakePin() != XBEE_DIN || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1163 | GPIO_InitStruct.Pin = GPIO_PIN_3; |
Mike Fiore |
14:f9a77400b622 | 1164 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1165 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1166 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1167 | } |
Mike Fiore |
14:f9a77400b622 | 1168 | |
Mike Fiore |
14:f9a77400b622 | 1169 | if (_dot->getWakePin() != XBEE_DIO2 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1170 | GPIO_InitStruct.Pin = GPIO_PIN_5; |
Mike Fiore |
14:f9a77400b622 | 1171 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1172 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1173 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1174 | } |
Mike Fiore |
14:f9a77400b622 | 1175 | |
Mike Fiore |
14:f9a77400b622 | 1176 | if (_dot->getWakePin() != XBEE_DIO3 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1177 | GPIO_InitStruct.Pin = GPIO_PIN_4; |
Mike Fiore |
14:f9a77400b622 | 1178 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1179 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1180 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1181 | } |
Mike Fiore |
14:f9a77400b622 | 1182 | |
Mike Fiore |
14:f9a77400b622 | 1183 | if (_dot->getWakePin() != XBEE_DIO4 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1184 | GPIO_InitStruct.Pin = GPIO_PIN_7; |
Mike Fiore |
14:f9a77400b622 | 1185 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1186 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1187 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1188 | } |
Mike Fiore |
14:f9a77400b622 | 1189 | |
Mike Fiore |
14:f9a77400b622 | 1190 | if (_dot->getWakePin() != XBEE_DIO5 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1191 | GPIO_InitStruct.Pin = GPIO_PIN_1; |
Mike Fiore |
14:f9a77400b622 | 1192 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1193 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1194 | HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1195 | } |
Mike Fiore |
14:f9a77400b622 | 1196 | |
Mike Fiore |
14:f9a77400b622 | 1197 | if (_dot->getWakePin() != XBEE_DIO6 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1198 | GPIO_InitStruct.Pin = GPIO_PIN_1; |
Mike Fiore |
14:f9a77400b622 | 1199 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1200 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1201 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1202 | } |
Mike Fiore |
14:f9a77400b622 | 1203 | |
Mike Fiore |
14:f9a77400b622 | 1204 | if (_dot->getWakePin() != XBEE_DIO7 || _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1205 | GPIO_InitStruct.Pin = GPIO_PIN_0; |
Mike Fiore |
14:f9a77400b622 | 1206 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1207 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1208 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1209 | } |
Mike Fiore |
14:f9a77400b622 | 1210 | |
Mike Fiore |
14:f9a77400b622 | 1211 | if (_dot->getWakePin() != XBEE_SLEEPRQ|| _dot->getWakeMode() == mDot::RTC_ALARM) { |
Mike Fiore |
14:f9a77400b622 | 1212 | GPIO_InitStruct.Pin = GPIO_PIN_11; |
Mike Fiore |
14:f9a77400b622 | 1213 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; |
Mike Fiore |
14:f9a77400b622 | 1214 | GPIO_InitStruct.Pull = GPIO_NOPULL; |
Mike Fiore |
14:f9a77400b622 | 1215 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); |
Mike Fiore |
14:f9a77400b622 | 1216 | } |
Mike Fiore |
14:f9a77400b622 | 1217 | |
Mike Fiore |
14:f9a77400b622 | 1218 | #endif |
Mike Fiore |
4:666017851052 | 1219 | _dot->sleep(_dot->getWakeInterval(), _dot->getWakeMode(), standby); |
Mike Fiore |
14:f9a77400b622 | 1220 | |
Mike Fiore |
14:f9a77400b622 | 1221 | #if defined(TARGET_XDOT_L151CC) |
Mike Fiore |
14:f9a77400b622 | 1222 | xdot_restore_gpio_state(); |
Mike Fiore |
14:f9a77400b622 | 1223 | #else |
Mike Fiore |
14:f9a77400b622 | 1224 | //Restore the GPIO state. |
Mike Fiore |
14:f9a77400b622 | 1225 | GPIOA->MODER = portA[0]; |
Mike Fiore |
14:f9a77400b622 | 1226 | GPIOA->OTYPER = portA[1]; |
Mike Fiore |
14:f9a77400b622 | 1227 | GPIOA->OSPEEDR = portA[2]; |
Mike Fiore |
14:f9a77400b622 | 1228 | GPIOA->PUPDR = portA[3]; |
Mike Fiore |
14:f9a77400b622 | 1229 | GPIOA->AFR[0] = portA[4]; |
Mike Fiore |
14:f9a77400b622 | 1230 | GPIOA->AFR[1] = portA[5]; |
Mike Fiore |
14:f9a77400b622 | 1231 | |
Mike Fiore |
14:f9a77400b622 | 1232 | GPIOB->MODER = portB[0]; |
Mike Fiore |
14:f9a77400b622 | 1233 | GPIOB->OTYPER = portB[1]; |
Mike Fiore |
14:f9a77400b622 | 1234 | GPIOB->OSPEEDR = portB[2]; |
Mike Fiore |
14:f9a77400b622 | 1235 | GPIOB->PUPDR = portB[3]; |
Mike Fiore |
14:f9a77400b622 | 1236 | GPIOB->AFR[0] = portB[4]; |
Mike Fiore |
14:f9a77400b622 | 1237 | GPIOB->AFR[1] = portB[5]; |
Mike Fiore |
14:f9a77400b622 | 1238 | |
Mike Fiore |
14:f9a77400b622 | 1239 | GPIOC->MODER = portC[0]; |
Mike Fiore |
14:f9a77400b622 | 1240 | GPIOC->OTYPER = portC[1]; |
Mike Fiore |
14:f9a77400b622 | 1241 | GPIOC->OSPEEDR = portC[2]; |
Mike Fiore |
14:f9a77400b622 | 1242 | GPIOC->PUPDR = portC[3]; |
Mike Fiore |
14:f9a77400b622 | 1243 | GPIOC->AFR[0] = portC[4]; |
Mike Fiore |
14:f9a77400b622 | 1244 | GPIOC->AFR[1] = portC[5]; |
Mike Fiore |
14:f9a77400b622 | 1245 | |
Mike Fiore |
14:f9a77400b622 | 1246 | GPIOD->MODER = portD[0]; |
Mike Fiore |
14:f9a77400b622 | 1247 | GPIOD->OTYPER = portD[1]; |
Mike Fiore |
14:f9a77400b622 | 1248 | GPIOD->OSPEEDR = portD[2]; |
Mike Fiore |
14:f9a77400b622 | 1249 | GPIOD->PUPDR = portD[3]; |
Mike Fiore |
14:f9a77400b622 | 1250 | GPIOD->AFR[0] = portD[4]; |
Mike Fiore |
14:f9a77400b622 | 1251 | GPIOD->AFR[1] = portD[5]; |
Mike Fiore |
14:f9a77400b622 | 1252 | |
Mike Fiore |
14:f9a77400b622 | 1253 | GPIOH->MODER = portH[0]; |
Mike Fiore |
14:f9a77400b622 | 1254 | GPIOH->OTYPER = portH[1]; |
Mike Fiore |
14:f9a77400b622 | 1255 | GPIOH->OSPEEDR = portH[2]; |
Mike Fiore |
14:f9a77400b622 | 1256 | GPIOH->PUPDR = portH[3]; |
Mike Fiore |
14:f9a77400b622 | 1257 | GPIOH->AFR[0] = portH[4]; |
Mike Fiore |
14:f9a77400b622 | 1258 | GPIOH->AFR[1] = portH[5]; |
Mike Fiore |
14:f9a77400b622 | 1259 | #endif |
Mike Fiore |
14:f9a77400b622 | 1260 | |
Mike Fiore |
14:f9a77400b622 | 1261 | _serial.rxClear(); |
Mike Fiore |
14:f9a77400b622 | 1262 | _serial.txClear(); |
Mike Fiore |
14:f9a77400b622 | 1263 | } |
Mike Fiore |
14:f9a77400b622 | 1264 | |
Mike Fiore |
14:f9a77400b622 | 1265 | std::string CommandTerminal::formatPacketData(const std::vector<uint8_t>& data, const uint8_t& format) { |
Mike Fiore |
14:f9a77400b622 | 1266 | if (format == mDot::HEXADECIMAL) |
Mike Fiore |
14:f9a77400b622 | 1267 | return mts::Text::bin2hexString(data); |
Mike Fiore |
14:f9a77400b622 | 1268 | else |
Mike Fiore |
14:f9a77400b622 | 1269 | return std::string(data.begin(), data.end()); |
Mike Fiore |
1:e52ae6584f1c | 1270 | } |
Mike Fiore |
1:e52ae6584f1c | 1271 | |
Mike Fiore |
1:e52ae6584f1c | 1272 | bool CommandTerminal::waitForEscape(int timeout, mDot* dot, WaitType wait) { |
Mike Fiore |
1:e52ae6584f1c | 1273 | Timer timer; |
Mike Fiore |
1:e52ae6584f1c | 1274 | |
Mike Fiore |
1:e52ae6584f1c | 1275 | timer.start(); |
Mike Fiore |
1:e52ae6584f1c | 1276 | while (timer.read_ms() < timeout) { |
Mike Fiore |
1:e52ae6584f1c | 1277 | |
Mike Fiore |
1:e52ae6584f1c | 1278 | if (dot != NULL) { |
Mike Fiore |
1:e52ae6584f1c | 1279 | if (wait == WAIT_SEND && (!dot->getIsTransmitting())) { |
Mike Fiore |
1:e52ae6584f1c | 1280 | return false; |
Mike Fiore |
1:e52ae6584f1c | 1281 | } |
Mike Fiore |
1:e52ae6584f1c | 1282 | } |
Mike Fiore |
1:e52ae6584f1c | 1283 | |
Mike Fiore |
9:ff62b20f7000 | 1284 | if (_serialp != NULL && _serialp->escaped()) { |
Mike Fiore |
9:ff62b20f7000 | 1285 | _serialp->clearEscaped(); |
Mike Fiore |
9:ff62b20f7000 | 1286 | return true; |
Mike Fiore |
1:e52ae6584f1c | 1287 | } |
Mike Fiore |
1:e52ae6584f1c | 1288 | |
Mike Fiore |
1:e52ae6584f1c | 1289 | osDelay(10); |
Mike Fiore |
1:e52ae6584f1c | 1290 | } |
Mike Fiore |
1:e52ae6584f1c | 1291 | |
Mike Fiore |
1:e52ae6584f1c | 1292 | return false; |
Mike Fiore |
1:e52ae6584f1c | 1293 | } |
Mike Fiore |
1:e52ae6584f1c | 1294 | |
Mike Fiore |
9:ff62b20f7000 | 1295 | void CommandTerminal::wakeup(void) { |
Mike Fiore |
9:ff62b20f7000 | 1296 | } |
Mike Fiore |
9:ff62b20f7000 | 1297 | |
Mike Fiore |
14:f9a77400b622 | 1298 | void CommandTerminal::RadioEvent::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) { |
Mike Fiore |
14:f9a77400b622 | 1299 | mDotEvent::PacketRx(port, payload, size, rssi, snr, ctrl, retries); |
Mike Fiore |
1:e52ae6584f1c | 1300 | |
Mike Fiore |
14:f9a77400b622 | 1301 | if (serial_data_mode) { |
Mike Fiore |
14:f9a77400b622 | 1302 | logDebug("Rx %d bytes", size); |
Mike Fiore |
14:f9a77400b622 | 1303 | if (size > 0) { |
Mike Fiore |
14:f9a77400b622 | 1304 | CommandTerminal::Serial()->write((char*) RxPayload, RxPayloadSize); |
Mike Fiore |
9:ff62b20f7000 | 1305 | } |
Mike Fiore |
14:f9a77400b622 | 1306 | if (!CommandTerminal::Serial()->readable() && _dot->getAckRequested() && _dot->getClass() == "C") { |
Mike Fiore |
14:f9a77400b622 | 1307 | _sendAck = true; |
Mike Fiore |
9:ff62b20f7000 | 1308 | } |
Mike Fiore |
9:ff62b20f7000 | 1309 | } |
Mike Fiore |
1:e52ae6584f1c | 1310 | } |
Mike Fiore |
9:ff62b20f7000 | 1311 | |
Mike Fiore |
9:ff62b20f7000 | 1312 | CommandTerminal::~CommandTerminal() { |
Mike Fiore |
9:ff62b20f7000 | 1313 | delete _events; |
Mike Fiore |
9:ff62b20f7000 | 1314 | } |