AT command firmware for MultiTech Dot devices.

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdRxFrequency.cpp Source File

CmdRxFrequency.cpp

00001 #include "CmdRxFrequency.h"
00002 
00003 CmdRxFrequency::CmdRxFrequency() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Rx Frequency", "AT+RXF", "Set the Rx frequency for +RECV,+RECVC", "SEE PLAN")
00006 #else
00007     Command("AT+RXF")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdRxFrequency::action(const std::vector<std::string>& args) {
00014     if (args.size() == 1) {
00015         CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getRxFrequency());
00016     }
00017     else if (args.size() == 2)
00018              {
00019 
00020         int frequency = 0;
00021         sscanf(args[1].c_str(), "%d", &frequency);
00022         if (CommandTerminal::Dot()->setRxFrequency(frequency) != mDot::MDOT_OK) {
00023             return 1;
00024         }
00025     }
00026 
00027     return 0;
00028 }
00029 
00030 bool CmdRxFrequency::verify(const std::vector<std::string>& args) {
00031     if (args.size() == 1)
00032         return true;
00033 
00034     if (args.size() == 2)
00035         {
00036         int frequency;
00037         if (sscanf(args[1].c_str(), "%d", &frequency) != 1) {
00038 #if MTS_CMD_TERM_VERBOSE
00039             CommandTerminal::setErrorMessage("Invalid argument");
00040 #endif
00041             return false;
00042         }
00043 
00044         if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) {
00045 #if MTS_CMD_TERM_VERBOSE
00046             char tmp[256];
00047             sprintf(tmp, "Invalid frequency, expects (0,%" SCNu32 "-%" SCNu32 ")", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency());
00048             CommandTerminal::setErrorMessage(tmp);
00049 #endif
00050             return false;
00051         }
00052 
00053         return true;
00054     }
00055 
00056 #if MTS_CMD_TERM_VERBOSE
00057     CommandTerminal::setErrorMessage("Invalid arguments");
00058 #endif
00059     return false;
00060 }