AT command firmware for MultiTech Dot devices.
Fork of mDot_AT_firmware by
CmdCustomSerialNumber.cpp
00001 #include "CmdCustomSerialNumber.h" 00002 00003 CmdCustomSerialNumber::CmdCustomSerialNumber() : 00004 #if MTS_CMD_TERM_VERBOSE 00005 Command("Custom Serial Number", "AT+CSN", "Configure custom serial number", "(string:16)") 00006 #else 00007 Command("AT+CSN") 00008 #endif 00009 { 00010 _queryable = true; 00011 } 00012 00013 uint32_t CmdCustomSerialNumber::action(const std::vector<std::string>& args) 00014 { 00015 if (args.size() == 1) 00016 { 00017 CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->getCustomSerialNumber().c_str()); 00018 } 00019 else if (args.size() == 2) 00020 { 00021 if (CommandTerminal::Dot()->setCustomSerialNumber(args[1]) == mDot::MDOT_OK) 00022 { 00023 CommandTerminal::Serial()->writef("Set ID: %s\r\n", args[1].c_str()); 00024 } 00025 else 00026 { 00027 return 1; 00028 } 00029 } 00030 00031 return 0; 00032 } 00033 00034 bool CmdCustomSerialNumber::verify(const std::vector<std::string>& args) 00035 { 00036 if (args.size() == 1) 00037 return true; 00038 00039 if (args.size() == 2) { 00040 00041 if (args[1].size() > CUSTOM_FIELD_LENGTH) { 00042 #if MTS_CMD_TERM_VERBOSE 00043 CommandTerminal::setErrorMessage("Invalid length, expects (string:16)"); 00044 #endif 00045 return false; 00046 } 00047 00048 return true; 00049 } 00050 00051 #if MTS_CMD_TERM_VERBOSE 00052 CommandTerminal::setErrorMessage("Invalid arguments"); 00053 #endif 00054 return false; 00055 }
Generated on Wed Dec 6 2023 19:34:05 by 1.7.2