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

CmdClassCTimeout.cpp

00001 #include "CmdClassCTimeout.h"
00002 
00003 CmdClassCTimeout::CmdClassCTimeout() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Class C Timeout", "AT+CTO", "Set the timeout the network expects an ACK sent for a confirmed downlink received in a Class C window", "(0-120)")
00006 #else
00007     Command("AT+CTO")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdClassCTimeout::action(const std::vector<std::string>& args)
00014 {
00015     mDot* dot = CommandTerminal::Dot();
00016     if (args.size() == 1) {
00017         CommandTerminal::Serial()->writef("%" SCNu32 "\r\n", dot->getClassCTimeout());
00018     } else if (args.size() == 2) {
00019         uint32_t timeout;
00020         sscanf(args[1].c_str(), "%" SCNu32, &timeout);
00021 
00022         if (dot->setClassCTimeout(static_cast<uint8_t>(timeout)) != mDot::MDOT_OK) {
00023             return 1;
00024         }
00025     }
00026 
00027     return 0;
00028 }
00029 
00030 bool CmdClassCTimeout::verify(const std::vector<std::string>& args)
00031 {
00032     if (args.size() == 1)
00033         return true;
00034 
00035     if (args.size() == 2) {
00036         uint32_t timeout;
00037         if (sscanf(args[1].c_str(), "%" SCNu32, &timeout) == 1) {
00038             if (timeout > 120) {
00039 #if MTS_CMD_TERM_VERBOSE
00040                 CommandTerminal::setErrorMessage("Invalid timeout, expects (0-120)");
00041 #endif
00042                 return false;
00043             }
00044 
00045             return true;
00046         }
00047     }
00048 
00049 #if MTS_CMD_TERM_VERBOSE
00050     CommandTerminal::setErrorMessage("Invalid arguments");
00051 #endif
00052     return false;
00053 }