firm newest

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

Committer:
nguyenhoang9x5555
Date:
Mon Oct 22 01:56:09 2018 +0000
Revision:
1:c1c6549b9333
Parent:
0:3c869a8cb8f8
hey

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdDeviceClass.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2 #include "CommandTerminal.h"
nguyenhoang9x5555 0:3c869a8cb8f8 3
nguyenhoang9x5555 0:3c869a8cb8f8 4 CmdDeviceClass::CmdDeviceClass()
nguyenhoang9x5555 0:3c869a8cb8f8 5 :
nguyenhoang9x5555 0:3c869a8cb8f8 6 Command("Device Class", "AT+DC", "Device class (A,B,C)", "(A,B,C)") {
nguyenhoang9x5555 0:3c869a8cb8f8 7
nguyenhoang9x5555 0:3c869a8cb8f8 8 _queryable = true;
nguyenhoang9x5555 0:3c869a8cb8f8 9 }
nguyenhoang9x5555 0:3c869a8cb8f8 10
nguyenhoang9x5555 0:3c869a8cb8f8 11 CmdDeviceClass::~CmdDeviceClass() {
nguyenhoang9x5555 0:3c869a8cb8f8 12
nguyenhoang9x5555 0:3c869a8cb8f8 13 }
nguyenhoang9x5555 0:3c869a8cb8f8 14
nguyenhoang9x5555 0:3c869a8cb8f8 15 uint32_t CmdDeviceClass::action(std::vector<std::string> args) {
nguyenhoang9x5555 0:3c869a8cb8f8 16
nguyenhoang9x5555 0:3c869a8cb8f8 17 if (args.size() == 1) {
nguyenhoang9x5555 0:3c869a8cb8f8 18 CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->getClass().c_str());
nguyenhoang9x5555 0:3c869a8cb8f8 19 } else {
nguyenhoang9x5555 0:3c869a8cb8f8 20 if (CommandTerminal::Dot()->setClass(args[1]) != mDot::MDOT_OK) {
nguyenhoang9x5555 0:3c869a8cb8f8 21 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
nguyenhoang9x5555 0:3c869a8cb8f8 22 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 23 }
nguyenhoang9x5555 0:3c869a8cb8f8 24 }
nguyenhoang9x5555 0:3c869a8cb8f8 25
nguyenhoang9x5555 0:3c869a8cb8f8 26 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 27 }
nguyenhoang9x5555 0:3c869a8cb8f8 28
nguyenhoang9x5555 0:3c869a8cb8f8 29 bool CmdDeviceClass::verify(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 30 {
nguyenhoang9x5555 0:3c869a8cb8f8 31 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 32 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 33
nguyenhoang9x5555 0:3c869a8cb8f8 34 if (args.size() == 2) {
nguyenhoang9x5555 0:3c869a8cb8f8 35 args[1] = mts::Text::toUpper(args[1]);
nguyenhoang9x5555 0:3c869a8cb8f8 36 if (args[1] == "A" || args[1] == "B" || args[1] == "C") {
nguyenhoang9x5555 0:3c869a8cb8f8 37 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 38 }
nguyenhoang9x5555 0:3c869a8cb8f8 39 }
nguyenhoang9x5555 0:3c869a8cb8f8 40
nguyenhoang9x5555 0:3c869a8cb8f8 41 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 42 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 43 }