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
CmdSerialBaudRate.cpp
00001 #include "CmdSerialBaudRate.h" 00002 00003 CmdSerialBaudRate::CmdSerialBaudRate() : 00004 #if defined(TARGET_MTS_MDOT_F411RE) 00005 Command("Serial Baud Rate", "AT+IPR", "Set serial baud rate, default: 115200 ", "(1200,2400,4800,9600,19200,38400,57600,115200,230400,460800,921600)") 00006 #else 00007 Command("Serial Baud Rate", "AT+IPR", "Set serial baud rate, default: 115200 ", "(1200,2400,4800,9600,19200,38400,57600,115200,230400)") 00008 #endif 00009 { 00010 _queryable = true; 00011 } 00012 00013 uint32_t CmdSerialBaudRate::action(std::vector<std::string> args) 00014 { 00015 if (args.size() == 1) 00016 { 00017 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getBaud()); 00018 } 00019 else if (args.size() == 2) 00020 { 00021 00022 int baudrate = 0; 00023 00024 sscanf(args[1].c_str(), "%d", &baudrate); 00025 00026 if (CommandTerminal::Dot()->setBaud(baudrate) == mDot::MDOT_OK) { 00027 CommandTerminal::Serial()->writef("Set Serial Baud Rate: %lu\r\n", baudrate); 00028 } else { 00029 00030 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00031 return 1; 00032 } 00033 } 00034 00035 return 0; 00036 } 00037 00038 bool CmdSerialBaudRate::verify(std::vector<std::string> args) 00039 { 00040 if (args.size() == 1) 00041 return true; 00042 00043 if (args.size() == 2) { 00044 int baudrate; 00045 00046 if (sscanf(args[1].c_str(), "%d", &baudrate) != 1) { 00047 CommandTerminal::setErrorMessage("Invalid argument"); 00048 return false; 00049 } 00050 00051 return true; 00052 } 00053 00054 CommandTerminal::setErrorMessage("Invalid arguments"); 00055 return false; 00056 }
Generated on Tue Jul 12 2022 20:40:04 by
