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
CmdCRC.cpp
00001 #include "CmdCRC.h" 00002 00003 CmdCRC::CmdCRC(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "CRC Checking ", "AT+CRC", "Enable/disable CRC checking of received packets. (0: off, 1: on)"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 _usage = "(0,1)"; 00008 _queryable = true; 00009 } 00010 00011 uint32_t CmdCRC::action(std::vector<std::string> args) 00012 { 00013 if (args.size() == 1) 00014 { 00015 if (_dot->getVerbose()) 00016 _serial.writef("CRC Check: "); 00017 00018 _serial.writef("%d\r\n", _dot->getCrc()); 00019 } 00020 else if (args.size() == 2) 00021 { 00022 int32_t code; 00023 bool enable = (args[1] == "1"); 00024 if ((code = _dot->setCrc(enable)) != mDot::MDOT_OK) 00025 { 00026 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00027 setErrorMessage(error); 00028 return 1; 00029 } 00030 } 00031 00032 return 0; 00033 } 00034 00035 bool CmdCRC::verify(std::vector<std::string> args) 00036 { 00037 if (args.size() == 1) 00038 return true; 00039 00040 if (args.size() == 2) 00041 { 00042 if (args[1] != "1" && args[1] != "0") { 00043 setErrorMessage("Invalid parameter, expects (0: off, 1: on)"); 00044 return false; 00045 } 00046 00047 return true; 00048 } 00049 00050 setErrorMessage("Invalid arguments"); 00051 return false; 00052 }
Generated on Tue Jul 12 2022 21:40:57 by
1.7.2
