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 mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
CmdTxChannel.cpp
00001 #include "CmdTxChannel.h" 00002 00003 CmdTxChannel::CmdTxChannel(mDot* dot, mts::MTSSerial& serial) 00004 : 00005 Command(dot, "Tx Channels", "AT+TXCH", "List Tx channel frequencies for sub-band"), 00006 _serial(serial) { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "<INDEX>,<FREQUENCY>,<DR_RANGE>"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdTxChannel::action(std::vector<std::string> args) { 00013 if (args.size() == 1) { 00014 std::vector<uint32_t> channels = _dot->getChannels(); 00015 00016 if (_dot->getFrequencyBand() == mDot::FB_868) { 00017 for (int i = 0; i < 16; i++) { 00018 _serial.writef("%d: %d 125k\r\n", i, channels[i]); 00019 } 00020 _serial.writef("D: %d 125k\r\n", channels[8]); 00021 00022 } else { 00023 00024 for (int i = 0; i < 8; i++) { 00025 _serial.writef("%d: %d 125k\r\n", i, channels[i]); 00026 } 00027 00028 _serial.writef("U: %d 500k\r\n", channels[8]); 00029 _serial.writef("D: %d 500k\r\n", channels[9]); 00030 } 00031 } 00032 00033 if (args.size() == 4) { 00034 int index; 00035 int frequency; 00036 int datarateRange; 00037 00038 sscanf(args[1].c_str(), "%d", &index); 00039 sscanf(args[2].c_str(), "%d", &frequency); 00040 sscanf(args[3].c_str(), "%02x", &datarateRange); 00041 00042 _dot->addChannel(index, frequency, datarateRange); 00043 } 00044 00045 return 0; 00046 } 00047 00048 bool CmdTxChannel::verify(std::vector<std::string> args) { 00049 if (args.size() == 1) 00050 return true; 00051 00052 if (args.size() == 4) { 00053 00054 int index; 00055 int frequency; 00056 int datarateRange; 00057 00058 sscanf(args[1].c_str(), "%d", &index); 00059 sscanf(args[2].c_str(), "%d", &frequency); 00060 sscanf(args[3].c_str(), "%02x", &datarateRange); 00061 00062 if (_dot->getFrequencyBand() == mDot::FB_868) { 00063 if (index < 3 || index > 15) { 00064 setErrorMessage("Invalid index, expects (3-15)"); 00065 return false; 00066 } 00067 00068 if (frequency != 0 && (frequency < 863000000 || frequency > 870000000)) { 00069 setErrorMessage("Invalid frequency, expects (863000000-870000000)"); 00070 return false; 00071 } 00072 } else { 00073 setErrorMessage("US915 Channels cannot be changed, use AT+FSB to limit"); 00074 return false; 00075 } 00076 00077 return true; 00078 } else { 00079 setErrorMessage("Invalid arguments"); 00080 return false; 00081 } 00082 00083 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
