firm newest

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

Committer:
nguyenhoang9x5555
Date:
Thu Oct 18 04:18:48 2018 +0000
Revision:
0:3c869a8cb8f8
DOT AT FIRMWARE 18102018

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdDeviceId.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2 #include <algorithm>
nguyenhoang9x5555 0:3c869a8cb8f8 3
nguyenhoang9x5555 0:3c869a8cb8f8 4 CmdDeviceId::CmdDeviceId() :
nguyenhoang9x5555 0:3c869a8cb8f8 5 Command("Device ID", "AT+DI", "Device EUI-64 (MSB) (unique, set at factory) (8 bytes)", "(hex:8)")
nguyenhoang9x5555 0:3c869a8cb8f8 6 {
nguyenhoang9x5555 0:3c869a8cb8f8 7 _queryable = true;
nguyenhoang9x5555 0:3c869a8cb8f8 8 }
nguyenhoang9x5555 0:3c869a8cb8f8 9
nguyenhoang9x5555 0:3c869a8cb8f8 10 uint32_t CmdDeviceId::action(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 11 {
nguyenhoang9x5555 0:3c869a8cb8f8 12 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 13 {
nguyenhoang9x5555 0:3c869a8cb8f8 14 CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(CommandTerminal::Dot()->getDeviceId(), "-").c_str());
nguyenhoang9x5555 0:3c869a8cb8f8 15 }
nguyenhoang9x5555 0:3c869a8cb8f8 16 #ifdef DEBUG_MAC
nguyenhoang9x5555 0:3c869a8cb8f8 17 else if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 18 {
nguyenhoang9x5555 0:3c869a8cb8f8 19 std::vector<uint8_t> NewEUI;
nguyenhoang9x5555 0:3c869a8cb8f8 20
nguyenhoang9x5555 0:3c869a8cb8f8 21 // Read in the key components...
nguyenhoang9x5555 0:3c869a8cb8f8 22 readByteArray(args[1], NewEUI, EUI_LENGTH);
nguyenhoang9x5555 0:3c869a8cb8f8 23
nguyenhoang9x5555 0:3c869a8cb8f8 24 if (CommandTerminal::Dot()->setDeviceId(NewEUI) == mDot::MDOT_OK) {
nguyenhoang9x5555 0:3c869a8cb8f8 25 CommandTerminal::Serial()->writef("%s\r\n", mts::Text::bin2hexString(NewEUI, "-").c_str());
nguyenhoang9x5555 0:3c869a8cb8f8 26 } else {
nguyenhoang9x5555 0:3c869a8cb8f8 27 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
nguyenhoang9x5555 0:3c869a8cb8f8 28 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 29 }
nguyenhoang9x5555 0:3c869a8cb8f8 30 }
nguyenhoang9x5555 0:3c869a8cb8f8 31 #endif
nguyenhoang9x5555 0:3c869a8cb8f8 32 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 33 }
nguyenhoang9x5555 0:3c869a8cb8f8 34
nguyenhoang9x5555 0:3c869a8cb8f8 35 bool CmdDeviceId::verify(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 36 {
nguyenhoang9x5555 0:3c869a8cb8f8 37 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 38 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 39
nguyenhoang9x5555 0:3c869a8cb8f8 40 #ifdef DEBUG_MAC
nguyenhoang9x5555 0:3c869a8cb8f8 41 if (args.size() == 2 && isHexString(args[1], 8))
nguyenhoang9x5555 0:3c869a8cb8f8 42 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 43
nguyenhoang9x5555 0:3c869a8cb8f8 44 CommandTerminal::setErrorMessage("Invalid id, expects (hex:8)");
nguyenhoang9x5555 0:3c869a8cb8f8 45 #else
nguyenhoang9x5555 0:3c869a8cb8f8 46 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 47 #endif
nguyenhoang9x5555 0:3c869a8cb8f8 48
nguyenhoang9x5555 0:3c869a8cb8f8 49 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 50 }