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.
Dependencies: MTS-Serial libxDot-dev-mbed5-deprecated
Fork of Dot-AT-Firmware by
Diff: CommandTerminal/CmdDeviceId.cpp
- Revision:
- 14:f9a77400b622
- Parent:
- 9:ff62b20f7000
--- a/CommandTerminal/CmdDeviceId.cpp Fri Nov 04 19:10:24 2016 +0000
+++ b/CommandTerminal/CmdDeviceId.cpp Fri Nov 04 14:25:43 2016 -0500
@@ -1,11 +1,9 @@
#include "CmdDeviceId.h"
#include <algorithm>
-CmdDeviceId::CmdDeviceId(mDot* dot, mts::MTSSerial& serial) :
- Command(dot, "Device ID", "AT+DI", "Device EUI-64 (MSB) (unique, set at factory) (8 bytes)"), _serial(serial)
+CmdDeviceId::CmdDeviceId() :
+ Command("Device ID", "AT+DI", "Device EUI-64 (MSB) (unique, set at factory) (8 bytes)", "(hex:8)")
{
- _help = std::string(text()) + ": " + std::string(desc());
- _usage = "(hex:8)";
_queryable = true;
}
@@ -13,11 +11,24 @@
{
if (args.size() == 1)
{
- if (_dot->getVerbose())
- _serial.writef("%s: ", name());
- _serial.writef("%s\r\n", mts::Text::bin2hexString(_dot->getDeviceId(), "-").c_str());
+ 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;
}
@@ -26,6 +37,14 @@
if (args.size() == 1)
return true;
- setErrorMessage("Invalid arguments");
+#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;
}
