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

CmdLinkCheckCount.cpp

00001 #include "CmdLinkCheckCount.h"
00002 
00003 CmdLinkCheckCount::CmdLinkCheckCount() :
00004         Command("Link Check Count", "AT+LCC", "Set number of packets between each link check if ACK's are disabled", "(0:off,N:Packets (max 255))")
00005 {
00006     _queryable = true;
00007 }
00008 
00009 uint32_t CmdLinkCheckCount::action(std::vector<std::string> args)
00010 {
00011     if (args.size() == 1)
00012     {
00013              CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getLinkCheckCount());
00014     }
00015     else if (args.size() == 2)
00016     {
00017         int count;
00018         sscanf(args[1].c_str(), "%d", &count);
00019 
00020         if (CommandTerminal::Dot()->setLinkCheckCount(count) != mDot::MDOT_OK)
00021         {
00022             CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
00023             return 1;
00024         }
00025     }
00026 
00027     return 0;
00028 }
00029 
00030 bool CmdLinkCheckCount::verify(std::vector<std::string> args)
00031 {
00032     if (args.size() == 1)
00033         return true;
00034 
00035     if (args.size() == 2)
00036     {
00037         int count;
00038         if (sscanf(args[1].c_str(), "%d", &count) != 1) {
00039             CommandTerminal::setErrorMessage("Invalid argument");
00040             return false;
00041         }
00042 
00043         if (count < 0 || count > 255) {
00044             CommandTerminal::setErrorMessage("Invalid count, expects (0:off,N:Packets (max 255))");
00045             return false;
00046         }
00047 
00048         return true;
00049     }
00050 
00051     CommandTerminal::setErrorMessage("Invalid arguments");
00052     return false;
00053 }