Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
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(mDot* dot, mts::MTSSerial& serial) 00011 : 00012 Command(dot, "Join Delay", "AT+JD", "Number of seconds before receive windows are opened for join (1 - 15)"), 00013 _serial(serial) 00014 { 00015 _help = std::string(text()) + ": " + std::string(desc()); 00016 _usage = "(1-15)"; 00017 _queryable = true; 00018 } 00019 00020 CmdJoinDelay::~CmdJoinDelay() 00021 { 00022 // TODO Auto-generated destructor stub 00023 } 00024 00025 uint32_t CmdJoinDelay::action(std::vector<std::string> args) { 00026 if (args.size() == 1) { 00027 if (_dot->getVerbose()) 00028 _serial.writef("Join Delay: "); 00029 00030 _serial.writef("%u\r\n", _dot->getJoinDelay()); 00031 } else if (args.size() == 2) { 00032 int32_t code; 00033 uint32_t joinDelay; 00034 sscanf(args[1].c_str(), "%lu", &joinDelay); 00035 00036 if ((code = _dot->setJoinDelay(joinDelay)) != mDot::MDOT_OK) { 00037 00038 setErrorMessage(_dot->getLastError());; 00039 return 1; 00040 } 00041 } 00042 return 0; 00043 } 00044 00045 bool CmdJoinDelay::verify(std::vector<std::string> args) { 00046 if (args.size() == 1) 00047 return true; 00048 00049 if (args.size() == 2) { 00050 00051 int joinDelay; 00052 if (sscanf(args[1].c_str(), "%d", &joinDelay) == 1) { 00053 if (joinDelay > 15 || joinDelay < 1) { 00054 setErrorMessage("Invalid join delay, expects (1-15)"); 00055 return false; 00056 } 00057 return true; 00058 } 00059 } 00060 00061 setErrorMessage("Invalid arguments"); 00062 return false; 00063 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
