firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdTimeOnAir.cpp@1:c1c6549b9333, 2018-10-22 (annotated)
- Committer:
- nguyenhoang9x5555
- Date:
- Mon Oct 22 01:56:09 2018 +0000
- Revision:
- 1:c1c6549b9333
- Parent:
- 0:3c869a8cb8f8
hey
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 1 | #include "CmdTimeOnAir.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdTimeOnAir::CmdTimeOnAir() |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 4 | : Command("Time on air", "AT+TOA", "Get time in ms of packet tx with current datarate", "(0-242)") { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | _queryable = true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 8 | uint32_t CmdTimeOnAir::action(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 9 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 10 | int bytes; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 11 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 12 | sscanf(args[1].c_str(), "%d", &bytes); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 13 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getTimeOnAir(bytes + 13)); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | bool CmdTimeOnAir::verify(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | if (args.size() < 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0-242)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 26 | int bytes; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 27 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 28 | sscanf(args[1].c_str(), "%d", &bytes); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 29 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 30 | if (bytes < 0 || bytes > 242) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 31 | CommandTerminal::setErrorMessage("Invalid parameter, expects (0-242)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 32 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 33 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 34 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 35 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 36 | } |