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

Stable library for mDot.

libmDot

xDot Library

Development library for xDot.

libxDot-dev

Stable library for xDot.

libxDot

Committer:
Jason Reiss
Date:
Fri Sep 11 13:16:33 2020 -0500
Revision:
27:5fafd3b26ac3
Parent:
18:63f098f042b2
Child:
28:c222ca8383f4
Update to Dot 3.3.6

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:e52ae6584f1c 1 #include "CmdTxChannel.h"
jenkins@jenkinsdm1 16:d5cf2af81a6d 2 #include "ChannelPlan.h"
Mike Fiore 1:e52ae6584f1c 3
Mike Fiore 14:f9a77400b622 4 CmdTxChannel::CmdTxChannel()
Jason Reiss 27:5fafd3b26ac3 5 : Command("Tx Channels", "AT+TXCH",
Jason Reiss 27:5fafd3b26ac3 6 #if defined(TARGET_MTS_MDOT_F411RE)
Jason Reiss 27:5fafd3b26ac3 7 "List Tx channel frequencies for sub-band",
Jason Reiss 27:5fafd3b26ac3 8 #else
Jason Reiss 27:5fafd3b26ac3 9 "",
Jason Reiss 27:5fafd3b26ac3 10 #endif
Jason Reiss 27:5fafd3b26ac3 11 "<INDEX>,<FREQUENCY>,<DR_RANGE>") {
Mike Fiore 1:e52ae6584f1c 12 _queryable = true;
Mike Fiore 1:e52ae6584f1c 13 }
Mike Fiore 1:e52ae6584f1c 14
jenkins@jenkinsdm1 18:63f098f042b2 15 uint32_t CmdTxChannel::action(const std::vector<std::string>& args) {
Mike Fiore 1:e52ae6584f1c 16 if (args.size() == 1) {
Mike Fiore 14:f9a77400b622 17
Mike Fiore 14:f9a77400b622 18 std::vector<uint32_t> channels = CommandTerminal::Dot()->getChannels();
Mike Fiore 14:f9a77400b622 19 std::vector<uint8_t> ranges = CommandTerminal::Dot()->getChannelRanges();
Mike Fiore 14:f9a77400b622 20 std::vector<uint16_t> mask = CommandTerminal::Dot()->getChannelMask();
Mike Fiore 14:f9a77400b622 21
Mike Fiore 14:f9a77400b622 22 CommandTerminal::Serial()->writef("Index\tFrequency DR Max Min On\r\n");
Mike Fiore 1:e52ae6584f1c 23
jenkins@jenkinsdm1 16:d5cf2af81a6d 24 if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) {
Mike Fiore 14:f9a77400b622 25 for (int8_t i = 0; i < 16; i++) {
Mike Fiore 14:f9a77400b622 26 if (channels[i] != 0)
Mike Fiore 14:f9a77400b622 27 CommandTerminal::Serial()->writef(" %d\t%d %X %X %d\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF, (mask[0] & (0x1 << i)) ? 1 : 0);
Mike Fiore 14:f9a77400b622 28 else
Mike Fiore 14:f9a77400b622 29 CommandTerminal::Serial()->writef(" %d\t %d %X %X 0\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF);
Mike Fiore 9:ff62b20f7000 30 }
Mike Fiore 14:f9a77400b622 31
Mike Fiore 14:f9a77400b622 32 if (channels[16] != 0)
Mike Fiore 14:f9a77400b622 33 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[16], ranges[16] >> 4, ranges[16] & 0xF);
Mike Fiore 14:f9a77400b622 34 else
Mike Fiore 14:f9a77400b622 35 CommandTerminal::Serial()->writef(" R2\t %d %X %X\r\n", channels[16], ranges[16], ranges[168]);
Mike Fiore 1:e52ae6584f1c 36
Mike Fiore 1:e52ae6584f1c 37 } else {
Mike Fiore 14:f9a77400b622 38 if (CommandTerminal::Dot()->getFrequencySubBand() > 0) {
Mike Fiore 14:f9a77400b622 39 uint8_t offset = (CommandTerminal::Dot()->getFrequencySubBand() - 1) * 8;
Mike Fiore 9:ff62b20f7000 40
Mike Fiore 14:f9a77400b622 41 for (int i = 0; i < 8; i++) {
Mike Fiore 14:f9a77400b622 42 if ((CommandTerminal::Dot()->getFrequencySubBand() % 2) == 1) {
Mike Fiore 14:f9a77400b622 43 CommandTerminal::Serial()->writef(" %d\t%d %X %X %d\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF, (mask[(offset + i)/16] & (0x0001 << i)) ? 1 : 0);
Mike Fiore 14:f9a77400b622 44 } else {
Mike Fiore 14:f9a77400b622 45 CommandTerminal::Serial()->writef(" %d\t%d %X %X %d\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF, (mask[(offset + i)/16] & (0x0001 << (i + 8))) ? 1 : 0);
Mike Fiore 14:f9a77400b622 46 }
Mike Fiore 14:f9a77400b622 47 }
Mike Fiore 14:f9a77400b622 48
Mike Fiore 14:f9a77400b622 49 CommandTerminal::Serial()->writef(" U\t%d %X %X %d\r\n", channels[8], ranges[8] >> 4, ranges[8] & 0xF, (mask[4] & (0x0001 << (CommandTerminal::Dot()->getFrequencySubBand() - 1))) ? 1 : 0);
Mike Fiore 14:f9a77400b622 50 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[9], ranges[9], ranges[9]);
Mike Fiore 14:f9a77400b622 51 } else {
Mike Fiore 14:f9a77400b622 52 for (size_t i = 0; i < channels.size() - 1; i++) {
Mike Fiore 14:f9a77400b622 53 CommandTerminal::Serial()->writef(" %d\t%d %X %X %d\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF, (mask[i/16] & (0x0001 << (i%16))) ? 1 : 0);
Mike Fiore 14:f9a77400b622 54 }
Mike Fiore 14:f9a77400b622 55 uint8_t last = channels.size() - 1;
Mike Fiore 14:f9a77400b622 56 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[last], ranges[last], ranges[last]);
Mike Fiore 9:ff62b20f7000 57 }
Mike Fiore 1:e52ae6584f1c 58 }
Mike Fiore 1:e52ae6584f1c 59 }
Mike Fiore 1:e52ae6584f1c 60
Mike Fiore 9:ff62b20f7000 61 if (args.size() == 4) {
Mike Fiore 9:ff62b20f7000 62 int index;
Mike Fiore 9:ff62b20f7000 63 int frequency;
Mike Fiore 9:ff62b20f7000 64 int datarateRange;
Mike Fiore 9:ff62b20f7000 65
Mike Fiore 9:ff62b20f7000 66 sscanf(args[1].c_str(), "%d", &index);
Mike Fiore 9:ff62b20f7000 67 sscanf(args[2].c_str(), "%d", &frequency);
Mike Fiore 9:ff62b20f7000 68 sscanf(args[3].c_str(), "%02x", &datarateRange);
Mike Fiore 9:ff62b20f7000 69
jenkins@jenkinsdm1 16:d5cf2af81a6d 70 if (CommandTerminal::Dot()->addChannel(index, frequency, datarateRange) != mDot::MDOT_OK) {
jenkins@jenkinsdm1 16:d5cf2af81a6d 71 CommandTerminal::setErrorMessage("Failed to add channel");
jenkins@jenkinsdm1 16:d5cf2af81a6d 72 return 1;
jenkins@jenkinsdm1 16:d5cf2af81a6d 73 }
Mike Fiore 9:ff62b20f7000 74 }
Mike Fiore 9:ff62b20f7000 75
Mike Fiore 1:e52ae6584f1c 76 return 0;
Mike Fiore 1:e52ae6584f1c 77 }
Mike Fiore 1:e52ae6584f1c 78
jenkins@jenkinsdm1 18:63f098f042b2 79 bool CmdTxChannel::verify(const std::vector<std::string>& args) {
Mike Fiore 9:ff62b20f7000 80 if (args.size() == 1)
Mike Fiore 9:ff62b20f7000 81 return true;
Mike Fiore 9:ff62b20f7000 82
Mike Fiore 9:ff62b20f7000 83 if (args.size() == 4) {
Mike Fiore 9:ff62b20f7000 84
Mike Fiore 9:ff62b20f7000 85 int index;
Mike Fiore 9:ff62b20f7000 86 int frequency;
Mike Fiore 9:ff62b20f7000 87 int datarateRange;
Mike Fiore 9:ff62b20f7000 88
Mike Fiore 9:ff62b20f7000 89 sscanf(args[1].c_str(), "%d", &index);
Mike Fiore 9:ff62b20f7000 90 sscanf(args[2].c_str(), "%d", &frequency);
Mike Fiore 9:ff62b20f7000 91 sscanf(args[3].c_str(), "%02x", &datarateRange);
Mike Fiore 9:ff62b20f7000 92
jenkins@jenkinsdm1 16:d5cf2af81a6d 93 if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) {
jenkins@jenkinsdm1 16:d5cf2af81a6d 94 if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) {
jenkins@jenkinsdm1 16:d5cf2af81a6d 95 char tmp[256];
jenkins@jenkinsdm1 16:d5cf2af81a6d 96 sprintf(tmp, "Invalid frequency, expects (0,%lu-%lu)", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency());
jenkins@jenkinsdm1 16:d5cf2af81a6d 97 CommandTerminal::setErrorMessage(tmp);
Mike Fiore 9:ff62b20f7000 98 return false;
Mike Fiore 9:ff62b20f7000 99 }
Mike Fiore 9:ff62b20f7000 100 } else {
jenkins@jenkinsdm1 16:d5cf2af81a6d 101 CommandTerminal::setErrorMessage("Fixed channel plans cannot be changed, use AT+FSB or AT+CHM to limit");
Mike Fiore 9:ff62b20f7000 102 return false;
Mike Fiore 9:ff62b20f7000 103 }
Mike Fiore 9:ff62b20f7000 104
Mike Fiore 9:ff62b20f7000 105 return true;
Mike Fiore 9:ff62b20f7000 106 } else {
Mike Fiore 14:f9a77400b622 107 CommandTerminal::setErrorMessage("Invalid arguments");
Mike Fiore 9:ff62b20f7000 108 return false;
Mike Fiore 9:ff62b20f7000 109 }
Mike Fiore 9:ff62b20f7000 110
Mike Fiore 9:ff62b20f7000 111 }