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: libmDot-Custom MTS-Serial
Fork of mDot_AT_firmware_CUSTOM by
To change channel plans replace AS923 with AU915, EU868, KR920 or US915 on line 15
#define CHANNEL_PLAN CP_AS923
CommandTerminal/CmdReceiveContinuous.cpp@14:e80ace5a6834, 2016-08-29 (annotated)
- Committer:
- Jason Reiss
- Date:
- Mon Aug 29 10:05:41 2016 -0500
- Revision:
- 14:e80ace5a6834
- Parent:
- 9:ff62b20f7000
Update commands
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdReceiveContinuous.h" |
| Mike Fiore |
1:e52ae6584f1c | 2 | #include "CommandTerminal.h" |
| Mike Fiore |
1:e52ae6584f1c | 3 | |
| Jason Reiss |
14:e80ace5a6834 | 4 | CmdReceiveContinuous::CmdReceiveContinuous() |
| Mike Fiore |
4:666017851052 | 5 | : |
| Jason Reiss |
14:e80ace5a6834 | 6 | Command("Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)", "out: (string:242) or (hex:242)") |
| Jason Reiss |
14:e80ace5a6834 | 7 | { |
| Mike Fiore |
1:e52ae6584f1c | 8 | } |
| Mike Fiore |
1:e52ae6584f1c | 9 | |
| Mike Fiore |
4:666017851052 | 10 | uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) { |
| Mike Fiore |
1:e52ae6584f1c | 11 | std::vector<uint8_t> data; |
| Mike Fiore |
1:e52ae6584f1c | 12 | |
| Mike Fiore |
1:e52ae6584f1c | 13 | std::string escape_buffer; |
| Mike Fiore |
1:e52ae6584f1c | 14 | char ch; |
| Mike Fiore |
1:e52ae6584f1c | 15 | |
| Mike Fiore |
4:666017851052 | 16 | while (true) { |
| Jason Reiss |
14:e80ace5a6834 | 17 | CommandTerminal::Dot()->openRxWindow(0); |
| Mike Fiore |
4:666017851052 | 18 | |
| Mike Fiore |
4:666017851052 | 19 | osDelay(1000); |
| Mike Fiore |
9:ff62b20f7000 | 20 | |
| Jason Reiss |
14:e80ace5a6834 | 21 | if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) { |
| Jason Reiss |
14:e80ace5a6834 | 22 | if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) { |
| Jason Reiss |
14:e80ace5a6834 | 23 | for (size_t i = 0; i < data.size(); i++) { |
| Jason Reiss |
14:e80ace5a6834 | 24 | CommandTerminal::Serial()->writef("%02x", data[i]); |
| Jason Reiss |
14:e80ace5a6834 | 25 | } |
| Jason Reiss |
14:e80ace5a6834 | 26 | CommandTerminal::Serial()->writef("\r\n"); |
| Jason Reiss |
14:e80ace5a6834 | 27 | } else { |
| Jason Reiss |
14:e80ace5a6834 | 28 | CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str()); |
| Jason Reiss |
14:e80ace5a6834 | 29 | } |
| Mike Fiore |
1:e52ae6584f1c | 30 | data.clear(); |
| Mike Fiore |
1:e52ae6584f1c | 31 | } |
| Mike Fiore |
1:e52ae6584f1c | 32 | |
| Jason Reiss |
14:e80ace5a6834 | 33 | while (CommandTerminal::Serial()->readable()) { |
| Jason Reiss |
14:e80ace5a6834 | 34 | CommandTerminal::Serial()->read(&ch, 1); |
| Mike Fiore |
1:e52ae6584f1c | 35 | escape_buffer += ch; |
| Jason Reiss |
14:e80ace5a6834 | 36 | if (escape_buffer == CommandTerminal::escape_sequence) { |
| Jason Reiss |
14:e80ace5a6834 | 37 | CommandTerminal::Dot()->closeRxWindow(); |
| Mike Fiore |
1:e52ae6584f1c | 38 | return 0; |
| Jason Reiss |
14:e80ace5a6834 | 39 | } |
| Mike Fiore |
1:e52ae6584f1c | 40 | |
| Mike Fiore |
1:e52ae6584f1c | 41 | osDelay(50); |
| Mike Fiore |
1:e52ae6584f1c | 42 | } |
| Mike Fiore |
1:e52ae6584f1c | 43 | |
| Mike Fiore |
1:e52ae6584f1c | 44 | escape_buffer.clear(); |
| Mike Fiore |
1:e52ae6584f1c | 45 | } |
| Mike Fiore |
1:e52ae6584f1c | 46 | |
| Mike Fiore |
1:e52ae6584f1c | 47 | return 0; |
| Mike Fiore |
1:e52ae6584f1c | 48 | } |
| Mike Fiore |
1:e52ae6584f1c | 49 | |
| Mike Fiore |
4:666017851052 | 50 | bool CmdReceiveContinuous::verify(std::vector<std::string> args) { |
| Mike Fiore |
1:e52ae6584f1c | 51 | if (args.size() == 1) |
| Mike Fiore |
1:e52ae6584f1c | 52 | return true; |
| Mike Fiore |
1:e52ae6584f1c | 53 | |
| Jason Reiss |
14:e80ace5a6834 | 54 | CommandTerminal::setErrorMessage("Invalid arguments"); |
| Mike Fiore |
1:e52ae6584f1c | 55 | return false; |
| Mike Fiore |
1:e52ae6584f1c | 56 | } |
