![](/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/CmdDeviceId.cpp
- Committer:
- pferland
- Date:
- 2018-03-02
- Revision:
- 18:f5d28d621bb0
- Parent:
- 14:f9a77400b622
File content as of revision 18:f5d28d621bb0:
#include "CmdDeviceId.h" #include <algorithm> CmdDeviceId::CmdDeviceId() : Command("Device ID", "AT+DI", "Device EUI-64 (MSB) (unique, set at factory) (8 bytes)", "(hex:8)") { _queryable = true; } uint32_t CmdDeviceId::action(std::vector<std::string> args) { if (args.size() == 1) { CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getDeviceId(), "-").c_str()); } #ifdef DEBUG_MAC else if (args.size() == 2) { std::vector<uint8_t> NewEUI; // Read in the key components... readByteArray(args[1], NewEUI, EUI_LENGTH); if (CommandTerminal::Dot()->setDeviceId(NewEUI) == mDot::MDOT_OK) { CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(NewEUI, "-").c_str()); } else { CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; return 1; } } #endif return 0; } bool CmdDeviceId::verify(std::vector<std::string> args) { if (args.size() == 1) return true; #ifdef DEBUG_MAC if (args.size() == 2 && isHexString(args[1], 8)) return true; CommandTerminal::setErrorMessage("Invalid id, expects (hex:8)"); #else CommandTerminal::setErrorMessage("Invalid arguments"); #endif return false; }