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 mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
CmdReceiveContinuous.cpp
00001 #include "CmdReceiveContinuous.h" 00002 #include "CommandTerminal.h" 00003 00004 CmdReceiveContinuous::CmdReceiveContinuous(mDot* dot, mts::MTSSerial& serial) 00005 : 00006 Command(dot, "Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)"), 00007 _serial(serial) { 00008 _help = std::string(text()) + ": " + std::string(desc()); 00009 _usage = "out: (string:242) or (hex:242)"; 00010 } 00011 00012 uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) { 00013 std::vector<uint8_t> data; 00014 00015 std::string escape_buffer; 00016 char ch; 00017 00018 while (true) { 00019 00020 _dot->openRxWindow(0); 00021 00022 osDelay(1000); 00023 00024 if (_dot->recv(data) == mDot::MDOT_OK) { 00025 if (_dot->getVerbose()) 00026 _serial.writef("Packet data:\r\n"); 00027 _serial.writef("%s\r\n", CommandTerminal::formatPacketData(data, _dot->getRxOutput()).c_str()); 00028 00029 data.clear(); 00030 } 00031 00032 while (_serial.readable()) { 00033 _serial.read(&ch, 1); 00034 escape_buffer += ch; 00035 if (escape_buffer == CommandTerminal::escape_sequence) 00036 return 0; 00037 00038 osDelay(50); 00039 } 00040 00041 escape_buffer.clear(); 00042 } 00043 00044 return 0; 00045 } 00046 00047 bool CmdReceiveContinuous::verify(std::vector<std::string> args) { 00048 if (args.size() == 1) 00049 return true; 00050 00051 setErrorMessage("Invalid arguments"); 00052 return false; 00053 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
