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