AT command firmware for MultiTech Dot devices.

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdDebugBaudRate.cpp Source File

CmdDebugBaudRate.cpp

00001 #include "CmdDebugBaudRate.h"
00002 
00003 CmdDebugBaudRate::CmdDebugBaudRate() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Debug Baud Rate", "AT+DIPR", "Set debug serial baud rate, default: 115200", "(2400,4800,9600,19200,38400,57600,115200,230400,460800,921600)")
00006 #else
00007     Command("AT+DIPR")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdDebugBaudRate::action(const std::vector<std::string>& args)
00014 {
00015     if (args.size() == 1)
00016     {
00017         CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getDebugBaud());
00018     }
00019     else if (args.size() == 2)
00020     {
00021         int baudrate = 0;
00022 
00023         sscanf(args[1].c_str(), "%d", &baudrate);
00024 
00025         if (CommandTerminal::Dot()->setDebugBaud(baudrate) == mDot::MDOT_OK) {
00026 #if MTS_CMD_TERM_VERBOSE
00027             CommandTerminal::Serial()->writef("Set Debug Baud Rate: %d\r\n", baudrate);
00028 #endif
00029         } else {
00030             return 1;
00031         }
00032     }
00033 
00034     return 0;
00035 }
00036 
00037 bool CmdDebugBaudRate::verify(const std::vector<std::string>& args)
00038 {
00039     if (args.size() == 1)
00040         return true;
00041 
00042     if (args.size() == 2) {
00043         int baudrate;
00044 
00045         if (sscanf(args[1].c_str(), "%d", &baudrate) != 1) {
00046 #if MTS_CMD_TERM_VERBOSE
00047             CommandTerminal::setErrorMessage("Invalid argument");
00048 #endif
00049             return false;
00050         }
00051 
00052         return true;
00053     }
00054 
00055 #if MTS_CMD_TERM_VERBOSE
00056     CommandTerminal::setErrorMessage("Invalid arguments");
00057 #endif
00058     return false;
00059 }