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 CmdJoinDelay.cpp Source File

CmdJoinDelay.cpp

00001 /*
00002  * CmdJoinDelay.cpp
00003  *
00004  *  Created on: Nov 4, 2015
00005  *      Author: jreiss
00006  */
00007 
00008 #include "CmdJoinDelay.h"
00009 
00010 CmdJoinDelay::CmdJoinDelay() :
00011 #if MTS_CMD_TERM_VERBOSE
00012     Command("Join Delay", "AT+JD", "Number of seconds before receive windows are opened for join (1 - 15)", "(1-15)")
00013 #else
00014     Command("AT+JD")
00015 #endif
00016 {
00017 
00018     _queryable = true;
00019 }
00020 
00021 CmdJoinDelay::~CmdJoinDelay()
00022 {
00023     // TODO Auto-generated destructor stub
00024 }
00025 
00026 uint32_t CmdJoinDelay::action(const std::vector<std::string>& args) {
00027 
00028     if (args.size() == 1) {
00029         CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getJoinDelay());
00030     } else if (args.size() == 2) {
00031         uint32_t joinDelay;
00032         sscanf(args[1].c_str(), "%" SCNu32, &joinDelay);
00033 
00034         if (CommandTerminal::Dot()->setJoinDelay(joinDelay) != mDot::MDOT_OK) {
00035             return 1;
00036         }
00037     }
00038     return 0;
00039 }
00040 
00041 bool CmdJoinDelay::verify(const std::vector<std::string>& args) {
00042     if (args.size() == 1)
00043         return true;
00044 
00045     if (args.size() == 2) {
00046 
00047         int joinDelay;
00048         if (sscanf(args[1].c_str(), "%d", &joinDelay) == 1) {
00049             if (joinDelay > 15 || joinDelay < 1) {
00050 #if MTS_CMD_TERM_VERBOSE
00051                 CommandTerminal::setErrorMessage("Invalid join delay, expects (1-15)");
00052 #endif
00053                 return false;
00054             }
00055             return true;
00056         }
00057     }
00058 
00059 #if MTS_CMD_TERM_VERBOSE
00060     CommandTerminal::setErrorMessage("Invalid arguments");
00061 #endif
00062     return false;
00063 }