mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Revision:
14:f9a77400b622
Parent:
1:e52ae6584f1c
--- a/CommandTerminal/CmdReceiveOnce.cpp	Fri Nov 04 19:10:24 2016 +0000
+++ b/CommandTerminal/CmdReceiveOnce.cpp	Fri Nov 04 14:25:43 2016 -0500
@@ -1,23 +1,26 @@
 #include "CmdReceiveOnce.h"
 #include "CommandTerminal.h"
 
-CmdReceiveOnce::CmdReceiveOnce(mDot* dot, mts::MTSSerial& serial) : Command(dot, "Receive Once", "AT+RECV", "Receive and display one packet."),
-    _serial(serial)
+CmdReceiveOnce::CmdReceiveOnce() : Command("Receive Once", "AT+RECV", "Receive and display one packet.", "(string:242) or (hex:242)")
+    
 {
-    _help = std::string(text()) + ": " + std::string(desc());
-    _usage = "(string:242) or (hex:242)";
 }
 
 uint32_t CmdReceiveOnce::action(std::vector<std::string> args)
 {
     std::vector<uint8_t> data;
 
-    if (_dot->recv(data) == mDot::MDOT_OK) {
-        if (_dot->getVerbose())
-            _serial.writef("Packet data:\r\n");
-
-        if (!data.empty())
-            _serial.writef("%s\r\n", CommandTerminal::formatPacketData(data, _dot->getRxOutput()).c_str());
+    if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) {
+        if (!data.empty()) {
+            if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) {
+                for (size_t i = 0; i < data.size(); i++) {
+                    CommandTerminal::Serial()->writef("%02x", data[i]);
+                }
+                CommandTerminal::Serial()->writef("\r\n");
+            } else {
+                CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str());
+            }
+        }
     }
 
     return 0;
@@ -28,6 +31,6 @@
 	if (args.size() == 1)
 		return true;
 
-    setErrorMessage("Invalid arguments");
+    CommandTerminal::setErrorMessage("Invalid arguments");
     return false;
 }