mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Revision:
14:f9a77400b622
Parent:
9:ff62b20f7000
--- a/CommandTerminal/CmdReceiveContinuous.cpp	Fri Nov 04 19:10:24 2016 +0000
+++ b/CommandTerminal/CmdReceiveContinuous.cpp	Fri Nov 04 14:25:43 2016 -0500
@@ -1,12 +1,10 @@
 #include "CmdReceiveContinuous.h"
 #include "CommandTerminal.h"
 
-CmdReceiveContinuous::CmdReceiveContinuous(mDot* dot, mts::MTSSerial& serial)
+CmdReceiveContinuous::CmdReceiveContinuous()
 :
-  Command(dot, "Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)"),
-  _serial(serial) {
-    _help = std::string(text()) + ": " + std::string(desc());
-    _usage = "out: (string:242) or (hex:242)";
+  Command("Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)", "out: (string:242) or (hex:242)")
+   {
 }
 
 uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) {
@@ -16,24 +14,29 @@
     char ch;
 
     while (true) {
-
-        _dot->openRxWindow(0);
+        CommandTerminal::Dot()->openRxWindow(0);
 
         osDelay(1000);
 
-        if (_dot->recv(data) == mDot::MDOT_OK) {
-            if (_dot->getVerbose())
-                _serial.writef("Packet data:\r\n");
-            _serial.writef("%s\r\n", CommandTerminal::formatPacketData(data, _dot->getRxOutput()).c_str());
-
+        if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) {
+            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());
+            }
             data.clear();
         }
 
-        while (_serial.readable()) {
-            _serial.read(&ch, 1);
+        while (CommandTerminal::Serial()->readable()) {
+            CommandTerminal::Serial()->read(&ch, 1);
             escape_buffer += ch;
-            if (escape_buffer == CommandTerminal::escape_sequence)
+            if (escape_buffer == CommandTerminal::escape_sequence) {
+                CommandTerminal::Dot()->closeRxWindow();
                 return 0;
+            }
 
             osDelay(50);
         }
@@ -48,6 +51,6 @@
     if (args.size() == 1)
         return true;
 
-    setErrorMessage("Invalid arguments");
+    CommandTerminal::setErrorMessage("Invalid arguments");
     return false;
 }