![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CmdJoinRequest.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 14:f9a77400b622
Added ability to force the AT terminal to use the USB debug port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdJoinRequest.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | #include "CommandTerminal.h" |
Mike Fiore |
1:e52ae6584f1c | 3 | |
Mike Fiore |
14:f9a77400b622 | 4 | CmdJoinRequest::CmdJoinRequest() |
Mike Fiore |
1:e52ae6584f1c | 5 | : |
Mike Fiore |
14:f9a77400b622 | 6 | Command("Join Network", "AT+JOIN", "Join network, provide argument of '1' to force join (acquire network address and session keys)", "(force:1)") { |
Mike Fiore |
14:f9a77400b622 | 7 | |
Mike Fiore |
1:e52ae6584f1c | 8 | } |
Mike Fiore |
1:e52ae6584f1c | 9 | |
Mike Fiore |
1:e52ae6584f1c | 10 | uint32_t CmdJoinRequest::action(std::vector<std::string> args) { |
Mike Fiore |
14:f9a77400b622 | 11 | |
Mike Fiore |
1:e52ae6584f1c | 12 | std::string buf; |
Mike Fiore |
1:e52ae6584f1c | 13 | |
Mike Fiore |
1:e52ae6584f1c | 14 | if (args.size() > 1 && args[1] == "1") |
Mike Fiore |
14:f9a77400b622 | 15 | CommandTerminal::Dot()->resetNetworkSession(); |
Mike Fiore |
1:e52ae6584f1c | 16 | |
Mike Fiore |
14:f9a77400b622 | 17 | if (CommandTerminal::Dot()->getJoinMode() == 0) { |
Mike Fiore |
14:f9a77400b622 | 18 | CommandTerminal::Serial()->writef("Join not necessary for Manual Join Mode\r\n"); |
Mike Fiore |
14:f9a77400b622 | 19 | return 0; |
Mike Fiore |
14:f9a77400b622 | 20 | } else if (CommandTerminal::Dot()->getJoinMode() == 3) { |
Mike Fiore |
14:f9a77400b622 | 21 | CommandTerminal::Serial()->writef("Join not necessary for Peer-to-Peer\r\n"); |
Mike Fiore |
9:ff62b20f7000 | 22 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 23 | } |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
14:f9a77400b622 | 25 | int32_t code = CommandTerminal::Dot()->joinNetworkOnce(); |
Mike Fiore |
1:e52ae6584f1c | 26 | |
Mike Fiore |
1:e52ae6584f1c | 27 | if (code == mDot::MDOT_OK) { |
Mike Fiore |
14:f9a77400b622 | 28 | CommandTerminal::Serial()->writef("Successfully joined network\r\n"); |
Mike Fiore |
1:e52ae6584f1c | 29 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 30 | } else { |
Mike Fiore |
14:f9a77400b622 | 31 | std::string error = mDot::getReturnCodeString(code) + " - " + CommandTerminal::Dot()->getLastError(); |
Mike Fiore |
14:f9a77400b622 | 32 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError()); |
Mike Fiore |
1:e52ae6584f1c | 33 | } |
Mike Fiore |
1:e52ae6584f1c | 34 | |
Mike Fiore |
1:e52ae6584f1c | 35 | return 1; |
Mike Fiore |
1:e52ae6584f1c | 36 | } |
Mike Fiore |
1:e52ae6584f1c | 37 | |
Mike Fiore |
1:e52ae6584f1c | 38 | bool CmdJoinRequest::verify(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 39 | if (args.size() == 1 || (args.size() == 2 && args[1] == "1")) |
Mike Fiore |
1:e52ae6584f1c | 40 | return true; |
Mike Fiore |
1:e52ae6584f1c | 41 | |
Mike Fiore |
14:f9a77400b622 | 42 | CommandTerminal::setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 43 | return false; |
Mike Fiore |
1:e52ae6584f1c | 44 | } |