AT command firmware for MultiTech Dot devices.

Fork of mDot_AT_firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdCustomDeviceID.cpp Source File

CmdCustomDeviceID.cpp

00001 #include "CmdCustomDeviceID.h"
00002 
00003 CmdCustomDeviceID::CmdCustomDeviceID() :
00004 #if MTS_CMD_TERM_VERBOSE
00005     Command("Custom Device ID", "AT+CDI", "Configure custom device ID", "(string:16)")
00006 #else
00007     Command("AT+CDI")
00008 #endif
00009 {
00010     _queryable = true;
00011 }
00012 
00013 uint32_t CmdCustomDeviceID::action(const std::vector<std::string>& args)
00014 {
00015     if (args.size() == 1)
00016     {
00017         CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->getCustomDeviceID().c_str());
00018     }
00019     else if (args.size() == 2)
00020     {
00021         if (CommandTerminal::Dot()->setCustomDeviceID(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 CmdCustomDeviceID::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 }