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 libmDot mbed-rtos mbed-src
Fork of mDot_AT_firmware by
CmdSerialWakeDelay.cpp
00001 #include "CmdSerialWakeDelay.h" 00002 00003 CmdSerialWakeDelay::CmdSerialWakeDelay(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Serial Wake Delay", "AT+SDWD", "Time to wait for data after wakeup signal (milliseconds)"), 00005 _serial(serial) 00006 { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "(2-2147483647) ms"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdSerialWakeDelay::action(std::vector<std::string> args) 00013 { 00014 if (args.size() == 1) 00015 { 00016 if (_dot->getVerbose()) 00017 _serial.writef("%s: ", name()); 00018 00019 _serial.writef("%lu\r\n", _dot->getSerialWakeDelay()); 00020 } 00021 else if (args.size() == 2) 00022 { 00023 int32_t code; 00024 uint32_t delay; 00025 sscanf(args[1].c_str(), "%lu", &delay); 00026 00027 if ((code = _dot->setSerialWakeDelay(delay)) != mDot::MDOT_OK) { 00028 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00029 setErrorMessage(error); 00030 return 1; 00031 } 00032 } 00033 00034 return 0; 00035 } 00036 00037 bool CmdSerialWakeDelay::verify(std::vector<std::string> args) 00038 { 00039 if (args.size() == 1) 00040 return true; 00041 00042 if (args.size() == 2) 00043 { 00044 uint32_t delay; 00045 if (sscanf(args[1].c_str(), "%lu", &delay) != 1) { 00046 setErrorMessage("Invalid argument"); 00047 return false; 00048 } 00049 00050 if (delay < 2 || delay > INT_MAX) { 00051 setErrorMessage("Invalid delay, expects (2-2147483647) ms"); 00052 return false; 00053 } 00054 00055 return true; 00056 } 00057 00058 setErrorMessage("Invalid arguments"); 00059 return false; 00060 }
Generated on Tue Jul 12 2022 21:40:57 by
1.7.2
