Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CmdReceiveContinuous.cpp
00001 #include "CmdReceiveContinuous.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdReceiveContinuous::CmdReceiveContinuous() 00005 : 00006 Command("Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)", "out: (string:242) or (hex:242)") 00007 { 00008 } 00009 00010 uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) { 00011 std::vector<uint8_t> data; 00012 00013 std::string escape_buffer; 00014 char ch; 00015 00016 while (true) { 00017 CommandTerminal::Dot()->openRxWindow(0); 00018 00019 osDelay(1000); 00020 00021 if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) { 00022 if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) { 00023 for (size_t i = 0; i < data.size(); i++) { 00024 CommandTerminal::Serial()->writef("%02x", data[i]); 00025 } 00026 CommandTerminal::Serial()->writef("\r\n"); 00027 } else { 00028 CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str()); 00029 } 00030 data.clear(); 00031 } 00032 00033 while (CommandTerminal::Serial()->readable()) { 00034 CommandTerminal::Serial()->read(&ch, 1); 00035 escape_buffer += ch; 00036 if (escape_buffer == CommandTerminal::escape_sequence) { 00037 CommandTerminal::Dot()->closeRxWindow(); 00038 return 0; 00039 } 00040 00041 osDelay(50); 00042 } 00043 00044 escape_buffer.clear(); 00045 } 00046 00047 return 0; 00048 } 00049 00050 bool CmdReceiveContinuous::verify(std::vector<std::string> args) { 00051 if (args.size() == 1) 00052 return true; 00053 00054 CommandTerminal::setErrorMessage("Invalid arguments"); 00055 return false; 00056 }
Generated on Tue Jul 12 2022 20:40:04 by
