few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
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(mDot* dot, mts::MTSSerial& serial) 00011 : 00012 Command(dot, "App Port", "AT+AP", "Port used for application data (1 - 223)"), 00013 _serial(serial) 00014 { 00015 _help = std::string(text()) + ": " + std::string(desc()); 00016 _usage = "(1-223)"; 00017 _queryable = true; 00018 } 00019 00020 CmdAppPort::~CmdAppPort() 00021 { 00022 // TODO Auto-generated destructor stub 00023 } 00024 00025 uint32_t CmdAppPort::action(std::vector<std::string> args) { 00026 if (args.size() == 1) { 00027 if (_dot->getVerbose()) 00028 _serial.writef("App Port: "); 00029 00030 _serial.writef("%u\r\n", _dot->getAppPort()); 00031 } else if (args.size() == 2) { 00032 int32_t code; 00033 int appPort; 00034 sscanf(args[1].c_str(), "%d", &appPort); 00035 00036 if ((code = _dot->setAppPort(appPort)) != mDot::MDOT_OK) { 00037 00038 setErrorMessage(_dot->getLastError());; 00039 return 1; 00040 } 00041 } 00042 return 0; 00043 } 00044 00045 bool CmdAppPort::verify(std::vector<std::string> args) { 00046 if (args.size() == 1) 00047 return true; 00048 00049 if (args.size() == 2) { 00050 00051 int appPort; 00052 if (sscanf(args[1].c_str(), "%d", &appPort) == 1) { 00053 if (appPort > 223 || appPort < 1) { 00054 setErrorMessage("Invalid app port, expects (1-223)"); 00055 return false; 00056 } 00057 return true; 00058 } 00059 } 00060 00061 setErrorMessage("Invalid arguments"); 00062 return false; 00063 }
Generated on Tue Jul 12 2022 16:01:22 by 1.7.2