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. 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.
Stable library for mDot.
xDot Library
Development library for xDot.
Stable library for xDot.
CommandTerminal/CmdTxChannel.cpp@33:5c0252521669, 2021-01-29 (annotated)
- Committer:
- Jason Reiss
- Date:
- Fri Jan 29 13:04:32 2021 -0600
- Revision:
- 33:5c0252521669
- Parent:
- 28:c222ca8383f4
- Child:
- 36:b586cd6e91f3
Remove moved commands
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdTxChannel.h" |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 2 | #include "ChannelPlan.h" |
Mike Fiore |
1:e52ae6584f1c | 3 | |
Jason Reiss |
28:c222ca8383f4 | 4 | namespace { |
Jason Reiss |
28:c222ca8383f4 | 5 | void parseArgs(const std::vector<std::string>& args, int& index, int& frequency, int& datarateRange) { |
Jason Reiss |
28:c222ca8383f4 | 6 | sscanf(args[1].c_str(), "%d", &index); |
Jason Reiss |
28:c222ca8383f4 | 7 | sscanf(args[2].c_str(), "%d", &frequency); |
Jason Reiss |
28:c222ca8383f4 | 8 | sscanf(args[3].c_str(), "%02x", &datarateRange); |
Jason Reiss |
28:c222ca8383f4 | 9 | } |
Jason Reiss |
28:c222ca8383f4 | 10 | |
Jason Reiss |
28:c222ca8383f4 | 11 | |
Jason Reiss |
28:c222ca8383f4 | 12 | void printChannel(const char* name, uint32_t channel, uint8_t range_max, uint8_t range_min, int16_t on) { |
Jason Reiss |
28:c222ca8383f4 | 13 | #if MTS_CMD_TERM_VERBOSE |
Jason Reiss |
28:c222ca8383f4 | 14 | if (on != -1) { |
Jason Reiss |
28:c222ca8383f4 | 15 | CommandTerminal::Serial()->writef(" %-6s%9d%7X%4X%5d\r\n", name, channel, range_max, range_min, on); |
Jason Reiss |
28:c222ca8383f4 | 16 | } else { |
Jason Reiss |
28:c222ca8383f4 | 17 | CommandTerminal::Serial()->writef(" %-6s%9d%7X%4X\r\n", name, channel, range_max, range_min); |
Jason Reiss |
28:c222ca8383f4 | 18 | } |
Jason Reiss |
27:5fafd3b26ac3 | 19 | #else |
Jason Reiss |
28:c222ca8383f4 | 20 | CommandTerminal::Serial()->writef("%s,%d,%X,%X,%d\r\n", name, channel, range_max, range_min, on); |
Jason Reiss |
27:5fafd3b26ac3 | 21 | #endif |
Jason Reiss |
28:c222ca8383f4 | 22 | } |
Jason Reiss |
28:c222ca8383f4 | 23 | |
Jason Reiss |
28:c222ca8383f4 | 24 | void assignName(char* name, int i) { |
Jason Reiss |
28:c222ca8383f4 | 25 | if (i > 9) { |
Jason Reiss |
28:c222ca8383f4 | 26 | int t = i - (i % 10); |
Jason Reiss |
28:c222ca8383f4 | 27 | name[0] = '0' + (t / 10); |
Jason Reiss |
28:c222ca8383f4 | 28 | name[1] = '0' + (i - t); |
Jason Reiss |
28:c222ca8383f4 | 29 | } else { |
Jason Reiss |
28:c222ca8383f4 | 30 | name[0] = i + '0'; |
Jason Reiss |
28:c222ca8383f4 | 31 | name[1] = '\0'; |
Jason Reiss |
28:c222ca8383f4 | 32 | } |
Jason Reiss |
28:c222ca8383f4 | 33 | } |
Jason Reiss |
28:c222ca8383f4 | 34 | |
Jason Reiss |
28:c222ca8383f4 | 35 | } // namespace |
Jason Reiss |
28:c222ca8383f4 | 36 | |
Jason Reiss |
28:c222ca8383f4 | 37 | CmdTxChannel::CmdTxChannel() : |
Jason Reiss |
28:c222ca8383f4 | 38 | #if MTS_CMD_TERM_VERBOSE |
Jason Reiss |
28:c222ca8383f4 | 39 | Command("Tx Channels", "AT+TXCH", "List Tx channel frequencies for sub-band", "<INDEX>,<FREQUENCY>,<DR_RANGE>") |
Jason Reiss |
28:c222ca8383f4 | 40 | #else |
Jason Reiss |
28:c222ca8383f4 | 41 | Command("AT+TXCH") |
Jason Reiss |
28:c222ca8383f4 | 42 | #endif |
Jason Reiss |
28:c222ca8383f4 | 43 | { |
Mike Fiore |
1:e52ae6584f1c | 44 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 45 | } |
Mike Fiore |
1:e52ae6584f1c | 46 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 47 | uint32_t CmdTxChannel::action(const std::vector<std::string>& args) { |
Mike Fiore |
1:e52ae6584f1c | 48 | if (args.size() == 1) { |
Mike Fiore |
14:f9a77400b622 | 49 | |
Mike Fiore |
14:f9a77400b622 | 50 | std::vector<uint32_t> channels = CommandTerminal::Dot()->getChannels(); |
Mike Fiore |
14:f9a77400b622 | 51 | std::vector<uint8_t> ranges = CommandTerminal::Dot()->getChannelRanges(); |
Mike Fiore |
14:f9a77400b622 | 52 | std::vector<uint16_t> mask = CommandTerminal::Dot()->getChannelMask(); |
Mike Fiore |
14:f9a77400b622 | 53 | |
Jason Reiss |
28:c222ca8383f4 | 54 | //channelProps props { "\0\0", 0, 0, 0, 0 }; |
Jason Reiss |
28:c222ca8383f4 | 55 | char name[3] = "\0\0"; |
Jason Reiss |
28:c222ca8383f4 | 56 | uint32_t channel; |
Jason Reiss |
28:c222ca8383f4 | 57 | uint8_t range_max; |
Jason Reiss |
28:c222ca8383f4 | 58 | uint8_t range_min; |
Jason Reiss |
28:c222ca8383f4 | 59 | int16_t on; |
Jason Reiss |
28:c222ca8383f4 | 60 | |
Jason Reiss |
28:c222ca8383f4 | 61 | #if MTS_CMD_TERM_VERBOSE |
Mike Fiore |
14:f9a77400b622 | 62 | CommandTerminal::Serial()->writef("Index\tFrequency DR Max Min On\r\n"); |
Jason Reiss |
28:c222ca8383f4 | 63 | #endif |
Mike Fiore |
1:e52ae6584f1c | 64 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 65 | if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) { |
Jason Reiss |
28:c222ca8383f4 | 66 | for (int8_t i = 0; i < 17; i++) { |
Jason Reiss |
28:c222ca8383f4 | 67 | channel = channels[i]; |
Jason Reiss |
28:c222ca8383f4 | 68 | range_max = ranges[i] >> 4; |
Jason Reiss |
28:c222ca8383f4 | 69 | range_min = ranges[i] & 0xF; |
Jason Reiss |
28:c222ca8383f4 | 70 | if (i == 16) { |
Jason Reiss |
28:c222ca8383f4 | 71 | name[0] = 'R'; |
Jason Reiss |
28:c222ca8383f4 | 72 | name[1] = '2'; |
Jason Reiss |
28:c222ca8383f4 | 73 | on = -1; |
Jason Reiss |
28:c222ca8383f4 | 74 | if (channels[16] == 0) { |
Jason Reiss |
28:c222ca8383f4 | 75 | range_max = ranges[16]; |
Jason Reiss |
28:c222ca8383f4 | 76 | range_min = ranges[168]; |
Jason Reiss |
28:c222ca8383f4 | 77 | } |
Jason Reiss |
28:c222ca8383f4 | 78 | } else { |
Jason Reiss |
28:c222ca8383f4 | 79 | assignName(name, i); |
Jason Reiss |
28:c222ca8383f4 | 80 | channel = channels[i]; |
Jason Reiss |
28:c222ca8383f4 | 81 | if (channels[i] != 0) { |
Jason Reiss |
28:c222ca8383f4 | 82 | on = (mask[0] & (0x1 << i)) ? 1 : 0; |
Mike Fiore |
14:f9a77400b622 | 83 | } else { |
Jason Reiss |
28:c222ca8383f4 | 84 | on = 0; |
Mike Fiore |
14:f9a77400b622 | 85 | } |
Mike Fiore |
14:f9a77400b622 | 86 | } |
Jason Reiss |
28:c222ca8383f4 | 87 | |
Jason Reiss |
28:c222ca8383f4 | 88 | printChannel(name, channel, range_max, range_min, on); |
Jason Reiss |
28:c222ca8383f4 | 89 | } |
Jason Reiss |
28:c222ca8383f4 | 90 | } else { |
Jason Reiss |
28:c222ca8383f4 | 91 | uint8_t sub_band = CommandTerminal::Dot()->getFrequencySubBand(); |
Jason Reiss |
28:c222ca8383f4 | 92 | if (sub_band > 0) { |
Jason Reiss |
28:c222ca8383f4 | 93 | uint8_t offset = (sub_band - 1) * 8; |
Mike Fiore |
14:f9a77400b622 | 94 | |
Jason Reiss |
28:c222ca8383f4 | 95 | for (int i = 0; i < 10; i++) { |
Jason Reiss |
28:c222ca8383f4 | 96 | channel = channels[i]; |
Jason Reiss |
28:c222ca8383f4 | 97 | if (i == 9) { |
Jason Reiss |
28:c222ca8383f4 | 98 | name[0] = 'R'; |
Jason Reiss |
28:c222ca8383f4 | 99 | name[1] = '2'; |
Jason Reiss |
28:c222ca8383f4 | 100 | range_max = ranges[i]; |
Jason Reiss |
28:c222ca8383f4 | 101 | range_min = ranges[i]; |
Jason Reiss |
28:c222ca8383f4 | 102 | on = -1; |
Jason Reiss |
28:c222ca8383f4 | 103 | } else { |
Jason Reiss |
28:c222ca8383f4 | 104 | if (i == 8) { |
Jason Reiss |
28:c222ca8383f4 | 105 | name[0] = 'U'; |
Jason Reiss |
28:c222ca8383f4 | 106 | on = (mask[4] & (0x0001 << (sub_band - 1))) ? 1 : 0; |
Jason Reiss |
28:c222ca8383f4 | 107 | } else { |
Jason Reiss |
28:c222ca8383f4 | 108 | assignName(name, i); |
Jason Reiss |
28:c222ca8383f4 | 109 | if ((sub_band % 2) == 1) { |
Jason Reiss |
28:c222ca8383f4 | 110 | on = (mask[(offset + i)/16] & (0x0001 << i)) ? 1 : 0; |
Jason Reiss |
28:c222ca8383f4 | 111 | } else { |
Jason Reiss |
28:c222ca8383f4 | 112 | on = (mask[(offset + i)/16] & (0x0001 << (i + 8))) ? 1 : 0; |
Jason Reiss |
28:c222ca8383f4 | 113 | } |
Jason Reiss |
28:c222ca8383f4 | 114 | } |
Jason Reiss |
28:c222ca8383f4 | 115 | range_max = ranges[i] >> 4; |
Jason Reiss |
28:c222ca8383f4 | 116 | range_min = ranges[i] & 0xF; |
Jason Reiss |
28:c222ca8383f4 | 117 | } |
Jason Reiss |
28:c222ca8383f4 | 118 | printChannel(name, channel, range_max, range_min, on); |
Jason Reiss |
28:c222ca8383f4 | 119 | } |
Mike Fiore |
14:f9a77400b622 | 120 | } else { |
Jason Reiss |
28:c222ca8383f4 | 121 | for (size_t i = 0; i < channels.size(); i++) { |
Jason Reiss |
28:c222ca8383f4 | 122 | channel = channels[i]; |
Jason Reiss |
28:c222ca8383f4 | 123 | if (i == channels.size() - 1) { |
Jason Reiss |
28:c222ca8383f4 | 124 | name[0] = 'R'; |
Jason Reiss |
28:c222ca8383f4 | 125 | name[1] = '2'; |
Jason Reiss |
28:c222ca8383f4 | 126 | range_max = ranges[i]; |
Jason Reiss |
28:c222ca8383f4 | 127 | range_min = ranges[i]; |
Jason Reiss |
28:c222ca8383f4 | 128 | on = -1; |
Jason Reiss |
28:c222ca8383f4 | 129 | } else { |
Jason Reiss |
28:c222ca8383f4 | 130 | assignName(name, i); |
Jason Reiss |
28:c222ca8383f4 | 131 | range_max = ranges[i] >> 4; |
Jason Reiss |
28:c222ca8383f4 | 132 | range_min = ranges[i] & 0xF; |
Jason Reiss |
28:c222ca8383f4 | 133 | on = (mask[i/16] & (0x0001 << (i%16))) ? 1 : 0; |
Jason Reiss |
28:c222ca8383f4 | 134 | } |
Jason Reiss |
28:c222ca8383f4 | 135 | printChannel(name, channel, range_max, range_min, on); |
Mike Fiore |
14:f9a77400b622 | 136 | } |
Mike Fiore |
9:ff62b20f7000 | 137 | } |
Mike Fiore |
1:e52ae6584f1c | 138 | } |
Mike Fiore |
1:e52ae6584f1c | 139 | } |
Mike Fiore |
1:e52ae6584f1c | 140 | |
Mike Fiore |
9:ff62b20f7000 | 141 | if (args.size() == 4) { |
Mike Fiore |
9:ff62b20f7000 | 142 | int index; |
Mike Fiore |
9:ff62b20f7000 | 143 | int frequency; |
Mike Fiore |
9:ff62b20f7000 | 144 | int datarateRange; |
Mike Fiore |
9:ff62b20f7000 | 145 | |
Jason Reiss |
28:c222ca8383f4 | 146 | parseArgs(args, index, frequency, datarateRange); |
Mike Fiore |
9:ff62b20f7000 | 147 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 148 | if (CommandTerminal::Dot()->addChannel(index, frequency, datarateRange) != mDot::MDOT_OK) { |
Jason Reiss |
28:c222ca8383f4 | 149 | #if MTS_CMD_TERM_VERBOSE |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 150 | CommandTerminal::setErrorMessage("Failed to add channel"); |
Jason Reiss |
28:c222ca8383f4 | 151 | #endif |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 152 | return 1; |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 153 | } |
Mike Fiore |
9:ff62b20f7000 | 154 | } |
Mike Fiore |
9:ff62b20f7000 | 155 | |
Mike Fiore |
1:e52ae6584f1c | 156 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 157 | } |
Mike Fiore |
1:e52ae6584f1c | 158 | |
jenkins@jenkinsdm1 | 18:63f098f042b2 | 159 | bool CmdTxChannel::verify(const std::vector<std::string>& args) { |
Mike Fiore |
9:ff62b20f7000 | 160 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 161 | return true; |
Mike Fiore |
9:ff62b20f7000 | 162 | |
Jason Reiss |
28:c222ca8383f4 | 163 | |
Mike Fiore |
9:ff62b20f7000 | 164 | if (args.size() == 4) { |
Mike Fiore |
9:ff62b20f7000 | 165 | |
Mike Fiore |
9:ff62b20f7000 | 166 | int index; |
Mike Fiore |
9:ff62b20f7000 | 167 | int frequency; |
Mike Fiore |
9:ff62b20f7000 | 168 | int datarateRange; |
Mike Fiore |
9:ff62b20f7000 | 169 | |
Jason Reiss |
28:c222ca8383f4 | 170 | parseArgs(args, index, frequency, datarateRange); |
Mike Fiore |
9:ff62b20f7000 | 171 | |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 172 | if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) { |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 173 | if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) { |
Jason Reiss |
28:c222ca8383f4 | 174 | #if MTS_CMD_TERM_VERBOSE |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 175 | char tmp[256]; |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 176 | sprintf(tmp, "Invalid frequency, expects (0,%lu-%lu)", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency()); |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 177 | CommandTerminal::setErrorMessage(tmp); |
Jason Reiss |
28:c222ca8383f4 | 178 | #endif |
Mike Fiore |
9:ff62b20f7000 | 179 | return false; |
Mike Fiore |
9:ff62b20f7000 | 180 | } |
Mike Fiore |
9:ff62b20f7000 | 181 | } else { |
Jason Reiss |
28:c222ca8383f4 | 182 | #if MTS_CMD_TERM_VERBOSE |
jenkins@jenkinsdm1 | 16:d5cf2af81a6d | 183 | CommandTerminal::setErrorMessage("Fixed channel plans cannot be changed, use AT+FSB or AT+CHM to limit"); |
Jason Reiss |
28:c222ca8383f4 | 184 | #endif |
Mike Fiore |
9:ff62b20f7000 | 185 | return false; |
Mike Fiore |
9:ff62b20f7000 | 186 | } |
Mike Fiore |
9:ff62b20f7000 | 187 | |
Mike Fiore |
9:ff62b20f7000 | 188 | return true; |
Mike Fiore |
9:ff62b20f7000 | 189 | } else { |
Jason Reiss |
28:c222ca8383f4 | 190 | #if MTS_CMD_TERM_VERBOSE |
Mike Fiore |
14:f9a77400b622 | 191 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Jason Reiss |
28:c222ca8383f4 | 192 | #endif |
Mike Fiore |
9:ff62b20f7000 | 193 | return false; |
Mike Fiore |
9:ff62b20f7000 | 194 | } |
Mike Fiore |
9:ff62b20f7000 | 195 | |
Mike Fiore |
9:ff62b20f7000 | 196 | } |