Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CmdTxChannel.cpp
00001 #include "CmdTxChannel.h" 00002 00003 CmdTxChannel::CmdTxChannel() 00004 : Command("Tx Channels", "AT+TXCH", "List Tx channel frequencies for sub-band", "<INDEX>,<FREQUENCY>,<DR_RANGE>") { 00005 _queryable = true; 00006 } 00007 00008 uint32_t CmdTxChannel::action(std::vector<std::string> args) { 00009 if (args.size() == 1) { 00010 00011 std::vector<uint32_t> channels = CommandTerminal::Dot()->getChannels(); 00012 std::vector<uint8_t> ranges = CommandTerminal::Dot()->getChannelRanges(); 00013 std::vector<uint16_t> mask = CommandTerminal::Dot()->getChannelMask(); 00014 00015 CommandTerminal::Serial()->writef("Index\tFrequency DR Max Min On\r\n"); 00016 00017 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868) { 00018 for (int8_t i = 0; i < 16; i++) { 00019 if (channels[i] != 0) 00020 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); 00021 else 00022 CommandTerminal::Serial()->writef(" %d\t %d %X %X 0\r\n", i, channels[i], ranges[i] >> 4, ranges[i] & 0xF); 00023 } 00024 00025 if (channels[16] != 0) 00026 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[16], ranges[16] >> 4, ranges[16] & 0xF); 00027 else 00028 CommandTerminal::Serial()->writef(" R2\t %d %X %X\r\n", channels[16], ranges[16], ranges[168]); 00029 00030 } else { 00031 if (CommandTerminal::Dot()->getFrequencySubBand() > 0) { 00032 uint8_t offset = (CommandTerminal::Dot()->getFrequencySubBand() - 1) * 8; 00033 00034 for (int i = 0; i < 8; i++) { 00035 if ((CommandTerminal::Dot()->getFrequencySubBand() % 2) == 1) { 00036 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); 00037 } else { 00038 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); 00039 } 00040 } 00041 00042 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); 00043 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[9], ranges[9], ranges[9]); 00044 } else { 00045 for (size_t i = 0; i < channels.size() - 1; i++) { 00046 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); 00047 } 00048 uint8_t last = channels.size() - 1; 00049 CommandTerminal::Serial()->writef(" R2\t%d %X %X\r\n", channels[last], ranges[last], ranges[last]); 00050 } 00051 } 00052 } 00053 00054 if (args.size() == 4) { 00055 int index; 00056 int frequency; 00057 int datarateRange; 00058 00059 sscanf(args[1].c_str(), "%d", &index); 00060 sscanf(args[2].c_str(), "%d", &frequency); 00061 sscanf(args[3].c_str(), "%02x", &datarateRange); 00062 00063 CommandTerminal::Dot()->addChannel(index, frequency, datarateRange); 00064 } 00065 00066 return 0; 00067 } 00068 00069 bool CmdTxChannel::verify(std::vector<std::string> args) { 00070 if (args.size() == 1) 00071 return true; 00072 00073 if (args.size() == 4) { 00074 00075 int index; 00076 int frequency; 00077 int datarateRange; 00078 00079 sscanf(args[1].c_str(), "%d", &index); 00080 sscanf(args[2].c_str(), "%d", &frequency); 00081 sscanf(args[3].c_str(), "%02x", &datarateRange); 00082 00083 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868) { 00084 if (index < 3 || index > 15) { 00085 CommandTerminal::setErrorMessage("Invalid index, expects (3-15)"); 00086 return false; 00087 } 00088 00089 if (frequency != 0 && (frequency < 863000000 || frequency > 870000000)) { 00090 CommandTerminal::setErrorMessage("Invalid frequency, expects (863000000-870000000)"); 00091 return false; 00092 } 00093 } else { 00094 CommandTerminal::setErrorMessage("US915|AU915 Channels cannot be changed, use AT+FSB or AT+CHM to limit"); 00095 return false; 00096 } 00097 00098 return true; 00099 } else { 00100 CommandTerminal::setErrorMessage("Invalid arguments"); 00101 return false; 00102 } 00103 00104 }
Generated on Tue Jul 12 2022 20:40:04 by
