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.
Fork of mDot_AT_firmware by
CmdJoinRequest.cpp
00001 #include "CmdJoinRequest.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdJoinRequest::CmdJoinRequest() : 00005 #if MTS_CMD_TERM_VERBOSE 00006 Command("Join Network", "AT+JOIN", "Join network, provide argument of '1' to force join (acquire network address and session keys)", "(force:1,usetxdr:2)") 00007 #else 00008 Command("AT+JOIN") 00009 #endif 00010 { 00011 00012 } 00013 00014 uint32_t CmdJoinRequest::action(const std::vector<std::string>& args) { 00015 // Detach the serial rx irq handler temporarily here to allow for deep sleep 00016 //CommandTerminal::Serial()->detach(); 00017 00018 std::string buf; 00019 uint32_t ret = 0; 00020 00021 if (args.size() > 1 && args[1] == "1") 00022 CommandTerminal::Dot()->resetNetworkSession(); 00023 00024 if (CommandTerminal::Dot()->getJoinMode() == 0) { 00025 CommandTerminal::Serial()->writef("Join not necessary for Manual Join Mode\r\n"); 00026 //CommandTerminal::Serial()->attach(); 00027 return 0; 00028 } else if (CommandTerminal::Dot()->getJoinMode() == 3) { 00029 CommandTerminal::Serial()->writef("Join not necessary for Peer-to-Peer\r\n"); 00030 //CommandTerminal::Serial()->attach(); 00031 return 0; 00032 } else { 00033 00034 if (args.size() > 1 && args[1] == "2") 00035 CommandTerminal::Dot()->setDisableAutoJoinDatarate(true); 00036 00037 int32_t code = CommandTerminal::Dot()->joinNetworkOnce(); 00038 00039 if (code == mDot::MDOT_OK) { 00040 CommandTerminal::Serial()->writef("Successfully joined network\r\n"); 00041 //CommandTerminal::Serial()->attach(); 00042 00043 } else { 00044 ret = 1; 00045 // std::string error = mDot::getReturnCodeString(code) + " - " + CommandTerminal::Dot()->getLastError(); 00046 // CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); 00047 } 00048 00049 if (args.size() > 1 && args[1] == "2") 00050 CommandTerminal::Dot()->setDisableAutoJoinDatarate(false); 00051 00052 } 00053 00054 //CommandTerminal::Serial()->attach(); 00055 return ret; 00056 } 00057 00058 bool CmdJoinRequest::verify(const std::vector<std::string>& args) { 00059 if (args.size() == 1 || (args.size() == 2 && (args[1] == "1" || args[1] == "2"))) 00060 return true; 00061 00062 #if MTS_CMD_TERM_VERBOSE 00063 CommandTerminal::setErrorMessage("Invalid arguments"); 00064 #endif 00065 return false; 00066 }
Generated on Wed Jan 15 2025 16:10:47 by
1.7.2


