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 CmdRxOutput.cpp Source File

CmdRxOutput.cpp

00001 #include "CmdRxOutput.h"
00002 
00003 CmdRxOutput::CmdRxOutput() :
00004         Command("Rx Output", "AT+RXO", "Set the Rx output type (0:hexadecimal, 1:raw)", "(0,1)")
00005 {
00006     _queryable = true;
00007 }
00008 
00009 uint32_t CmdRxOutput::action(std::vector<std::string> args)
00010 {
00011     if (args.size() == 1)
00012     {
00013         CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getRxOutput());
00014     }
00015     else if (args.size() == 2)
00016     {
00017         
00018         uint8_t output = args[1] == "0" ? 0 : 1;
00019         if (CommandTerminal::Dot()->setRxOutput(output) != mDot::MDOT_OK)
00020         {
00021             
00022             CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
00023             return 1;
00024         }
00025     }
00026 
00027     return 0;
00028 }
00029 
00030 bool CmdRxOutput::verify(std::vector<std::string> args)
00031 {
00032     if (args.size() == 1)
00033         return true;
00034 
00035     if (args.size() == 2)
00036     {
00037         if (!(args[1] == "0" || args[1] == "1")) {
00038             CommandTerminal::setErrorMessage("Invalid type, expects (0:hexadecimal, 1:raw)");
00039             return false;
00040         }
00041 
00042         return true;
00043     }
00044 
00045     CommandTerminal::setErrorMessage("Invalid arguments");
00046     return false;
00047 }