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

CmdTimeOnAir.cpp

00001 #include "CmdTimeOnAir.h"
00002 
00003 CmdTimeOnAir::CmdTimeOnAir()
00004 : Command("Time on air", "AT+TOA", "Get time in ms of packet tx with current datarate", "(0-242)") {
00005     _queryable = true;
00006 }
00007 
00008 uint32_t CmdTimeOnAir::action(std::vector<std::string> args) {
00009 
00010     int bytes;
00011 
00012     sscanf(args[1].c_str(), "%d", &bytes);
00013 
00014     CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getTimeOnAir(bytes + 13));
00015 
00016     return 0;
00017 }
00018 
00019 bool CmdTimeOnAir::verify(std::vector<std::string> args) {
00020 
00021     if (args.size() < 2) {
00022         CommandTerminal::setErrorMessage("Invalid parameter, expects (0-242)");
00023         return false;
00024     }
00025 
00026     int bytes;
00027 
00028     sscanf(args[1].c_str(), "%d", &bytes);
00029 
00030     if (bytes < 0 || bytes > 242) {
00031         CommandTerminal::setErrorMessage("Invalid parameter, expects (0-242)");
00032         return false;
00033     }
00034 
00035     return true;
00036 }