AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
CmdJoinRx2Frequency.cpp
00001 #include "CmdJoinRx2Frequency.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdJoinRx2Frequency::CmdJoinRx2Frequency() : 00005 #if MTS_CMD_TERM_VERBOSE 00006 Command("Join Rx2 Frequency", "AT+JR2F", "Join Rx2 frequency", "(US:902000000-928000000,AU:915000000-928000000,EU:863000000-870000000)") 00007 #else 00008 Command("AT+JR2F") 00009 #endif 00010 { 00011 00012 } 00013 00014 uint32_t CmdJoinRx2Frequency::action(const std::vector<std::string>& args) { 00015 00016 if (args.size() == 1) 00017 { 00018 CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getJoinRx2Frequency()); 00019 } 00020 else if (args.size() == 2) 00021 { 00022 int frequency = 0; 00023 00024 sscanf(args[1].c_str(), "%d", &frequency); 00025 if (CommandTerminal::Dot()->setJoinRx2Frequency(frequency) != mDot::MDOT_OK) { 00026 return 1; 00027 } 00028 } 00029 00030 return 0; 00031 } 00032 00033 bool CmdJoinRx2Frequency::verify(const std::vector<std::string>& args) { 00034 if (args.size() == 1) 00035 return true; 00036 00037 if (args.size() == 2) { 00038 int frequency = ULONG_MAX; 00039 if (sscanf(args[1].c_str(), "%d", &frequency) != 1) { 00040 #if MTS_CMD_TERM_VERBOSE 00041 CommandTerminal::setErrorMessage("Invalid argument"); 00042 #endif 00043 return false; 00044 } 00045 00046 if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) { 00047 00048 #if MTS_CMD_TERM_VERBOSE 00049 char tmp[256]; 00050 sprintf(tmp, "Invalid frequency, expects (0,%" SCNu32 "-%" SCNu32 ")", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency()); 00051 CommandTerminal::setErrorMessage(tmp); 00052 #endif 00053 return false; 00054 } 00055 return true; 00056 } 00057 00058 #if MTS_CMD_TERM_VERBOSE 00059 CommandTerminal::setErrorMessage("Invalid arguments"); 00060 #endif 00061 return false; 00062 }
Generated on Wed Dec 6 2023 19:34:05 by 1.7.2