few changes for RTS/CTS control

Dependencies:   MTS-Serial libmDot mbed-rtos mbed

Fork of mDot_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(mDot* dot, mts::MTSSerial& serial)
00004 :
00005   Command(dot, "Downlink Counter", "AT+DLC", "Get or set the downlink counter"),
00006   _serial(serial) {
00007     _help = std::string(text()) + ": " + std::string(desc());
00008     _usage = "(0-4294967295)";
00009     _queryable = true;
00010 }
00011 
00012 uint32_t CmdDownlinkCounter::action(std::vector<std::string> args) {
00013     if (args.size() == 1) {
00014         if (_dot->getVerbose())
00015             _serial.writef("Downlink Counter: ");
00016 
00017         _serial.writef("%u\r\n", _dot->getDownLinkCounter());
00018     } else if (args.size() == 2) {
00019         int32_t code;
00020         uint32_t count;
00021         sscanf(args[1].c_str(), "%lu", &count);
00022 
00023         if ((code = _dot->setDownLinkCounter(count)) != mDot::MDOT_OK) {
00024             
00025             setErrorMessage(_dot->getLastError());;
00026             return 1;
00027         }
00028     }
00029     return 0;
00030 }
00031 
00032 bool CmdDownlinkCounter::verify(std::vector<std::string> args) {
00033     if (args.size() == 1)
00034         return true;
00035 
00036     if (args.size() == 2) {
00037 
00038         uint32_t count;
00039         if (sscanf(args[1].c_str(), "%lu", &count) == 1) {
00040             return true;
00041         }
00042     }
00043 
00044     setErrorMessage("Invalid arguments");
00045     return false;
00046 }
00047