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-src
Fork of mDot_AT_firmware by
CmdAdaptiveDataRate.cpp
00001 #include "CmdAdaptiveDataRate.h" 00002 00003 00004 CmdAdaptiveDataRate::CmdAdaptiveDataRate(mDot* dot, mts::MTSSerial& serial) : 00005 Command(dot, "Adaptive Data Rate", "AT+ADR", "Enable/disable Adaptive Data Rate (0: off, 1: on)"), _serial(serial) 00006 { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "(0,1)"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdAdaptiveDataRate::action(std::vector<std::string> args) 00013 { 00014 if (args.size() == 1) 00015 { 00016 if (_dot->getVerbose()) 00017 _serial.writef("Adaptive Data Rate: "); 00018 00019 _serial.writef("%d\r\n", _dot->getAdr()); 00020 } 00021 else if (args.size() == 2) 00022 { 00023 int32_t code; 00024 bool enable = (args[1] == "1"); 00025 if ((code = _dot->setAdr(enable)) != mDot::MDOT_OK) 00026 { 00027 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00028 setErrorMessage(error); 00029 return 1; 00030 } 00031 } 00032 00033 return 0; 00034 } 00035 00036 bool CmdAdaptiveDataRate::verify(std::vector<std::string> args) 00037 { 00038 if (args.size() == 1) 00039 return true; 00040 00041 if (args.size() == 2) 00042 { 00043 if (args[1] != "1" && args[1] != "0") { 00044 setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); 00045 return false; 00046 } 00047 00048 return true; 00049 } 00050 00051 setErrorMessage("Invalid arguments"); 00052 return false; 00053 }
Generated on Tue Jul 12 2022 21:40:57 by
1.7.2
