AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
Dot Library Not Included!
Because these example programs can be used for both mDot and xDot devices, the LoRa stack is not included. The libmDot library should be imported if building for mDot devices. The libxDot library should be imported if building for xDot devices. Check the commit messages of the Dot library version used to find the correct mbed-os version to use with it. The mbed-os version must match the version used in that version of Dot library or it will likely cause it to fail to compile or have unexpected problems while running.
Dot Library Version 3 Updates
Dot Library versions 3.x.x require a channel plan to be injected into the stack. The Dot-Examples and Dot-AT-Firmware do this by defining a macro called "CHANNEL_PLAN" that controls the channel plan that will be used in the examples. Available channel plans will be in the Dot Library repository in the plans folder.
Revision 20 and earlier of Dot-Examples and revision 15 and earlier of Dot-AT-Firmware should be used with Dot Library versions prior to 3.0.0.
Fota Library
Th Fota Library must be added to compile for mDot 3.1.0 with Fota support. Latest dev libraries and 3.2.0 release will include Fota with libmDot/libxDot.
AT Firmware Description
This AT Firmware is what ships on mDot and xDot devices. It provides an AT command interface for using the mDot or xDot for LoRa communication.
AT command documentation can be found on Multitech.com.
The firmware changelog can be found here.
The library changelog can be found here.
Dot Libraries
Dot Library Limitations
The commit messages in libmDot-mbed5 and libmDot-dev-mbed5 specify the version of the Dot library the commit contains and the version of mbed-os it was compiled against. We recommend building your application with the version of mbed-os specified in the commit message of the version of the Dot library you're using. This will ensure that you don't run into any runtime issues caused by differences in the mbed-os versions.
Stable and development libraries are available for both mDot and xDot platforms. The library chosen must match the target platform. Compiling for the mDot platform with the xDot library or vice versa will not succeed.
mDot Library
Development library for mDot.
Stable library for mDot.
xDot Library
Development library for xDot.
Stable library for xDot.
CommandTerminal/CommandTerminal.h@23:4f0a981c0349, 2019-04-24 (annotated)
- Committer:
- Jason Reiss
- Date:
- Wed Apr 24 10:47:25 2019 -0500
- Revision:
- 23:4f0a981c0349
- Parent:
- 22:a13ac7df92c0
- Child:
- 27:5fafd3b26ac3
Update for v3.2.0 release
Who changed what in which revision?
User | Revision | Line number | New 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" |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 42 | #include "Fota.h" |
Mike Fiore |
14:f9a77400b622 | 43 | |
Mike Fiore |
1:e52ae6584f1c | 44 | /* Define to prevent recursive inclusion -------------------------------------*/ |
Mike Fiore |
1:e52ae6584f1c | 45 | #ifndef __command_terminal_H__ |
Mike Fiore |
1:e52ae6584f1c | 46 | #define __command_terminal_H__ |
Mike Fiore |
1:e52ae6584f1c | 47 | |
Mike Fiore |
14:f9a77400b622 | 48 | typedef uint32_t (*action_ptr_t)(std::vector<std::string> args); |
Mike Fiore |
14:f9a77400b622 | 49 | typedef bool (*verify_ptr_t)(std::vector<std::string> args); |
Mike Fiore |
14:f9a77400b622 | 50 | |
Mike Fiore |
14:f9a77400b622 | 51 | class Command; |
Mike Fiore |
14:f9a77400b622 | 52 | |
Mike Fiore |
1:e52ae6584f1c | 53 | class CommandTerminal { |
Mike Fiore |
1:e52ae6584f1c | 54 | |
Mike Fiore |
14:f9a77400b622 | 55 | class RadioEvent : public mDotEvent { |
Mike Fiore |
9:ff62b20f7000 | 56 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 57 | public: |
Mike Fiore |
14:f9a77400b622 | 58 | RadioEvent() : _sendAck(false) {} |
Mike Fiore |
9:ff62b20f7000 | 59 | |
Mike Fiore |
9:ff62b20f7000 | 60 | virtual ~RadioEvent() {} |
Mike Fiore |
9:ff62b20f7000 | 61 | |
Mike Fiore |
14:f9a77400b622 | 62 | virtual void TxDone(uint8_t dr) { |
Mike Fiore |
14:f9a77400b622 | 63 | mDotEvent::TxDone(dr); |
Mike Fiore |
14:f9a77400b622 | 64 | |
Mike Fiore |
14:f9a77400b622 | 65 | logDebug("RadioEvent - TxDone"); |
Mike Fiore |
14:f9a77400b622 | 66 | } |
Mike Fiore |
14:f9a77400b622 | 67 | |
Mike Fiore |
14:f9a77400b622 | 68 | virtual void TxTimeout(void) { |
Mike Fiore |
14:f9a77400b622 | 69 | mDotEvent::TxTimeout(); |
Mike Fiore |
14:f9a77400b622 | 70 | |
Mike Fiore |
14:f9a77400b622 | 71 | logDebug("RadioEvent - TxTimeout"); |
Mike Fiore |
14:f9a77400b622 | 72 | } |
Mike Fiore |
14:f9a77400b622 | 73 | |
Mike Fiore |
14:f9a77400b622 | 74 | virtual void JoinAccept(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { |
Mike Fiore |
14:f9a77400b622 | 75 | mDotEvent::JoinAccept(payload, size, rssi, snr); |
Mike Fiore |
14:f9a77400b622 | 76 | |
Mike Fiore |
14:f9a77400b622 | 77 | logDebug("RadioEvent - JoinAccept"); |
Mike Fiore |
14:f9a77400b622 | 78 | } |
Mike Fiore |
14:f9a77400b622 | 79 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 80 | virtual void JoinFailed(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr) { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 81 | mDotEvent::JoinFailed(payload, size, rssi, snr); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 82 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 83 | logDebug("RadioEvent - JoinFailed"); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 84 | } |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 85 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 86 | 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, uint32_t address, bool dupRx); |
Mike Fiore |
14:f9a77400b622 | 87 | |
Mike Fiore |
14:f9a77400b622 | 88 | 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 | 89 | mDotEvent::RxDone(payload, size, rssi, snr, ctrl, slot); |
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) { |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 118 | return CommandTerminal::getBatteryLevel(); |
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 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 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;} |
Jason Reiss |
23:4f0a981c0349 | 175 | |
Mike Fiore |
14:f9a77400b622 | 176 | static mDot* Dot() {return _dot;} |
Mike Fiore |
14:f9a77400b622 | 177 | static mDot* _dot; |
Mike Fiore |
1:e52ae6584f1c | 178 | |
Jason Reiss |
23:4f0a981c0349 | 179 | static const RadioEvent* Events() { return _events; } |
Jason Reiss |
23:4f0a981c0349 | 180 | |
Mike Fiore |
14:f9a77400b622 | 181 | static void setErrorMessage(const char* message); |
Mike Fiore |
14:f9a77400b622 | 182 | static void setErrorMessage(const std::string& message); |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 183 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 184 | static uint8_t getBatteryLevel(); |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 185 | static void setBatteryLevel(const uint8_t battery_level); |
Mike Fiore |
14:f9a77400b622 | 186 | |
Jason Reiss |
23:4f0a981c0349 | 187 | static void formatPacket(uint8_t* payload, uint16_t size); |
Jason Reiss |
23:4f0a981c0349 | 188 | static std::string formatPacket(std::vector<uint8_t> payload); |
Jason Reiss |
23:4f0a981c0349 | 189 | static void formatPacketSDSend(std::vector<uint8_t> &payload); |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 190 | protected: |
Mike Fiore |
14:f9a77400b622 | 191 | |
Mike Fiore |
14:f9a77400b622 | 192 | static std::string _errorMessage; |
Mike Fiore |
14:f9a77400b622 | 193 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 194 | private: |
Mike Fiore |
4:666017851052 | 195 | |
Mike Fiore |
9:ff62b20f7000 | 196 | mts::ATSerial& _serial; |
Mike Fiore |
9:ff62b20f7000 | 197 | static mts::ATSerial* _serialp; |
Mike Fiore |
1:e52ae6584f1c | 198 | |
Mike Fiore |
14:f9a77400b622 | 199 | static CommandTerminal::RadioEvent* _events; |
Mike Fiore |
1:e52ae6584f1c | 200 | mDot::Mode _mode; |
Mike Fiore |
14:f9a77400b622 | 201 | |
Mike Fiore |
1:e52ae6584f1c | 202 | bool _sleep_standby; |
Mike Fiore |
1:e52ae6584f1c | 203 | DigitalOut _xbee_on_sleep; |
Mike Fiore |
14:f9a77400b622 | 204 | bool _autoOTAEnabled; |
Mike Fiore |
1:e52ae6584f1c | 205 | |
Mike Fiore |
9:ff62b20f7000 | 206 | void serialLoop(); |
Mike Fiore |
1:e52ae6584f1c | 207 | bool autoJoinCheck(); |
Mike Fiore |
1:e52ae6584f1c | 208 | |
Mike Fiore |
1:e52ae6584f1c | 209 | void printHelp(); |
Mike Fiore |
1:e52ae6584f1c | 210 | |
Mike Fiore |
14:f9a77400b622 | 211 | static bool readable(); |
Mike Fiore |
14:f9a77400b622 | 212 | static bool writeable(); |
Mike Fiore |
14:f9a77400b622 | 213 | static char read(); |
Mike Fiore |
14:f9a77400b622 | 214 | static void write(const char* message); |
Mike Fiore |
14:f9a77400b622 | 215 | static void writef(const char* format, ... ); |
Mike Fiore |
1:e52ae6584f1c | 216 | |
Mike Fiore |
1:e52ae6584f1c | 217 | void sleep(bool standby); |
Mike Fiore |
9:ff62b20f7000 | 218 | void wakeup(void); |
Mike Fiore |
14:f9a77400b622 | 219 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 220 | uint8_t* _payload; |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 221 | uint8_t _size; |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 222 | uint8_t _port; |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 223 | std::vector<uint8_t> data; |
Mike Fiore |
1:e52ae6584f1c | 224 | }; |
Mike Fiore |
1:e52ae6584f1c | 225 | |
Mike Fiore |
1:e52ae6584f1c | 226 | #endif // __command_terminal_H__ |