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

CmdWakeTimeout.cpp

00001 #include "CmdWakeTimeout.h"
00002 
00003 CmdWakeTimeout::CmdWakeTimeout() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Wake Timeout", "AT+WTO", "Read serial data until timeout (milliseconds)", "(0-65000) ms")
00006 #else
00007     Command("AT+WTO")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdWakeTimeout::action(const std::vector<std::string>& args)
00014 {
00015     if (args.size() == 1)
00016     {
00017         CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getWakeTimeout());
00018     }
00019     else if (args.size() == 2)
00020     {
00021         int timeout;
00022         sscanf(args[1].c_str(), "%d", &timeout);
00023 
00024         if (CommandTerminal::Dot()->setWakeTimeout(timeout) != mDot::MDOT_OK) {
00025             return 1;
00026         }
00027     }
00028 
00029     return 0;
00030 }
00031 
00032 bool CmdWakeTimeout::verify(const std::vector<std::string>& args)
00033 {
00034     if (args.size() == 1)
00035         return true;
00036 
00037     if (args.size() == 2)
00038     {
00039         int timeout;
00040         if (sscanf(args[1].c_str(), "%d", &timeout) != 1) {
00041 #if MTS_CMD_TERM_VERBOSE
00042             CommandTerminal::setErrorMessage("Invalid argument");
00043 #endif
00044             return false;
00045         }
00046 
00047         if (timeout < 0 || timeout > 65000) {
00048 #if MTS_CMD_TERM_VERBOSE
00049             CommandTerminal::setErrorMessage("Invalid timeout, expects (0-65000) ms");
00050 #endif
00051             return false;
00052         }
00053 
00054         return true;
00055     }
00056 
00057 #if MTS_CMD_TERM_VERBOSE
00058     CommandTerminal::setErrorMessage("Invalid arguments");
00059 #endif
00060     return false;
00061 }