few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CmdWakeTimeout.cpp
00001 #include "CmdWakeTimeout.h" 00002 00003 CmdWakeTimeout::CmdWakeTimeout(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Wake Timeout", "AT+WTO", "Read serial data until timeout (milliseconds)"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 _usage = "(0-65000) ms"; 00008 _queryable = true; 00009 } 00010 00011 uint32_t CmdWakeTimeout::action(std::vector<std::string> args) 00012 { 00013 if (args.size() == 1) 00014 { 00015 if (_dot->getVerbose()) 00016 _serial.writef("%s: ", name()); 00017 00018 _serial.writef("%lu\r\n", _dot->getWakeTimeout()); 00019 } 00020 else if (args.size() == 2) 00021 { 00022 int32_t code; 00023 int timeout; 00024 sscanf(args[1].c_str(), "%d", &timeout); 00025 00026 if ((code = _dot->setWakeTimeout(timeout)) != mDot::MDOT_OK) { 00027 00028 setErrorMessage(_dot->getLastError());; 00029 return 1; 00030 } 00031 } 00032 00033 return 0; 00034 } 00035 00036 bool CmdWakeTimeout::verify(std::vector<std::string> args) 00037 { 00038 if (args.size() == 1) 00039 return true; 00040 00041 if (args.size() == 2) 00042 { 00043 int timeout; 00044 if (sscanf(args[1].c_str(), "%d", &timeout) != 1) { 00045 setErrorMessage("Invalid argument"); 00046 return false; 00047 } 00048 00049 if (timeout < 0 || timeout > 65000) { 00050 setErrorMessage("Invalid timeout, expects (0-65000) ms"); 00051 return false; 00052 } 00053 00054 return true; 00055 } 00056 00057 setErrorMessage("Invalid arguments"); 00058 return false; 00059 }
Generated on Tue Jul 12 2022 16:01:24 by 1.7.2