![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdTxChannel.cpp
- Revision:
- 16:d5cf2af81a6d
- Parent:
- 14:f9a77400b622
diff -r e20116281a78 -r d5cf2af81a6d CommandTerminal/CmdTxChannel.cpp --- a/CommandTerminal/CmdTxChannel.cpp Fri Nov 04 17:04:54 2016 -0500 +++ b/CommandTerminal/CmdTxChannel.cpp Mon Jun 19 14:33:21 2017 -0500 @@ -1,4 +1,5 @@ #include "CmdTxChannel.h" +#include "ChannelPlan.h" CmdTxChannel::CmdTxChannel() : Command("Tx Channels", "AT+TXCH", "List Tx channel frequencies for sub-band", "<INDEX>,<FREQUENCY>,<DR_RANGE>") { @@ -14,7 +15,7 @@ CommandTerminal::Serial()->writef("Index\tFrequency DR Max Min On\r\n"); - if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868) { + if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) { for (int8_t i = 0; i < 16; i++) { if (channels[i] != 0) 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); @@ -60,7 +61,10 @@ sscanf(args[2].c_str(), "%d", &frequency); sscanf(args[3].c_str(), "%02x", &datarateRange); - CommandTerminal::Dot()->addChannel(index, frequency, datarateRange); + if (CommandTerminal::Dot()->addChannel(index, frequency, datarateRange) != mDot::MDOT_OK) { + CommandTerminal::setErrorMessage("Failed to add channel"); + return 1; + } } return 0; @@ -80,18 +84,15 @@ sscanf(args[2].c_str(), "%d", &frequency); sscanf(args[3].c_str(), "%02x", &datarateRange); - if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868) { - if (index < 3 || index > 15) { - CommandTerminal::setErrorMessage("Invalid index, expects (3-15)"); - return false; - } - - if (frequency != 0 && (frequency < 863000000 || frequency > 870000000)) { - CommandTerminal::setErrorMessage("Invalid frequency, expects (863000000-870000000)"); + if (lora::ChannelPlan::IsPlanDynamic(CommandTerminal::Dot()->getFrequencyBand())) { + if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) { + char tmp[256]; + sprintf(tmp, "Invalid frequency, expects (0,%lu-%lu)", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency()); + CommandTerminal::setErrorMessage(tmp); return false; } } else { - CommandTerminal::setErrorMessage("US915|AU915 Channels cannot be changed, use AT+FSB or AT+CHM to limit"); + CommandTerminal::setErrorMessage("Fixed channel plans cannot be changed, use AT+FSB or AT+CHM to limit"); return false; }