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
CmdTxPower.cpp
00001 #include "CmdTxPower.h" 00002 00003 CmdTxPower::CmdTxPower() : 00004 Command("Tx Power", "AT+TXP", "Set the radio TX power before antenna gain in dBm", "(0-30)") { 00005 _queryable = true; 00006 } 00007 00008 uint32_t CmdTxPower::action(std::vector<std::string> args) 00009 { 00010 if (args.size() == 1) 00011 { 00012 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getTxPower()); 00013 } 00014 else if (args.size() == 2) 00015 { 00016 int power = 0; 00017 sscanf(args[1].c_str(), "%d", &power); 00018 00019 if (CommandTerminal::Dot()->setTxPower(power) != mDot::MDOT_OK) 00020 { 00021 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00022 return 1; 00023 } 00024 } 00025 00026 return 0; 00027 } 00028 00029 bool CmdTxPower::verify(std::vector<std::string> args) 00030 { 00031 if (args.size() == 1) 00032 return true; 00033 00034 if (args.size() == 2) 00035 { 00036 int power = 0; 00037 if (sscanf(args[1].c_str(), "%d", &power) != 1) { 00038 CommandTerminal::setErrorMessage("Invalid argument"); 00039 return false; 00040 } 00041 00042 if (power < 0 || power > 30) 00043 { 00044 CommandTerminal::setErrorMessage("Invalid power, expects (0-30)"); 00045 return false; 00046 } 00047 00048 return true; 00049 } 00050 00051 CommandTerminal::setErrorMessage("Invalid arguments"); 00052 return false; 00053 } 00054
Generated on Tue Jul 12 2022 20:40:04 by
