AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
CmdWakeInterval.cpp
00001 #include "CmdWakeInterval.h" 00002 00003 CmdWakeInterval::CmdWakeInterval() : 00004 #if MTS_CMD_TERM_VERBOSE 00005 Command("Wake Interval", "AT+WI", "Wakeup interval (seconds)", "(2-2147483646) s") 00006 #else 00007 Command("AT+WI") 00008 #endif 00009 { 00010 _queryable = true; 00011 } 00012 00013 uint32_t CmdWakeInterval::action(const std::vector<std::string>& args) 00014 { 00015 if (args.size() == 1) 00016 { 00017 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getWakeInterval()); 00018 } 00019 else if (args.size() == 2) 00020 { 00021 int timeout; 00022 sscanf(args[1].c_str(), "%d", &timeout); 00023 00024 if (CommandTerminal::Dot()->setWakeInterval(timeout) != mDot::MDOT_OK) { 00025 return 1; 00026 } 00027 } 00028 00029 return 0; 00030 } 00031 00032 bool CmdWakeInterval::verify(const std::vector<std::string>& args) 00033 { 00034 if (args.size() == 1) 00035 return true; 00036 00037 if (args.size() == 2) { 00038 int timeout; 00039 if (sscanf(args[1].c_str(), "%d", &timeout) != 1) { 00040 #if MTS_CMD_TERM_VERBOSE 00041 CommandTerminal::setErrorMessage("Invalid argument"); 00042 #endif 00043 return false; 00044 } 00045 00046 if (timeout < 2 || timeout > INT_MAX-1) { 00047 #if MTS_CMD_TERM_VERBOSE 00048 CommandTerminal::setErrorMessage("Invalid interval, expects (2-2147483646) s"); 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 }
Generated on Wed Dec 6 2023 19:34:05 by 1.7.2