AT Command Set mDot firmware with updated libmDot, to fix endian problem with joining LoRaWAN network
Dependencies: MTS-Serial libmDot mbed-rtos mbed-src
Fork of mDot_AT_firmware by
CmdSerialReceiveTimeout.cpp
00001 #include "CmdSerialReceiveTimeout.h" 00002 00003 CmdSerialReceiveTimeout::CmdSerialReceiveTimeout(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Serial Receive Timeout", "AT+SDTO", "Read serial data until timeout (milliseconds)"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 _usage = "(0-65000) ms"; 00008 _queryable = true; 00009 } 00010 00011 uint32_t CmdSerialReceiveTimeout::action(std::vector<std::string> args) 00012 { 00013 if (args.size() == 1) 00014 { 00015 if (_dot->getVerbose()) 00016 _serial.writef("%s: ", name()); 00017 00018 _serial.writef("%lu\r\n", _dot->getSerialReceiveTimeout()); 00019 } 00020 else if (args.size() == 2) 00021 { 00022 int32_t code; 00023 uint32_t timeout; 00024 sscanf(args[1].c_str(), "%lu", &timeout); 00025 00026 if ((code = _dot->setSerialReceiveTimeout(timeout)) != mDot::MDOT_OK) { 00027 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00028 setErrorMessage(error); 00029 return 1; 00030 } 00031 } 00032 00033 return 0; 00034 } 00035 00036 bool CmdSerialReceiveTimeout::verify(std::vector<std::string> args) 00037 { 00038 if (args.size() == 1) 00039 return true; 00040 00041 if (args.size() == 2) 00042 { 00043 uint32_t timeout; 00044 if (sscanf(args[1].c_str(), "%lu", &timeout) != 1) { 00045 setErrorMessage("Invalid argument"); 00046 return false; 00047 } 00048 00049 if (timeout < 0 || timeout > 65000) { 00050 setErrorMessage("Invalid timeout, expects (0-65000) ms"); 00051 return false; 00052 } 00053 00054 return true; 00055 } 00056 00057 setErrorMessage("Invalid arguments"); 00058 return false; 00059 }
Generated on Tue Jul 12 2022 21:40:57 by
1.7.2
