Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libxDot-dev-mbed5-deprecated
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdWakeTimeout.cpp
- Revision:
- 4:666017851052
- Child:
- 9:ff62b20f7000
diff -r 1ee9417f6707 -r 666017851052 CommandTerminal/CmdWakeTimeout.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/CommandTerminal/CmdWakeTimeout.cpp Tue Aug 18 11:21:43 2015 -0500
@@ -0,0 +1,59 @@
+#include "CmdWakeTimeout.h"
+
+CmdWakeTimeout::CmdWakeTimeout(mDot* dot, mts::MTSSerial& serial) :
+ Command(dot, "Wake Timeout", "AT+WTO", "Read serial data until timeout (milliseconds)"), _serial(serial)
+{
+ _help = std::string(text()) + ": " + std::string(desc());
+ _usage = "(0-65000) ms";
+ _queryable = true;
+}
+
+uint32_t CmdWakeTimeout::action(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ {
+ if (_dot->getVerbose())
+ _serial.writef("%s: ", name());
+
+ _serial.writef("%lu\r\n", _dot->getWakeTimeout());
+ }
+ else if (args.size() == 2)
+ {
+ int32_t code;
+ uint32_t timeout;
+ sscanf(args[1].c_str(), "%lu", &timeout);
+
+ if ((code = _dot->setWakeTimeout(timeout)) != mDot::MDOT_OK) {
+ std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError();
+ setErrorMessage(error);
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+bool CmdWakeTimeout::verify(std::vector<std::string> args)
+{
+ if (args.size() == 1)
+ return true;
+
+ if (args.size() == 2)
+ {
+ uint32_t timeout;
+ if (sscanf(args[1].c_str(), "%lu", &timeout) != 1) {
+ setErrorMessage("Invalid argument");
+ return false;
+ }
+
+ if (timeout < 0 || timeout > 65000) {
+ setErrorMessage("Invalid timeout, expects (0-65000) ms");
+ return false;
+ }
+
+ return true;
+ }
+
+ setErrorMessage("Invalid arguments");
+ return false;
+}
