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
CmdSerialWakeInterval.cpp
00001 #include "CmdSerialWakeInterval.h" 00002 00003 CmdSerialWakeInterval::CmdSerialWakeInterval(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Serial Wake Interval", "AT+SDWI", "Serial data wakeup interval to generate wake signal (seconds)"), 00005 _serial(serial) 00006 { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "(2-2147483647) s"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdSerialWakeInterval::action(std::vector<std::string> args) 00013 { 00014 if (args.size() == 1) 00015 { 00016 if (_dot->getVerbose()) 00017 _serial.writef("%s: ", name()); 00018 00019 _serial.writef("%lu\r\n", _dot->getSerialWakeInterval()); 00020 } 00021 else if (args.size() == 2) 00022 { 00023 int32_t code; 00024 uint32_t timeout; 00025 sscanf(args[1].c_str(), "%lu", &timeout); 00026 00027 if ((code = _dot->setSerialWakeInterval(timeout)) != mDot::MDOT_OK) { 00028 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00029 setErrorMessage(error); 00030 return 1; 00031 } 00032 } 00033 00034 return 0; 00035 } 00036 00037 bool CmdSerialWakeInterval::verify(std::vector<std::string> args) 00038 { 00039 if (args.size() == 1) 00040 return true; 00041 00042 if (args.size() == 2) { 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 < 2 || timeout > INT_MAX) { 00050 setErrorMessage("Invalid interval, expects (2-2147483647) s"); 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
