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 CmdRxDelay.cpp Source File

CmdRxDelay.cpp

00001 /*
00002  * CmdRxDelay.cpp
00003  *
00004  *  Created on: Nov 4, 2015
00005  *      Author: jreiss
00006  */
00007 
00008 #include "CmdRxDelay.h"
00009 
00010 CmdRxDelay::CmdRxDelay() :
00011 #if MTS_CMD_TERM_VERBOSE
00012     Command("Rx Delay", "AT+RXD", "Number of seconds before receive windows are opened (1 - 15)", "(1-15)")
00013 #else
00014     Command("AT+RXD")
00015 #endif
00016 {
00017     _queryable = true;
00018 }
00019 
00020 CmdRxDelay::~CmdRxDelay()
00021 {
00022     // TODO Auto-generated destructor stub
00023 }
00024 
00025 uint32_t CmdRxDelay::action(const std::vector<std::string>& args) {
00026     if (args.size() == 1) {
00027         CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getRxDelay());
00028     } else if (args.size() == 2) {
00029 
00030         int rxDelay;
00031         sscanf(args[1].c_str(), "%d", &rxDelay);
00032 
00033         if (CommandTerminal::Dot()->setRxDelay(rxDelay) != mDot::MDOT_OK) {
00034             return 1;
00035         }
00036     }
00037     return 0;
00038 }
00039 
00040 bool CmdRxDelay::verify(const std::vector<std::string>& args) {
00041     if (args.size() == 1)
00042         return true;
00043 
00044     if (args.size() == 2) {
00045 
00046         int rxDelay;
00047         if (sscanf(args[1].c_str(), "%d", &rxDelay) == 1) {
00048 
00049             if (rxDelay > 15 || rxDelay < 1) {
00050 #if MTS_CMD_TERM_VERBOSE
00051                 CommandTerminal::setErrorMessage("Invalid rx delay, expects (1-15)");
00052 #endif
00053                 return false;
00054             }
00055 
00056             return true;
00057         }
00058     }
00059 
00060 #if MTS_CMD_TERM_VERBOSE
00061     CommandTerminal::setErrorMessage("Invalid arguments");
00062 #endif
00063     return false;
00064 }