few changes for RTS/CTS control

Dependencies:   MTS-Serial libmDot mbed-rtos mbed

Fork of mDot_AT_firmware by MultiTech

CommandTerminal/CmdTimeOnAir.cpp

Committer:
serg838
Date:
2016-10-25
Revision:
11:77b7911263da
Parent:
9:ff62b20f7000

File content as of revision 11:77b7911263da:

#include "CmdTimeOnAir.h"

CmdTimeOnAir::CmdTimeOnAir(mDot* dot, mts::MTSSerial& serial)
:
  Command(dot, "Time on air", "AT+TOA", "Get time in ms of packet tx with current datarate"),
  _serial(serial) {
    _help = std::string(text()) + ": " + std::string(desc());
    _usage = "(0-242)";
    _queryable = true;
}

uint32_t CmdTimeOnAir::action(std::vector<std::string> args) {

    if (_dot->getVerbose())
        _serial.writef("Time on air: ");

    int bytes;

    sscanf(args[1].c_str(), "%d", &bytes);

    _serial.writef("%lu\r\n", _dot->getTimeOnAir(bytes + 13));

    return 0;
}

bool CmdTimeOnAir::verify(std::vector<std::string> args) {

    if (args.size() < 2) {
        setErrorMessage("Invalid parameter, expects (0-242)");
        return false;
    }

    int bytes;

    sscanf(args[1].c_str(), "%d", &bytes);

    if (bytes < 0 || bytes > 242) {
        setErrorMessage("Invalid parameter, expects (0-242)");
        return false;
    }

    return true;
}