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

CmdWakeDelay.cpp

00001 #include "CmdWakeDelay.h"
00002 
00003 CmdWakeDelay::CmdWakeDelay() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Wake Delay", "AT+WD", "Time to wait for data after wakeup signal  (milliseconds)", "(2-2147483646) ms")
00006 #else
00007     Command("AT+WD")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdWakeDelay::action(const std::vector<std::string>& args)
00014 {
00015     if (args.size() == 1)
00016     {
00017         CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getWakeDelay());
00018     }
00019     else if (args.size() == 2)
00020     {
00021         int delay;
00022         sscanf(args[1].c_str(), "%d", &delay);
00023 
00024         if (CommandTerminal::Dot()->setWakeDelay(delay) != mDot::MDOT_OK) {
00025             return 1;
00026         }
00027     }
00028 
00029     return 0;
00030 }
00031 
00032 bool CmdWakeDelay::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 delay;
00040         if (sscanf(args[1].c_str(), "%d", &delay) != 1) {
00041 #if MTS_CMD_TERM_VERBOSE
00042             CommandTerminal::setErrorMessage("Invalid argument");
00043 #endif
00044             return false;
00045         }
00046 
00047         if (delay < 2 || delay > INT_MAX-1) {
00048 #if MTS_CMD_TERM_VERBOSE
00049             CommandTerminal::setErrorMessage("Invalid delay, expects (2-2147483646) 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 }