mDot AT-Firmware for testing
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdNetworkAddress.cpp
- Revision:
- 14:f9a77400b622
- Parent:
- 9:ff62b20f7000
--- a/CommandTerminal/CmdNetworkAddress.cpp Fri Nov 04 19:10:24 2016 +0000 +++ b/CommandTerminal/CmdNetworkAddress.cpp Fri Nov 04 14:25:43 2016 -0500 @@ -1,11 +1,9 @@ #include "CmdNetworkAddress.h" #include <algorithm> -CmdNetworkAddress::CmdNetworkAddress(mDot* dot, mts::MTSSerial& serial) : - Command(dot, "Network Address", "AT+NA", "Network address (devAddr in LoraMac) (4 bytes)"), _serial(serial) +CmdNetworkAddress::CmdNetworkAddress() : + Command("Network Address", "AT+NA", "Network address (devAddr in LoraMac) (4 bytes)", "(hex:4)") { - _help = std::string(text()) + ": " + std::string(desc()); - _usage = "(hex:4)"; _queryable = true; } @@ -15,16 +13,12 @@ if (args.size() == 1) { - if (_dot->getVerbose()) - _serial.writef("Network Address: "); - - addr = _dot->getNetworkAddress(); - - _serial.writef("%02x:%02x:%02x:%02x\r\n", addr[0], addr[1], addr[2], addr[3]); + addr = CommandTerminal::Dot()->getNetworkAddress(); + CommandTerminal::Serial()->writef("%02x:%02x:%02x:%02x\r\n", addr[0], addr[1], addr[2], addr[3]); } else if (args.size() == 2) { - int32_t code; + int temp; uint32_t step = 2; @@ -38,12 +32,11 @@ addr.push_back(temp); } - if ((code = _dot->setNetworkAddress(addr)) == mDot::MDOT_OK) { - _serial.writef("Set Network Address: "); - _serial.writef("%02x:%02x:%02x:%02x\r\n", addr[0], addr[1], addr[2], addr[3]); + if (CommandTerminal::Dot()->setNetworkAddress(addr) == mDot::MDOT_OK) { + CommandTerminal::Serial()->writef("Set Network Address: "); + CommandTerminal::Serial()->writef("%02x:%02x:%02x:%02x\r\n", addr[0], addr[1], addr[2], addr[3]); } else { - - setErrorMessage(_dot->getLastError());; + CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; return 1; } } @@ -60,13 +53,13 @@ if (args.size() == 2) { if (!isHexString(args[1], 4)) { - setErrorMessage("Invalid address, expects (hex:4)"); + CommandTerminal::setErrorMessage("Invalid address, expects (hex:4)"); return false; } return true; } - setErrorMessage("Invalid arguments"); + CommandTerminal::setErrorMessage("Invalid arguments"); return false; }