firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdPing.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 "CmdPing.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdPing::CmdPing() : Command("Send Ping", "AT+PING", "Sends ping and displays the servers received rssi and snr", "(-140-0),(-20.0-20.0)") |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 4 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | uint32_t CmdPing::action(std::vector<std::string> args) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 8 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 9 | mDot::ping_response response; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 10 | response = CommandTerminal::Dot()->ping(); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 11 | if (response.status != mDot::MDOT_OK) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 12 | std::string error = mDot::getReturnCodeString(response.status); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 13 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | if (response.status != mDot::MDOT_NOT_JOINED) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | error += + " - " + CommandTerminal::Dot()->getLastError(); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | return 1; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | CommandTerminal::Serial()->writef("%d,%d.%d\r\n", response.rssi, response.snr / 10, abs(response.snr) % 10); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 |