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
Fork of mDot_USB_AT_firmware by
CmdACKAttempts.cpp
00001 #include "CmdACKAttempts.h" 00002 00003 CmdACKAttempts::CmdACKAttempts(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Require ACK", "AT+ACK", "Enable to require send acknowledgement (0: off, N: number of attempts until ACK recevied)"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 _usage = "(0-8)"; 00008 _queryable = true; 00009 } 00010 00011 uint32_t CmdACKAttempts::action(std::vector<std::string> args) 00012 { 00013 if (args.size() == 1) 00014 { 00015 if (_dot->getVerbose()) 00016 _serial.writef("ACK Attempts: "); 00017 00018 _serial.writef("%u\r\n", _dot->getAck()); 00019 } 00020 else if (args.size() == 2) 00021 { 00022 int32_t code; 00023 int retries; 00024 sscanf(args[1].c_str(), "%d", &retries); 00025 00026 if ((code = _dot->setAck(retries)) != mDot::MDOT_OK) 00027 { 00028 setErrorMessage(_dot->getLastError()); 00029 return 1; 00030 } 00031 } 00032 00033 return 0; 00034 } 00035 00036 bool CmdACKAttempts::verify(std::vector<std::string> args) 00037 { 00038 if (args.size() == 1) 00039 return true; 00040 00041 if (args.size() == 2) 00042 { 00043 int retries; 00044 if (sscanf(args[1].c_str(), "%d", &retries) != 1) { 00045 setErrorMessage("Invalid argument"); 00046 return false; 00047 } 00048 00049 if (retries < 0 || retries > 8) { 00050 setErrorMessage("Invalid attempts, expects (0-8)"); 00051 return false; 00052 } 00053 00054 return true; 00055 } 00056 00057 setErrorMessage("Invalid arguments"); 00058 return false; 00059 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
