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 CmdDownlinkCounter.cpp Source File

CmdDownlinkCounter.cpp

00001 #include "CmdDownlinkCounter.h"
00002 
00003 CmdDownlinkCounter::CmdDownlinkCounter()
00004 :
00005   Command("Downlink Counter", "AT+DLC", "Get or set the downlink counter", "(0-4294967295)") {
00006 
00007     _queryable = true;
00008 }
00009 
00010 uint32_t CmdDownlinkCounter::action(std::vector<std::string> args) {
00011     if (args.size() == 1) {
00012         CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getDownLinkCounter());
00013     } else if (args.size() == 2) {
00014                 uint32_t count;
00015         sscanf(args[1].c_str(), "%lu", &count);
00016 
00017         if (CommandTerminal::Dot()->setDownLinkCounter(count) != mDot::MDOT_OK) {
00018             CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
00019             return 1;
00020         }
00021     }
00022     return 0;
00023 }
00024 
00025 bool CmdDownlinkCounter::verify(std::vector<std::string> args) {
00026     if (args.size() == 1)
00027         return true;
00028 
00029     if (args.size() == 2) {
00030 
00031         uint32_t count;
00032         if (sscanf(args[1].c_str(), "%lu", &count) == 1) {
00033             return true;
00034         }
00035     }
00036 
00037     CommandTerminal::setErrorMessage("Invalid arguments");
00038     return false;
00039 }
00040