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-mbed5
Fork of Dot-AT-Firmware by
CmdErrorCorrection.cpp
00001 #include "CmdErrorCorrection.h" 00002 00003 CmdErrorCorrection::CmdErrorCorrection() : 00004 Command("Error Correction", "AT+FEC", "Configure Forward Error Correction bytes (1 to 4)", "(1-4)") 00005 { 00006 _queryable = true; 00007 } 00008 00009 uint32_t CmdErrorCorrection::action(std::vector<std::string> args) 00010 { 00011 if (args.size() == 1) 00012 { 00013 CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getFec()); 00014 } 00015 else if (args.size() == 2) 00016 { 00017 uint32_t bytes; 00018 sscanf(args[1].c_str(), "%lu", &bytes); 00019 00020 if (CommandTerminal::Dot()->setFec(bytes) != mDot::MDOT_OK) 00021 { 00022 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00023 return 1; 00024 } 00025 } 00026 00027 return 0; 00028 } 00029 00030 bool CmdErrorCorrection::verify(std::vector<std::string> args) 00031 { 00032 if (args.size() == 1) 00033 return true; 00034 00035 if (args.size() == 2) 00036 { 00037 int retries; 00038 if (sscanf(args[1].c_str(), "%d", &retries) != 1) { 00039 CommandTerminal::setErrorMessage("Invalid argument"); 00040 return false; 00041 } 00042 00043 if (retries < 1 || retries > 4) 00044 { 00045 CommandTerminal::setErrorMessage("Invalid bytes, expects (1-4)"); 00046 return false; 00047 } 00048 00049 return true; 00050 } 00051 00052 CommandTerminal::setErrorMessage("Invalid arguments"); 00053 return false; 00054 }
Generated on Tue Jul 12 2022 20:40:03 by
