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 libmDot-mbed5
Fork of Dot-AT-Firmware by
CmdDeviceId.cpp
00001 #include "CmdDeviceId.h" 00002 #include <algorithm> 00003 00004 CmdDeviceId::CmdDeviceId() : 00005 Command("Device ID", "AT+DI", "Device EUI-64 (MSB) (unique, set at factory) (8 bytes)", "(hex:8)") 00006 { 00007 _queryable = true; 00008 } 00009 00010 uint32_t CmdDeviceId::action(std::vector<std::string> args) 00011 { 00012 if (args.size() == 1) 00013 { 00014 CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getDeviceId(), "-").c_str()); 00015 } 00016 #ifdef DEBUG_MAC 00017 else if (args.size() == 2) 00018 { 00019 std::vector<uint8_t> NewEUI; 00020 00021 // Read in the key components... 00022 readByteArray(args[1], NewEUI, EUI_LENGTH); 00023 00024 if (CommandTerminal::Dot()->setDeviceId(NewEUI) == mDot::MDOT_OK) { 00025 CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(NewEUI, "-").c_str()); 00026 } else { 00027 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; 00028 return 1; 00029 } 00030 } 00031 #endif 00032 return 0; 00033 } 00034 00035 bool CmdDeviceId::verify(std::vector<std::string> args) 00036 { 00037 if (args.size() == 1) 00038 return true; 00039 00040 #ifdef DEBUG_MAC 00041 if (args.size() == 2 && isHexString(args[1], 8)) 00042 return true; 00043 00044 CommandTerminal::setErrorMessage("Invalid id, expects (hex:8)"); 00045 #else 00046 CommandTerminal::setErrorMessage("Invalid arguments"); 00047 #endif 00048 00049 return false; 00050 }
Generated on Tue Jul 12 2022 20:40:03 by
