few changes for RTS/CTS control

Dependencies:   MTS-Serial libmDot mbed-rtos mbed

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdErrorCorrection.cpp Source File

CmdErrorCorrection.cpp

00001 #include "CmdErrorCorrection.h"
00002 
00003 CmdErrorCorrection::CmdErrorCorrection(mDot* dot, mts::MTSSerial& serial) :
00004         Command(dot, "Error Correction", "AT+FEC", "Configure Forward Error Correction bytes (1 to 4)"), _serial(serial)
00005 {
00006     _help = std::string(text()) + ": " + std::string(desc());
00007     _usage = "(1-4)";
00008     _queryable = true;
00009 }
00010 
00011 uint32_t CmdErrorCorrection::action(std::vector<std::string> args)
00012 {
00013     if (args.size() == 1)
00014     {
00015         if (_dot->getVerbose())
00016             _serial.writef("Error Correction Bytes: ");
00017 
00018         _serial.writef("%u\r\n", _dot->getFec());
00019     }
00020     else if (args.size() == 2)
00021     {
00022         int32_t code;
00023         uint32_t bytes;
00024         sscanf(args[1].c_str(), "%lu", &bytes);
00025 
00026         if ((code = _dot->setFec(bytes)) != mDot::MDOT_OK)
00027         {
00028             
00029             setErrorMessage(_dot->getLastError());;
00030             return 1;
00031         }
00032     }
00033 
00034     return 0;
00035 }
00036 
00037 bool CmdErrorCorrection::verify(std::vector<std::string> args)
00038 {
00039     if (args.size() == 1)
00040         return true;
00041 
00042     if (args.size() == 2)
00043     {
00044         int retries;
00045         if (sscanf(args[1].c_str(), "%d", &retries) != 1) {
00046             setErrorMessage("Invalid argument");
00047             return false;
00048         }
00049 
00050         if (retries < 1 || retries > 4)
00051         {
00052             setErrorMessage("Invalid bytes, expects (1-4)");
00053             return false;
00054         }
00055 
00056         return true;
00057     }
00058 
00059     setErrorMessage("Invalid arguments");
00060     return false;
00061 }