MicroLabo / Mbed OS mbed-Dot-AT-Firmware

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdSerialClearOnError.cpp Source File

CmdSerialClearOnError.cpp

00001 #include "CmdSerialClearOnError.h"
00002 
00003 CmdSerialClearOnError::CmdSerialClearOnError() :
00004         Command("Clear On Error", "AT+SDCE", "Serial clear on error if enabled data that cannot be sent will be discarded", "(0:off,1:on)")
00005 {
00006     _queryable = true;
00007 }
00008 
00009 uint32_t CmdSerialClearOnError::action(std::vector<std::string> args)
00010 {
00011     if (args.size() == 1)
00012     {
00013         CommandTerminal::Serial()->writef("%d\r\n", CommandTerminal::Dot()->getSerialClearOnError());
00014     }
00015     else if (args.size() == 2)
00016     {
00017         bool enable = (args[1] == "1");
00018 
00019         if (CommandTerminal::Dot()->setSerialClearOnError(enable) != mDot::MDOT_OK) {
00020             CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());
00021             return 1;
00022         }
00023     }
00024 
00025     return 0;
00026 }
00027 
00028 bool CmdSerialClearOnError::verify(std::vector<std::string> args)
00029 {
00030     if (args.size() == 1)
00031         return true;
00032 
00033     if (args.size() == 2) {
00034         if (args[1] != "1" && args[1] != "0") {
00035             CommandTerminal::setErrorMessage("Invalid parameter, expects (0: off, 1: on)");
00036             return false;
00037         }
00038 
00039         return true;
00040     }
00041 
00042     CommandTerminal::setErrorMessage("Invalid arguments");
00043     return false;
00044 }