MicroLabo / Mbed OS mbed-Dot-AT-Firmware

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CmdDeviceClass.cpp Source File

CmdDeviceClass.cpp

00001 #include "CmdDeviceClass.h"
00002 #include "CommandTerminal.h"
00003 
00004 CmdDeviceClass::CmdDeviceClass()
00005 :
00006   Command("Device Class", "AT+DC", "Device class (A,B,C)", "(A,B,C)") {
00007 
00008     _queryable = true;
00009 }
00010 
00011 CmdDeviceClass::~CmdDeviceClass() {
00012 
00013 }
00014 
00015 uint32_t CmdDeviceClass::action(std::vector<std::string> args) {
00016 
00017     if (args.size() == 1) {
00018         CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->getClass().c_str());
00019     } else {
00020         if (CommandTerminal::Dot()->setClass(args[1]) != mDot::MDOT_OK) {
00021             CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
00022             return 1;
00023         }
00024     }
00025 
00026     return 0;
00027 }
00028 
00029 bool CmdDeviceClass::verify(std::vector<std::string> args)
00030 {
00031     if (args.size() == 1)
00032         return true;
00033 
00034     if (args.size() == 2) {
00035         args[1] = mts::Text::toUpper(args[1]);
00036         if (args[1] == "A" || args[1] == "B" || args[1] == "C") {
00037             return true;
00038         }
00039     }
00040 
00041     CommandTerminal::setErrorMessage("Invalid arguments");
00042     return false;
00043 }