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
CmdJoinRx1Offset.cpp
00001 #include "CmdJoinRx1Offset.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdJoinRx1Offset::CmdJoinRx1Offset() 00005 : 00006 Command("Join Rx1 DR Offset", "AT+JRXO", "Join Rx1 datarate offset", "(US:0-3,AU:0-3,EU:0-5)") { 00007 00008 } 00009 00010 uint32_t CmdJoinRx1Offset::action(std::vector<std::string> args) { 00011 00012 if (args.size() == 1) { 00013 CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getJoinRx1DataRateOffset()); 00014 } 00015 else if (args.size() == 2) { 00016 std::string dr = mts::Text::toUpper(args[1]); 00017 00018 int offset = 0; 00019 sscanf(dr.c_str(), "%d", &offset); 00020 00021 if (CommandTerminal::Dot()->setJoinRx1DataRateOffset(offset) != mDot::MDOT_OK) { 00022 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00023 return 1; 00024 } 00025 } 00026 00027 return 0; 00028 } 00029 00030 bool CmdJoinRx1Offset::verify(std::vector<std::string> args) { 00031 if (args.size() == 1) 00032 return true; 00033 00034 if (args.size() == 2) { 00035 std::string dr = mts::Text::toUpper(args[1]); 00036 00037 int offset = -1; 00038 sscanf(dr.c_str(), "%d", &offset); 00039 00040 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_US915 || CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_AU915) { 00041 if (offset < 0 || offset > 3) { 00042 CommandTerminal::setErrorMessage("Invalid offset, expects (0-3)"); 00043 return false; 00044 } 00045 } else { 00046 if (offset < 0 || offset > 5) { 00047 CommandTerminal::setErrorMessage("Invalid offset, expects (0-5)"); 00048 return false; 00049 } 00050 } 00051 00052 return true; 00053 } 00054 00055 CommandTerminal::setErrorMessage("Invalid arguments"); 00056 return false; 00057 }
Generated on Tue Jul 12 2022 20:40:03 by
