mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Committer:
Mike Fiore
Date:
Fri Nov 04 14:25:43 2016 -0500
Revision:
14:f9a77400b622
Parent:
1:e52ae6584f1c
update from git revision 2.0.16

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:e52ae6584f1c 1 #include "CmdReceiveOnce.h"
Mike Fiore 1:e52ae6584f1c 2 #include "CommandTerminal.h"
Mike Fiore 1:e52ae6584f1c 3
Mike Fiore 14:f9a77400b622 4 CmdReceiveOnce::CmdReceiveOnce() : Command("Receive Once", "AT+RECV", "Receive and display one packet.", "(string:242) or (hex:242)")
Mike Fiore 14:f9a77400b622 5
Mike Fiore 1:e52ae6584f1c 6 {
Mike Fiore 1:e52ae6584f1c 7 }
Mike Fiore 1:e52ae6584f1c 8
Mike Fiore 1:e52ae6584f1c 9 uint32_t CmdReceiveOnce::action(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 10 {
Mike Fiore 1:e52ae6584f1c 11 std::vector<uint8_t> data;
Mike Fiore 1:e52ae6584f1c 12
Mike Fiore 14:f9a77400b622 13 if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) {
Mike Fiore 14:f9a77400b622 14 if (!data.empty()) {
Mike Fiore 14:f9a77400b622 15 if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) {
Mike Fiore 14:f9a77400b622 16 for (size_t i = 0; i < data.size(); i++) {
Mike Fiore 14:f9a77400b622 17 CommandTerminal::Serial()->writef("%02x", data[i]);
Mike Fiore 14:f9a77400b622 18 }
Mike Fiore 14:f9a77400b622 19 CommandTerminal::Serial()->writef("\r\n");
Mike Fiore 14:f9a77400b622 20 } else {
Mike Fiore 14:f9a77400b622 21 CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str());
Mike Fiore 14:f9a77400b622 22 }
Mike Fiore 14:f9a77400b622 23 }
Mike Fiore 1:e52ae6584f1c 24 }
Mike Fiore 1:e52ae6584f1c 25
Mike Fiore 1:e52ae6584f1c 26 return 0;
Mike Fiore 1:e52ae6584f1c 27 }
Mike Fiore 1:e52ae6584f1c 28
Mike Fiore 1:e52ae6584f1c 29 bool CmdReceiveOnce::verify(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 30 {
Mike Fiore 1:e52ae6584f1c 31 if (args.size() == 1)
Mike Fiore 1:e52ae6584f1c 32 return true;
Mike Fiore 1:e52ae6584f1c 33
Mike Fiore 14:f9a77400b622 34 CommandTerminal::setErrorMessage("Invalid arguments");
Mike Fiore 1:e52ae6584f1c 35 return false;
Mike Fiore 1:e52ae6584f1c 36 }