firm newest

Dependencies:   MTS-Serial libmDot-dev-mbed5-deprecated

Committer:
nguyenhoang9x5555
Date:
Mon Oct 22 01:56:09 2018 +0000
Revision:
1:c1c6549b9333
Parent:
0:3c869a8cb8f8
hey

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdNetworkJoinMode.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2
nguyenhoang9x5555 0:3c869a8cb8f8 3 CmdNetworkJoinMode::CmdNetworkJoinMode() :
nguyenhoang9x5555 0:3c869a8cb8f8 4 Command("Network Join Mode", "AT+NJM", "0: Manual configuration, 1: OTA Network Join, 2: Auto OTA Network Join on start up, 3: Peer-to-Peer (default: 1)", "(0-3)")
nguyenhoang9x5555 0:3c869a8cb8f8 5 {
nguyenhoang9x5555 0:3c869a8cb8f8 6 _queryable = true;
nguyenhoang9x5555 0:3c869a8cb8f8 7 }
nguyenhoang9x5555 0:3c869a8cb8f8 8
nguyenhoang9x5555 0:3c869a8cb8f8 9 uint32_t CmdNetworkJoinMode::action(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 10 {
nguyenhoang9x5555 0:3c869a8cb8f8 11 if (args.size() == 1) {
nguyenhoang9x5555 0:3c869a8cb8f8 12 CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getJoinMode());
nguyenhoang9x5555 0:3c869a8cb8f8 13 }
nguyenhoang9x5555 0:3c869a8cb8f8 14 else if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 15 {
nguyenhoang9x5555 0:3c869a8cb8f8 16 uint8_t mode = (args[1] == "1") ? 1 : 0;
nguyenhoang9x5555 0:3c869a8cb8f8 17 mode = (args[1] == "2" ? 2 : mode);
nguyenhoang9x5555 0:3c869a8cb8f8 18 mode = (args[1] == "3" ? 3 : mode);
nguyenhoang9x5555 0:3c869a8cb8f8 19
nguyenhoang9x5555 0:3c869a8cb8f8 20 if (CommandTerminal::Dot()->setJoinMode(mode) != mDot::MDOT_OK)
nguyenhoang9x5555 0:3c869a8cb8f8 21 {
nguyenhoang9x5555 0:3c869a8cb8f8 22 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
nguyenhoang9x5555 0:3c869a8cb8f8 23 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 24 }
nguyenhoang9x5555 0:3c869a8cb8f8 25
nguyenhoang9x5555 0:3c869a8cb8f8 26 }
nguyenhoang9x5555 0:3c869a8cb8f8 27
nguyenhoang9x5555 0:3c869a8cb8f8 28 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 29 }
nguyenhoang9x5555 0:3c869a8cb8f8 30
nguyenhoang9x5555 0:3c869a8cb8f8 31 bool CmdNetworkJoinMode::verify(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 32 {
nguyenhoang9x5555 0:3c869a8cb8f8 33 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 34 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 35
nguyenhoang9x5555 0:3c869a8cb8f8 36 if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 37 {
nguyenhoang9x5555 0:3c869a8cb8f8 38 if (!(args[1] == "0" || args[1] == "1" || args[1] == "2" || args[1] == "3"))
nguyenhoang9x5555 0:3c869a8cb8f8 39 {
nguyenhoang9x5555 0:3c869a8cb8f8 40 CommandTerminal::setErrorMessage("Invalid parameter, expects (0: Manual, 1: OTA, 2: Auto OTA, 3:Peer-to-Peer)");
nguyenhoang9x5555 0:3c869a8cb8f8 41 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 42 }
nguyenhoang9x5555 0:3c869a8cb8f8 43
nguyenhoang9x5555 0:3c869a8cb8f8 44 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 45 }
nguyenhoang9x5555 0:3c869a8cb8f8 46
nguyenhoang9x5555 0:3c869a8cb8f8 47 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 48 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 49 }