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

CmdPing.cpp

00001 #include "CmdPing.h"
00002 
00003 CmdPing::CmdPing() : Command("Send Ping", "AT+PING", "Sends ping and displays the servers received rssi and snr", "(-140-0),(-20.0-20.0)")
00004 {
00005 }
00006 
00007 uint32_t CmdPing::action(std::vector<std::string> args)
00008 {
00009     mDot::ping_response response;
00010     response = CommandTerminal::Dot()->ping();
00011     if (response.status != mDot::MDOT_OK) {
00012         std::string error = mDot::getReturnCodeString(response.status);
00013 
00014         if (response.status != mDot::MDOT_NOT_JOINED)
00015             error +=  + " - " + CommandTerminal::Dot()->getLastError();
00016 
00017         CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
00018         return 1;
00019     }
00020 
00021     CommandTerminal::Serial()->writef("%d,%d.%d\r\n", response.rssi, response.snr / 10, abs(response.snr) % 10);
00022 
00023     return 0;
00024 }
00025