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
CmdJoinRetries.cpp
00001 #include "CmdJoinRetries.h" 00002 00003 CmdJoinRetries::CmdJoinRetries(mDot* dot, mts::MTSSerial& serial) 00004 : 00005 Command(dot, "Join Retries", "AT+JR", "Number of times to retry joining the network in an attempt (0 - 255)"), 00006 _serial(serial) { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "(0-255)"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdJoinRetries::action(std::vector<std::string> args) { 00013 if (args.size() == 1) { 00014 if (_dot->getVerbose()) 00015 _serial.writef("Join Retries: "); 00016 00017 _serial.writef("%u\r\n", _dot->getJoinRetries()); 00018 } else if (args.size() == 2) { 00019 int32_t code; 00020 uint32_t retries; 00021 sscanf(args[1].c_str(), "%lu", &retries); 00022 00023 if ((code = _dot->setJoinRetries(retries)) != mDot::MDOT_OK) { 00024 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00025 setErrorMessage(error); 00026 return 1; 00027 } 00028 } 00029 return 0; 00030 } 00031 00032 bool CmdJoinRetries::verify(std::vector<std::string> args) { 00033 if (args.size() == 1) 00034 return true; 00035 00036 if (args.size() == 2) { 00037 00038 uint32_t retries; 00039 if (sscanf(args[1].c_str(), "%lu", &retries) == 1) { 00040 if (retries > 255) { 00041 setErrorMessage("Invalid retries, expects (0-255)"); 00042 return false; 00043 } 00044 return true; 00045 } 00046 } 00047 00048 setErrorMessage("Invalid arguments"); 00049 return false; 00050 } 00051
Generated on Tue Jul 12 2022 21:40:57 by 1.7.2