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
CmdTxFrequency.cpp
00001 #include "CmdTxFrequency.h" 00002 #include <climits> 00003 00004 00005 CmdTxFrequency::CmdTxFrequency() : 00006 Command("Tx Frequency", "AT+TXF", "Set Tx frequency", "US:(0,902000000-928000000), AU:(0, 915000000-928000000), EU:(0,863000000-870000000)") { 00007 _queryable = true; 00008 } 00009 00010 uint32_t CmdTxFrequency::action(std::vector<std::string> args) 00011 { 00012 if (args.size() == 1) 00013 { 00014 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getTxFrequency()); 00015 } 00016 else if (args.size() == 2) 00017 { 00018 int frequency = 0; 00019 00020 sscanf(args[1].c_str(), "%d", &frequency); 00021 if (CommandTerminal::Dot()->setTxFrequency(frequency) != mDot::MDOT_OK) 00022 { 00023 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00024 return 1; 00025 } 00026 } 00027 00028 return 0; 00029 } 00030 00031 bool CmdTxFrequency::verify(std::vector<std::string> args) 00032 { 00033 if (args.size() == 1) 00034 return true; 00035 00036 if (args.size() == 2) 00037 { 00038 int frequency = ULONG_MAX; 00039 if (sscanf(args[1].c_str(), "%d", &frequency) != 1) { 00040 CommandTerminal::setErrorMessage("Invalid argument"); 00041 return false; 00042 } 00043 00044 if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) { 00045 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868) 00046 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,863000000-870000000)"); 00047 else if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_AU915) 00048 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,915000000-928000000)"); 00049 else 00050 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,902000000-928000000)"); 00051 00052 return false; 00053 } 00054 00055 return true; 00056 } 00057 00058 CommandTerminal::setErrorMessage("Invalid arguments"); 00059 return false; 00060 } 00061
Generated on Tue Jul 12 2022 20:40:04 by
