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:
Thu Nov 19 09:58:25 2020 -0600
Revision:
28:c222ca8383f4
Parent:
27:5fafd3b26ac3
update to Dot 4.0.0 release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 9:ff62b20f7000 1 #include "mbed.h"
Mike Fiore 9:ff62b20f7000 2 #include "mDot.h"
Mike Fiore 9:ff62b20f7000 3 #include "CommandTerminal.h"
jenkins@jenkinsdm1 16:d5cf2af81a6d 4 #include "ChannelPlans.h"
Mike Fiore 9:ff62b20f7000 5
Jason Reiss 28:c222ca8383f4 6 #if defined(TARGET_XDOT_L151CC) && defined(FOTA)
Jason Reiss 28:c222ca8383f4 7 #include "SPIFBlockDevice.h"
Jason Reiss 28:c222ca8383f4 8 #include "DataFlashBlockDevice.h"
Jason Reiss 28:c222ca8383f4 9 #endif
Jason Reiss 28:c222ca8383f4 10
Jason Reiss 28:c222ca8383f4 11 mbed::UnbufferedSerial debug_port(USBTX, USBRX, LOG_DEFAULT_BAUD_RATE);
Jason Reiss 28:c222ca8383f4 12
Jason Reiss 28:c222ca8383f4 13 FileHandle *mbed::mbed_override_console(int fd)
Jason Reiss 28:c222ca8383f4 14 {
Jason Reiss 28:c222ca8383f4 15 return &debug_port;
Jason Reiss 28:c222ca8383f4 16 }
Jason Reiss 28:c222ca8383f4 17
Mike Fiore 9:ff62b20f7000 18
Jason Reiss 28:c222ca8383f4 19 #if defined(TARGET_MTS_MDOT_F411RE)
Jason Reiss 28:c222ca8383f4 20 #define AT_TX_PIN XBEE_DOUT
Jason Reiss 28:c222ca8383f4 21 #define AT_RX_PIN XBEE_DIN
Jason Reiss 28:c222ca8383f4 22 #define AT_RTS_PIN XBEE_RTS
Jason Reiss 28:c222ca8383f4 23 #define AT_CTS_PIN XBEE_CTS
Jason Reiss 28:c222ca8383f4 24 #elif defined(TARGET_XDOT_L151CC)
Jason Reiss 28:c222ca8383f4 25 #define AT_TX_PIN UART1_TX
Jason Reiss 28:c222ca8383f4 26 #define AT_RX_PIN UART1_RX
Jason Reiss 28:c222ca8383f4 27 #define AT_RTS_PIN UART1_RTS
Jason Reiss 28:c222ca8383f4 28 #define AT_CTS_PIN UART1_CTS
Jason Reiss 28:c222ca8383f4 29 #else
Jason Reiss 28:c222ca8383f4 30 #error Unsupported target
Jason Reiss 28:c222ca8383f4 31 #endif
Mike Fiore 14:f9a77400b622 32
jenkins@jenkinsdm1 16:d5cf2af81a6d 33 #ifndef CHANNEL_PLAN
jenkins@jenkinsdm1 16:d5cf2af81a6d 34 #define CHANNEL_PLAN CP_US915
jenkins@jenkinsdm1 16:d5cf2af81a6d 35 #endif
jenkins@jenkinsdm1 16:d5cf2af81a6d 36
Mike Fiore 14:f9a77400b622 37 #ifndef UNIT_TEST
Jason Reiss 23:4f0a981c0349 38 #ifndef UNIT_TEST_MDOT_LIB
Jason Reiss 28:c222ca8383f4 39
Jason Reiss 28:c222ca8383f4 40 DigitalIn boot(PA_5);
Jason Reiss 28:c222ca8383f4 41
Mike Fiore 9:ff62b20f7000 42 int main()
Mike Fiore 9:ff62b20f7000 43 {
Jason Reiss 28:c222ca8383f4 44 #if defined(DEBUG_MAC) && defined(TARGET_MTS_MDOT_F411RE)
Jason Reiss 27:5fafd3b26ac3 45 lora::ChannelPlan* plan = new lora::ChannelPlan_US915();
Jason Reiss 27:5fafd3b26ac3 46 mDot* dot = mDot::getInstance(plan);
Jason Reiss 27:5fafd3b26ac3 47 #else
jenkins@jenkinsdm1 16:d5cf2af81a6d 48 #if CHANNEL_PLAN == CP_AS923
Jason Reiss 23:4f0a981c0349 49 lora::ChannelPlan_AS923 plan;
Jason Reiss 28:c222ca8383f4 50 #elif CHANNEL_PLAN == CP_AS923_2
Jason Reiss 28:c222ca8383f4 51 lora::ChannelPlan_AS923 plan;
Jason Reiss 28:c222ca8383f4 52 #elif CHANNEL_PLAN == CP_AS923_3
Jason Reiss 28:c222ca8383f4 53 lora::ChannelPlan_AS923 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 54 #elif CHANNEL_PLAN == CP_US915
Jason Reiss 23:4f0a981c0349 55 lora::ChannelPlan_US915 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 56 #elif CHANNEL_PLAN == CP_AU915
Jason Reiss 23:4f0a981c0349 57 lora::ChannelPlan_AU915 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 58 #elif CHANNEL_PLAN == CP_EU868
Jason Reiss 23:4f0a981c0349 59 lora::ChannelPlan_EU868 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 60 #elif CHANNEL_PLAN == CP_KR920
Jason Reiss 23:4f0a981c0349 61 lora::ChannelPlan_KR920 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 62 #elif CHANNEL_PLAN == CP_IN865
Jason Reiss 23:4f0a981c0349 63 lora::ChannelPlan_IN865 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 64 #elif CHANNEL_PLAN == CP_AS923_JAPAN
Jason Reiss 23:4f0a981c0349 65 lora::ChannelPlan_AS923_Japan plan;
Jason Reiss 28:c222ca8383f4 66 #elif CHANNEL_PLAN == CP_AS923_JAPAN1
Jason Reiss 28:c222ca8383f4 67 lora::ChannelPlan_AS923_Japan1 plan;
Jason Reiss 28:c222ca8383f4 68 #elif CHANNEL_PLAN == CP_AS923_JAPAN2
Jason Reiss 28:c222ca8383f4 69 lora::ChannelPlan_AS923_Japan2 plan;
Jason Reiss 23:4f0a981c0349 70 #elif CHANNEL_PLAN == CP_RU864
Jason Reiss 23:4f0a981c0349 71 lora::ChannelPlan_RU864 plan;
jenkins@jenkinsdm1 16:d5cf2af81a6d 72 #endif
Jason Reiss 28:c222ca8383f4 73 #if defined(TARGET_XDOT_L151CC) && defined(FOTA)
Jason Reiss 28:c222ca8383f4 74
Jason Reiss 28:c222ca8383f4 75 mbed::BlockDevice* ext_bd = NULL;
Jason Reiss 28:c222ca8383f4 76
Jason Reiss 28:c222ca8383f4 77 ext_bd = new SPIFBlockDevice();
Jason Reiss 28:c222ca8383f4 78 int ret = ext_bd->init();
Jason Reiss 28:c222ca8383f4 79 if (ext_bd->init() < 0) {
Jason Reiss 28:c222ca8383f4 80 delete ext_bd;
Jason Reiss 28:c222ca8383f4 81 ext_bd = new DataFlashBlockDevice();
Jason Reiss 28:c222ca8383f4 82 ret = ext_bd->init();
Jason Reiss 28:c222ca8383f4 83 // Check for zero size because DataFlashBlockDevice doesn't
Jason Reiss 28:c222ca8383f4 84 // return an error if the chip is not present
Jason Reiss 28:c222ca8383f4 85 if ((ret < 0) || (ext_bd->size() == 0)) {
Jason Reiss 28:c222ca8383f4 86 delete ext_bd;
Jason Reiss 28:c222ca8383f4 87 ext_bd = NULL;
Jason Reiss 28:c222ca8383f4 88 }
Jason Reiss 28:c222ca8383f4 89 }
Jason Reiss 28:c222ca8383f4 90
Jason Reiss 28:c222ca8383f4 91 mDot* dot = mDot::getInstance(&plan, ext_bd);
Jason Reiss 28:c222ca8383f4 92
Jason Reiss 28:c222ca8383f4 93 if (ext_bd != NULL) {
Jason Reiss 28:c222ca8383f4 94 logInfo("External flash device detected, type: %s, size: 0x%08x",
Jason Reiss 28:c222ca8383f4 95 ext_bd->get_type(), (uint32_t)ext_bd->size());
Jason Reiss 28:c222ca8383f4 96 }
Jason Reiss 28:c222ca8383f4 97 #else
Jason Reiss 23:4f0a981c0349 98 mDot* dot = mDot::getInstance(&plan);
Jason Reiss 28:c222ca8383f4 99 #endif
Jason Reiss 27:5fafd3b26ac3 100 #endif //MTS_MDOT_F411RE
jenkins@jenkinsdm1 16:d5cf2af81a6d 101 assert(dot);
Mike Fiore 9:ff62b20f7000 102
Jason Reiss 28:c222ca8383f4 103 #if defined(DEBUG_MAC) && defined(TARGET_MTS_MDOT_F411RE)
Jason Reiss 27:5fafd3b26ac3 104 logDebug("Loading default channel plan %02x", dot->getDefaultFrequencyBand());
Jason Reiss 27:5fafd3b26ac3 105 switch (dot->getDefaultFrequencyBand()) {
Jason Reiss 27:5fafd3b26ac3 106 case lora::ChannelPlan::AS923:
Jason Reiss 28:c222ca8383f4 107 case lora::ChannelPlan::AS923_2:
Jason Reiss 28:c222ca8383f4 108 case lora::ChannelPlan::AS923_3:
Jason Reiss 28:c222ca8383f4 109 delete plan;
Jason Reiss 27:5fafd3b26ac3 110 plan = new lora::ChannelPlan_AS923();
Jason Reiss 27:5fafd3b26ac3 111 break;
Jason Reiss 27:5fafd3b26ac3 112
Jason Reiss 28:c222ca8383f4 113 case lora::ChannelPlan::US915:
Jason Reiss 27:5fafd3b26ac3 114 case lora::ChannelPlan::US915_OLD:
Jason Reiss 27:5fafd3b26ac3 115 delete plan;
Jason Reiss 27:5fafd3b26ac3 116 plan = new lora::ChannelPlan_US915();
Jason Reiss 27:5fafd3b26ac3 117 break;
Jason Reiss 27:5fafd3b26ac3 118
Jason Reiss 28:c222ca8383f4 119 case lora::ChannelPlan::AU915:
Jason Reiss 27:5fafd3b26ac3 120 case lora::ChannelPlan::AU915_OLD:
Jason Reiss 27:5fafd3b26ac3 121 delete plan;
Jason Reiss 27:5fafd3b26ac3 122 plan = new lora::ChannelPlan_AU915();
Jason Reiss 27:5fafd3b26ac3 123 break;
Jason Reiss 27:5fafd3b26ac3 124
Jason Reiss 28:c222ca8383f4 125 case lora::ChannelPlan::EU868:
Jason Reiss 27:5fafd3b26ac3 126 case lora::ChannelPlan::EU868_OLD:
Jason Reiss 27:5fafd3b26ac3 127 delete plan;
Jason Reiss 27:5fafd3b26ac3 128 plan = new lora::ChannelPlan_EU868();
Jason Reiss 27:5fafd3b26ac3 129 break;
Jason Reiss 27:5fafd3b26ac3 130
Jason Reiss 27:5fafd3b26ac3 131 case lora::ChannelPlan::KR920:
Jason Reiss 27:5fafd3b26ac3 132 delete plan;
Jason Reiss 27:5fafd3b26ac3 133 plan = new lora::ChannelPlan_KR920();
Jason Reiss 27:5fafd3b26ac3 134 break;
Jason Reiss 27:5fafd3b26ac3 135
Jason Reiss 27:5fafd3b26ac3 136 case lora::ChannelPlan::AS923_JAPAN:
Jason Reiss 27:5fafd3b26ac3 137 delete plan;
Jason Reiss 27:5fafd3b26ac3 138 plan = new lora::ChannelPlan_AS923_Japan();
Jason Reiss 27:5fafd3b26ac3 139 break;
Jason Reiss 27:5fafd3b26ac3 140
Jason Reiss 28:c222ca8383f4 141 case lora::ChannelPlan::AS923_JAPAN1:
Jason Reiss 28:c222ca8383f4 142 delete plan;
Jason Reiss 28:c222ca8383f4 143 plan = new lora::ChannelPlan_AS923_Japan1();
Jason Reiss 28:c222ca8383f4 144 break;
Jason Reiss 28:c222ca8383f4 145
Jason Reiss 28:c222ca8383f4 146 case lora::ChannelPlan::AS923_JAPAN2:
Jason Reiss 28:c222ca8383f4 147 delete plan;
Jason Reiss 28:c222ca8383f4 148 plan = new lora::ChannelPlan_AS923_Japan2();
Jason Reiss 28:c222ca8383f4 149 break;
Jason Reiss 28:c222ca8383f4 150
Jason Reiss 27:5fafd3b26ac3 151 case lora::ChannelPlan::IN865:
Jason Reiss 27:5fafd3b26ac3 152 delete plan;
Jason Reiss 27:5fafd3b26ac3 153 plan = new lora::ChannelPlan_IN865();
Jason Reiss 27:5fafd3b26ac3 154 break;
Jason Reiss 27:5fafd3b26ac3 155
Jason Reiss 27:5fafd3b26ac3 156 case lora::ChannelPlan::RU864:
Jason Reiss 27:5fafd3b26ac3 157 delete plan;
Jason Reiss 27:5fafd3b26ac3 158 plan = new lora::ChannelPlan_RU864();
Jason Reiss 27:5fafd3b26ac3 159 break;
Jason Reiss 27:5fafd3b26ac3 160
Jason Reiss 27:5fafd3b26ac3 161 default:
Jason Reiss 27:5fafd3b26ac3 162 logInfo("Default channel plan not valid Defaulting US915");
Jason Reiss 27:5fafd3b26ac3 163 delete plan;
Jason Reiss 27:5fafd3b26ac3 164 plan = new lora::ChannelPlan_US915();
Jason Reiss 27:5fafd3b26ac3 165 break;
Jason Reiss 27:5fafd3b26ac3 166 }
Jason Reiss 27:5fafd3b26ac3 167 dot->setChannelPlan(plan);
Jason Reiss 27:5fafd3b26ac3 168 #endif
Mike Fiore 9:ff62b20f7000 169 // Seed the RNG
Mike Fiore 9:ff62b20f7000 170 srand(dot->getRadioRandom());
Mike Fiore 9:ff62b20f7000 171
Mike Fiore 9:ff62b20f7000 172
Jason Reiss 28:c222ca8383f4 173 PinName rtsPin = NC;
Jason Reiss 28:c222ca8383f4 174 PinName ctsPin = NC;
Jason Reiss 28:c222ca8383f4 175 if (dot->getFlowControl()) {
Jason Reiss 28:c222ca8383f4 176 rtsPin = AT_RTS_PIN;
Jason Reiss 28:c222ca8383f4 177 ctsPin = AT_CTS_PIN;
Jason Reiss 28:c222ca8383f4 178 }
Jason Reiss 28:c222ca8383f4 179
Jason Reiss 28:c222ca8383f4 180 mts::ATSerial serial(AT_TX_PIN, AT_RX_PIN, rtsPin, ctsPin, dot->getBaud());
Mike Fiore 9:ff62b20f7000 181
jenkins@jenkinsdm1 18:63f098f042b2 182 debug_port.baud(dot->getDebugBaud());
Mike Fiore 9:ff62b20f7000 183
Jason Reiss 28:c222ca8383f4 184 CommandTerminal term(serial);
Mike Fiore 14:f9a77400b622 185 CommandTerminal::_dot = dot;
jenkins@jenkinsdm1 22:a13ac7df92c0 186
Jason Reiss 23:4f0a981c0349 187 Fota::getInstance(dot);
jenkins@jenkinsdm1 18:63f098f042b2 188
Mike Fiore 14:f9a77400b622 189 term.init();
Mike Fiore 9:ff62b20f7000 190
Mike Fiore 9:ff62b20f7000 191 term.start();
Mike Fiore 9:ff62b20f7000 192 }
Mike Fiore 14:f9a77400b622 193
Mike Fiore 14:f9a77400b622 194 #endif // UNIT_TEST
Jason Reiss 23:4f0a981c0349 195 #endif