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:
jenkins@jenkinsdm1
Date:
Fri Mar 08 11:37:37 2019 -0600
Revision:
18:63f098f042b2
Parent:
16:d5cf2af81a6d
Child:
27:5fafd3b26ac3
mdot-firmware revision 3.1.0

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