firm newest

Dependencies:   MTS-Serial libmDot-dev-mbed5-deprecated

Committer:
nguyenhoang9x5555
Date:
Thu Oct 18 04:18:48 2018 +0000
Revision:
0:3c869a8cb8f8
DOT AT FIRMWARE 18102018

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdReceiveContinuous.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2 #include "CommandTerminal.h"
nguyenhoang9x5555 0:3c869a8cb8f8 3
nguyenhoang9x5555 0:3c869a8cb8f8 4 CmdReceiveContinuous::CmdReceiveContinuous()
nguyenhoang9x5555 0:3c869a8cb8f8 5 :
nguyenhoang9x5555 0:3c869a8cb8f8 6 Command("Receive Continuous", "AT+RECVC", "Continuously receive and display packets. (escape sequence: +++)", "out: (string:242) or (hex:242)")
nguyenhoang9x5555 0:3c869a8cb8f8 7 {
nguyenhoang9x5555 0:3c869a8cb8f8 8 }
nguyenhoang9x5555 0:3c869a8cb8f8 9
nguyenhoang9x5555 0:3c869a8cb8f8 10 uint32_t CmdReceiveContinuous::action(std::vector<std::string> args) {
nguyenhoang9x5555 0:3c869a8cb8f8 11 std::vector<uint8_t> data;
nguyenhoang9x5555 0:3c869a8cb8f8 12
nguyenhoang9x5555 0:3c869a8cb8f8 13 std::string escape_buffer;
nguyenhoang9x5555 0:3c869a8cb8f8 14 char ch;
nguyenhoang9x5555 0:3c869a8cb8f8 15
nguyenhoang9x5555 0:3c869a8cb8f8 16 while (true) {
nguyenhoang9x5555 0:3c869a8cb8f8 17 CommandTerminal::Dot()->openRxWindow(0);
nguyenhoang9x5555 0:3c869a8cb8f8 18
nguyenhoang9x5555 0:3c869a8cb8f8 19 osDelay(1000);
nguyenhoang9x5555 0:3c869a8cb8f8 20
nguyenhoang9x5555 0:3c869a8cb8f8 21 if (CommandTerminal::Dot()->recv(data) == mDot::MDOT_OK) {
nguyenhoang9x5555 0:3c869a8cb8f8 22 if (CommandTerminal::Dot()->getRxOutput() == mDot::HEXADECIMAL) {
nguyenhoang9x5555 0:3c869a8cb8f8 23 for (size_t i = 0; i < data.size(); i++) {
nguyenhoang9x5555 0:3c869a8cb8f8 24 CommandTerminal::Serial()->writef("%02x", data[i]);
nguyenhoang9x5555 0:3c869a8cb8f8 25 }
nguyenhoang9x5555 0:3c869a8cb8f8 26 CommandTerminal::Serial()->writef("\r\n");
nguyenhoang9x5555 0:3c869a8cb8f8 27 } else {
nguyenhoang9x5555 0:3c869a8cb8f8 28 CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::formatPacketData(data, CommandTerminal::Dot()->getRxOutput()).c_str());
nguyenhoang9x5555 0:3c869a8cb8f8 29 }
nguyenhoang9x5555 0:3c869a8cb8f8 30 data.clear();
nguyenhoang9x5555 0:3c869a8cb8f8 31 }
nguyenhoang9x5555 0:3c869a8cb8f8 32
nguyenhoang9x5555 0:3c869a8cb8f8 33 while (CommandTerminal::Serial()->readable()) {
nguyenhoang9x5555 0:3c869a8cb8f8 34 CommandTerminal::Serial()->read(&ch, 1);
nguyenhoang9x5555 0:3c869a8cb8f8 35 escape_buffer += ch;
nguyenhoang9x5555 0:3c869a8cb8f8 36 if (escape_buffer == CommandTerminal::escape_sequence) {
nguyenhoang9x5555 0:3c869a8cb8f8 37 CommandTerminal::Dot()->closeRxWindow();
nguyenhoang9x5555 0:3c869a8cb8f8 38 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 39 }
nguyenhoang9x5555 0:3c869a8cb8f8 40
nguyenhoang9x5555 0:3c869a8cb8f8 41 osDelay(50);
nguyenhoang9x5555 0:3c869a8cb8f8 42 }
nguyenhoang9x5555 0:3c869a8cb8f8 43
nguyenhoang9x5555 0:3c869a8cb8f8 44 escape_buffer.clear();
nguyenhoang9x5555 0:3c869a8cb8f8 45 }
nguyenhoang9x5555 0:3c869a8cb8f8 46
nguyenhoang9x5555 0:3c869a8cb8f8 47 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 48 }
nguyenhoang9x5555 0:3c869a8cb8f8 49
nguyenhoang9x5555 0:3c869a8cb8f8 50 bool CmdReceiveContinuous::verify(std::vector<std::string> args) {
nguyenhoang9x5555 0:3c869a8cb8f8 51 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 52 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 53
nguyenhoang9x5555 0:3c869a8cb8f8 54 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 55 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 56 }