AT command firmware for MultiTech Dot devices.

Fork of mDot_AT_firmware by MultiTech

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. The AT firmware was last tested with mbed-os-5.4.7. Using a version past mbed-os-5.4.7 will cause the build to fail. The library used with the AT firmware has to match the mbed-os version.

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.

libmDot-dev-mbed5

Stable library for mDot.

Import librarylibmDot-mbed5

Stable version of the mDot library for mbed 5. This version of the library is suitable for deployment scenarios. See lastest commit message for version of mbed-os library that has been tested against.

xDot Library

Development library for xDot.

libxDot-dev-mbed5

Stable library for xDot.

Import librarylibxDot-mbed5

Stable version of the xDot library for mbed 5. This version of the library is suitable for deployment scenarios.

Committer:
Jason Reiss
Date:
Fri Jan 29 13:04:32 2021 -0600
Revision:
33:5c0252521669
Parent:
28:c222ca8383f4
Remove moved commands

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 9:ff62b20f7000 1 #ifndef ATSERIAL_H
Mike Fiore 9:ff62b20f7000 2 #define ATSERIAL_H
Mike Fiore 9:ff62b20f7000 3
Jason Reiss 28:c222ca8383f4 4 #include "mbed.h"
Mike Fiore 9:ff62b20f7000 5
Mike Fiore 9:ff62b20f7000 6 namespace mts
Mike Fiore 9:ff62b20f7000 7 {
Mike Fiore 9:ff62b20f7000 8
Jason Reiss 28:c222ca8383f4 9 /** This class wraps provides a buffered wrapper to the mbed::UnbufferedSerial
Jason Reiss 28:c222ca8383f4 10 * class. Looks for an escape sequence within received byte stream.
Jason Reiss 28:c222ca8383f4 11 */
Jason Reiss 28:c222ca8383f4 12 class ATSerial : private mbed::NonCopyable<ATSerial>
Mike Fiore 9:ff62b20f7000 13 {
Mike Fiore 9:ff62b20f7000 14 public:
Mike Fiore 9:ff62b20f7000 15 /** Creates a new ATSerial object that can be used to talk to an mbed serial port
Jason Reiss 28:c222ca8383f4 16 * through internal SW buffers. Providing RTS and CTS will enable flow control.
Mike Fiore 9:ff62b20f7000 17 *
Jason Reiss 28:c222ca8383f4 18 * @param txd the transmit data pin on the desired mbed Serial interface.
Jason Reiss 28:c222ca8383f4 19 * @param rxd the receive data pin on the desired mbed Serial interface.
Jason Reiss 28:c222ca8383f4 20 * @param rts the request-to-send pin on the desired mbed Serial interface.
Jason Reiss 28:c222ca8383f4 21 * @param cts the clear-to-send pin on the desired mbed Serial interface.
Jason Reiss 28:c222ca8383f4 22 * @param baud The initial baudrate
Mike Fiore 9:ff62b20f7000 23 */
Jason Reiss 28:c222ca8383f4 24 ATSerial(PinName txd, PinName rxd, PinName rts = NC, PinName cts = NC,
Jason Reiss 28:c222ca8383f4 25 int baud = MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
Mike Fiore 9:ff62b20f7000 26
Mike Fiore 9:ff62b20f7000 27 /** Destructs an ATSerial object and frees all related resources, including
Mike Fiore 9:ff62b20f7000 28 * internal buffers.
Mike Fiore 9:ff62b20f7000 29 */
Mike Fiore 9:ff62b20f7000 30 virtual ~ATSerial();
Mike Fiore 9:ff62b20f7000 31
Mike Fiore 9:ff62b20f7000 32 /** This method is used to the set the baud rate of the serial port.
Mike Fiore 9:ff62b20f7000 33 *
Mike Fiore 9:ff62b20f7000 34 * @param baudrate the baudrate in bps as an int. The default is 9600 bps.
Mike Fiore 9:ff62b20f7000 35 */
Mike Fiore 9:ff62b20f7000 36 void baud(int baudrate);
Mike Fiore 9:ff62b20f7000 37
Mike Fiore 9:ff62b20f7000 38 /** This method sets the transmission format used by the serial port.
Mike Fiore 9:ff62b20f7000 39 *
Mike Fiore 9:ff62b20f7000 40 * @param bits the number of bits in a word (5-8; default = 8)
Mike Fiore 9:ff62b20f7000 41 * @param parity the parity used (SerialBase::None, SerialBase::Odd, SerialBase::Even,
Mike Fiore 9:ff62b20f7000 42 * SerialBase::Forced1, SerialBase::Forced0; default = SerialBase::None)
Mike Fiore 9:ff62b20f7000 43 * @param stop the number of stop bits (1 or 2; default = 1)
Mike Fiore 9:ff62b20f7000 44 */
Jason Reiss 28:c222ca8383f4 45 void format(int bits=8, mbed::SerialBase::Parity parity=mbed::SerialBase::None, int stop_bits=1);
Jason Reiss 28:c222ca8383f4 46
Jason Reiss 28:c222ca8383f4 47 /** Check if bytes are available to read.
Jason Reiss 28:c222ca8383f4 48 * @return True if receive buffer is not empty.
Jason Reiss 28:c222ca8383f4 49 */
Jason Reiss 28:c222ca8383f4 50 bool readable();
Mike Fiore 9:ff62b20f7000 51
Jason Reiss 28:c222ca8383f4 52 /** Check if bytes can be written.
Jason Reiss 28:c222ca8383f4 53 * @return True if transmit buffer is not full.
Mike Fiore 9:ff62b20f7000 54 */
Jason Reiss 28:c222ca8383f4 55 bool writeable();
Jason Reiss 28:c222ca8383f4 56
Jason Reiss 28:c222ca8383f4 57 /** Clear the receive buffer. */
Jason Reiss 28:c222ca8383f4 58 void rxClear();
Jason Reiss 28:c222ca8383f4 59
Jason Reiss 28:c222ca8383f4 60 /** Clear the transmist buffer. */
Jason Reiss 28:c222ca8383f4 61 void txClear();
Mike Fiore 9:ff62b20f7000 62
Mike Fiore 9:ff62b20f7000 63 /** Check for escape sequence detected on serial input
Jason Reiss 28:c222ca8383f4 64 * @return true if escape sequence was seen
Mike Fiore 9:ff62b20f7000 65 */
Mike Fiore 9:ff62b20f7000 66 bool escaped();
Mike Fiore 9:ff62b20f7000 67
Jason Reiss 28:c222ca8383f4 68 /** Set escape character. */
Mike Fiore 9:ff62b20f7000 69 void escapeChar(char esc);
Mike Fiore 9:ff62b20f7000 70
Jason Reiss 28:c222ca8383f4 71 /** Get the escape character. */
Mike Fiore 9:ff62b20f7000 72 char escapeChar();
Mike Fiore 9:ff62b20f7000 73
Jason Reiss 28:c222ca8383f4 74 /** Clear escaped state. */
Mike Fiore 9:ff62b20f7000 75 void clearEscaped();
Mike Fiore 9:ff62b20f7000 76
Jason Reiss 28:c222ca8383f4 77 /** Read a byte from receive buffer
Jason Reiss 28:c222ca8383f4 78 * @param[out] c Storage for read character
Jason Reiss 28:c222ca8383f4 79 * @return True if a character was read
Jason Reiss 28:c222ca8383f4 80 */
Jason Reiss 28:c222ca8383f4 81 bool read(char& c);
Jason Reiss 28:c222ca8383f4 82
Jason Reiss 28:c222ca8383f4 83 /** Read bytes from the receive buffer.
Jason Reiss 28:c222ca8383f4 84 * @param[out] buffer Allocated memory to store read bytes
Jason Reiss 28:c222ca8383f4 85 * @param length Size of buffer in bytes
Jason Reiss 28:c222ca8383f4 86 * @return Number of bytes read
Jason Reiss 27:5fafd3b26ac3 87 */
Jason Reiss 28:c222ca8383f4 88 int read(char *buffer, size_t length);
Jason Reiss 28:c222ca8383f4 89
Jason Reiss 28:c222ca8383f4 90 /** Write bytes from to transmit buffer.
Jason Reiss 28:c222ca8383f4 91 * @param buffer Bytes to write
Jason Reiss 28:c222ca8383f4 92 * @param length Size of buffer in bytes
Jason Reiss 28:c222ca8383f4 93 * @return Number of bytes written
Jason Reiss 28:c222ca8383f4 94 */
Jason Reiss 28:c222ca8383f4 95 int write(const char *buffer, size_t length);
Jason Reiss 28:c222ca8383f4 96
Jason Reiss 28:c222ca8383f4 97 /** Write formatted string to transmit buffer.
Jason Reiss 28:c222ca8383f4 98 * @param format Format string
Jason Reiss 28:c222ca8383f4 99 * @param ... Items to format
Jason Reiss 28:c222ca8383f4 100 * @return Number of bytes written
Jason Reiss 28:c222ca8383f4 101 */
Jason Reiss 28:c222ca8383f4 102 int writef(const char* format, ... );
Mike Fiore 9:ff62b20f7000 103
Mike Fiore 9:ff62b20f7000 104 protected:
Jason Reiss 28:c222ca8383f4 105 mbed::UnbufferedSerial _serial; // Using unbuffered serial so reads can be done in event handler
Mike Fiore 9:ff62b20f7000 106
Jason Reiss 28:c222ca8383f4 107 // Receive buffer
Jason Reiss 28:c222ca8383f4 108 mbed::CircularBuffer<char, MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE> _rxbuf;
Jason Reiss 28:c222ca8383f4 109 // Transmit buffer
Jason Reiss 28:c222ca8383f4 110 mbed::CircularBuffer<char, MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE> _txbuf;
Jason Reiss 28:c222ca8383f4 111 bool _tx_irq_enabled; // Flag indicating transmit IRQ is enabled
Mike Fiore 9:ff62b20f7000 112
Jason Reiss 28:c222ca8383f4 113 Timer _timer; // Inter-byte receive timer
Jason Reiss 28:c222ca8383f4 114 std::chrono::milliseconds _last_time; // Last time a byte was received
Jason Reiss 28:c222ca8383f4 115 int _esc_cnt; // Number of escape characters received
Jason Reiss 28:c222ca8383f4 116 char _esc_ch; // Escape character
Jason Reiss 28:c222ca8383f4 117 bool _escaped; // True if escape sequence has been received
Jason Reiss 28:c222ca8383f4 118 void handleRead(); // Method for handling data to be read
Jason Reiss 28:c222ca8383f4 119 void handleWrite(); // Method for handling data writes
Jason Reiss 28:c222ca8383f4 120 void startWrite(); // Method for starting data writes
Jason Reiss 28:c222ca8383f4 121 PlatformMutex _mutex; // Lock for API accesses
Jason Reiss 28:c222ca8383f4 122 bool _flow; // Flag indicates flow control is enabled
Jason Reiss 28:c222ca8383f4 123 DigitalOut _rts; // Request to send signal
Jason Reiss 28:c222ca8383f4 124 InterruptIn _cts; // Clear to send signal
Jason Reiss 28:c222ca8383f4 125 size_t _hwm; // RX buffer high water mark for setting RTS to stop
Jason Reiss 28:c222ca8383f4 126 size_t _lwm; // RX buffer low water mark for setting RTS to start
Mike Fiore 9:ff62b20f7000 127 };
Mike Fiore 9:ff62b20f7000 128
Mike Fiore 9:ff62b20f7000 129 }
Mike Fiore 9:ff62b20f7000 130
Mike Fiore 9:ff62b20f7000 131 #endif /* ATSERIAL_H */