AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
CmdAppPort.cpp
00001 /* 00002 * CmdAppPort.cpp 00003 * 00004 * Created on: Nov 4, 2015 00005 * Author: jreiss 00006 */ 00007 00008 #include "CmdAppPort.h" 00009 00010 CmdAppPort::CmdAppPort() : 00011 #if MTS_CMD_TERM_VERBOSE 00012 Command("App Port", "AT+AP", "Port used for application data (1 - 223)", "(1-223)") 00013 #else 00014 Command("AT+AP") 00015 #endif 00016 { 00017 _queryable = true; 00018 } 00019 00020 CmdAppPort::~CmdAppPort() 00021 { 00022 // TODO Auto-generated destructor stub 00023 } 00024 00025 uint32_t CmdAppPort::action(const std::vector<std::string>& args) { 00026 if (args.size() == 1) { 00027 CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getAppPort()); 00028 } else if (args.size() == 2) { 00029 00030 int appPort; 00031 sscanf(args[1].c_str(), "%d", &appPort); 00032 00033 if (CommandTerminal::Dot()->setAppPort(appPort) != mDot::MDOT_OK) { 00034 return 1; 00035 } 00036 } 00037 return 0; 00038 } 00039 00040 bool CmdAppPort::verify(const std::vector<std::string>& args) { 00041 if (args.size() == 1) 00042 return true; 00043 00044 if (args.size() == 2) { 00045 00046 int appPort; 00047 if (sscanf(args[1].c_str(), "%d", &appPort) == 1) { 00048 if (appPort > 223 || appPort < 1) { 00049 #if MTS_CMD_TERM_VERBOSE 00050 CommandTerminal::setErrorMessage("Invalid app port, expects (1-223)"); 00051 #endif 00052 return false; 00053 } 00054 return true; 00055 } 00056 } 00057 00058 #if MTS_CMD_TERM_VERBOSE 00059 CommandTerminal::setErrorMessage("Invalid arguments"); 00060 #endif 00061 return false; 00062 }
Generated on Wed Dec 6 2023 19:34:05 by 1.7.2