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 libxDot-mbed5
CmdJoinRx2Datarate.cpp
00001 #include "CmdJoinRx2Datarate.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdJoinRx2Datarate::CmdJoinRx2Datarate() 00005 : 00006 Command("Join Rx2 Datarate", "AT+JR2D", "Join Rx2 datarate", "(US:DR8-DR13,AU:DR8-DR13,EU:DR0-DR7)") { 00007 00008 } 00009 00010 uint32_t CmdJoinRx2Datarate::action(std::vector<std::string> args) { 00011 00012 if (args.size() == 1) { 00013 CommandTerminal::Serial()->writef("%s\r\n", mDot::DataRateStr(CommandTerminal::Dot()->getJoinRx2DataRate()).c_str()); 00014 } 00015 else if (args.size() == 2) { 00016 std::string dr = mts::Text::toUpper(args[1]); 00017 00018 int datarate = 0; 00019 uint8_t i; 00020 00021 int res = sscanf(dr.c_str(), "%d", &datarate); 00022 00023 if (res == 0) { 00024 for (i = 0; i < 16; i++) { 00025 if (mDot::DataRateStr(i).find(dr) != std::string::npos) { 00026 datarate = i; 00027 break; 00028 } 00029 } 00030 } 00031 00032 if (CommandTerminal::Dot()->setJoinRx2DataRate(datarate) != mDot::MDOT_OK) { 00033 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); 00034 return 1; 00035 } 00036 } 00037 00038 return 0; 00039 } 00040 00041 bool CmdJoinRx2Datarate::verify(std::vector<std::string> args) { 00042 if (args.size() == 1) 00043 return true; 00044 00045 if (args.size() == 2) { 00046 return true; 00047 } 00048 00049 CommandTerminal::setErrorMessage("Invalid arguments"); 00050 return false; 00051 }
Generated on Tue Jul 12 2022 23:49:49 by
