Custom Channel Plan version of MTDOT Box firmware
Dependencies: DOGS102 GpsParser ISL29011 MMA845x MPL3115A2 MTS-Serial NCP5623B libmDot-Custom mDot_Channel_Plans
Fork of MTDOT-BOX-EVB-Factory-Firmware by
CmdTxDataRate.cpp
00001 /* Copyright (c) <2016> <MultiTech Systems>, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 #include "CmdTxDataRate.h" 00019 #include "MTSText.h" 00020 #include "MTSLog.h" 00021 00022 CmdTxDataRate::CmdTxDataRate(mDot* dot, mts::MTSSerial& serial) 00023 : 00024 Command(dot, "Tx Data Rate", "AT+TXDR", "Set the Tx data rate for all channels"), 00025 _serial(serial) 00026 { 00027 _help = std::string(text()) + ": " + std::string(desc()); 00028 _queryable = true; 00029 } 00030 00031 uint32_t CmdTxDataRate::action(std::vector<std::string> args) { 00032 if (args.size() == 1) 00033 { 00034 if (_dot->getVerbose()) 00035 _serial.writef("Tx Data Rate: "); 00036 00037 _serial.writef("DR%d - %s\r\n", _dot->getTxDataRate(), _dot->getDateRateDetails(_dot->getTxDataRate()).c_str()); 00038 } else if (args.size() == 2) { 00039 std::string dr = mts::Text::toUpper(args[1]); 00040 int32_t code; 00041 int datarate = -1; 00042 uint8_t i; 00043 00044 int res = sscanf(dr.c_str(), "%d", &datarate); 00045 00046 if (res == 0) { 00047 for (i = 0; i < 24; i++) { 00048 if (mDot::DataRateStr(i).find(dr) != std::string::npos) { 00049 datarate = i; 00050 break; 00051 } 00052 } 00053 } 00054 00055 if ((code = _dot->setTxDataRate(datarate)) != mDot::MDOT_OK) { 00056 setErrorMessage(_dot->getLastError()); 00057 return 1; 00058 } 00059 } 00060 00061 return 0; 00062 } 00063 00064 bool CmdTxDataRate::verify(std::vector<std::string> args) { 00065 if (args.size() == 1) 00066 return true; 00067 00068 if (args.size() == 2) { 00069 std::string dr = mts::Text::toUpper(args[1]); 00070 00071 uint8_t i; 00072 int datarate = -1; 00073 00074 int res = sscanf(dr.c_str(), "%d", &datarate); 00075 00076 if (res == 0) { 00077 for (i = 0; i < 24; i++) { 00078 00079 if (mDot::DataRateStr(i).find(dr) != std::string::npos) { 00080 uint8_t _dr = i; 00081 datarate = _dr; 00082 break; 00083 } 00084 } 00085 } 00086 00087 return true; 00088 } 00089 00090 setErrorMessage("Invalid arguments"); 00091 return false; 00092 }
Generated on Tue Jul 12 2022 13:07:49 by 1.7.2