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
CmdJoinRequest.cpp
00001 #include "CmdJoinRequest.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdJoinRequest::CmdJoinRequest(mDot* dot, mts::MTSSerial& serial) 00005 : 00006 Command(dot, "Join Network", "AT+JOIN", "Join network, provide argument of '1' to force join (acquire network address and session keys)"), 00007 _serial(serial) { 00008 _help = std::string(text()) + ": " + std::string(desc()); 00009 _usage = "(force:1)"; 00010 } 00011 00012 uint32_t CmdJoinRequest::action(std::vector<std::string> args) { 00013 int32_t code; 00014 std::string buf; 00015 00016 if (args.size() > 1 && args[1] == "1") 00017 _dot->resetNetworkSession(); 00018 00019 if (_dot->getJoinMode() == 0) { 00020 _serial.writef("Join not necessary for Manual Join Mode\r\n"); 00021 return 0; 00022 } 00023 00024 code = _dot->joinNetworkOnce(); 00025 00026 if (code == mDot::MDOT_OK) { 00027 _serial.writef("Successfully joined network\r\n"); 00028 return 0; 00029 } else { 00030 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00031 setErrorMessage(_dot->getLastError());; 00032 } 00033 00034 return 1; 00035 } 00036 00037 bool CmdJoinRequest::verify(std::vector<std::string> args) { 00038 if (args.size() == 1 || (args.size() == 2 && args[1] == "1")) 00039 return true; 00040 00041 setErrorMessage("Invalid arguments"); 00042 return false; 00043 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
