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
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 std::string dr = mts::Text::toUpper(args[1]); 00047 00048 uint8_t i; 00049 int datarate = -1; 00050 00051 int res = sscanf(dr.c_str(), "%d", &datarate); 00052 00053 if (res == 0) { 00054 for (i = 0; i < 16; i++) { 00055 if (mDot::DataRateStr(i).find(dr) != std::string::npos) { 00056 datarate = i; 00057 break; 00058 } 00059 } 00060 } 00061 00062 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_US915 || CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_AU915) { 00063 // DR8-13 used for P2P modes 00064 if (datarate < 8 || datarate > 13) { 00065 CommandTerminal::setErrorMessage("Invalid data rate, expects (DR8-DR13)"); 00066 return false; 00067 } 00068 } else { 00069 if (datarate < 0 || datarate > 7) { 00070 CommandTerminal::setErrorMessage("Invalid data rate, expects (DR0-DR7)"); 00071 return false; 00072 } 00073 } 00074 00075 return true; 00076 } 00077 00078 CommandTerminal::setErrorMessage("Invalid arguments"); 00079 return false; 00080 }
Generated on Tue Jul 12 2022 20:40:03 by
