This mDot firmware will allow USB to directly utilize AT command without the need the use of RS232 DB9 port.
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
Diff: CommandTerminal/CmdRepeat.cpp
- Revision:
- 9:ff62b20f7000
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CommandTerminal/CmdRepeat.cpp Mon Apr 04 09:00:31 2016 -0500 @@ -0,0 +1,61 @@ +#include "CmdRepeat.h" + +CmdRepeat::CmdRepeat(mDot* dot, mts::MTSSerial& serial) : + Command(dot, "Packet Repeats", "AT+REP", "Configure number of times to repeat a packet"), _serial(serial) +{ + _help = std::string(text()) + ": " + std::string(desc()); + _usage = "(0-15)"; + _queryable = true; +} + +uint32_t CmdRepeat::action(std::vector<std::string> args) +{ + if (args.size() == 1) + { + if (_dot->getVerbose()) + _serial.writef("Packet Repeats: "); + + _serial.writef("%u\r\n", _dot->getRepeat()); + } + else if (args.size() == 2) + { + int32_t code; + int repeat; + sscanf(args[1].c_str(), "%d", &repeat); + + if ((code = _dot->setRepeat(repeat)) != mDot::MDOT_OK) + { + + setErrorMessage(_dot->getLastError());; + return 1; + } + } + + return 0; +} + +bool CmdRepeat::verify(std::vector<std::string> args) +{ + if (args.size() == 1) + return true; + + if (args.size() == 2) + { + int repeat; + if (sscanf(args[1].c_str(), "%d", &repeat) != 1) { + setErrorMessage("Invalid argument"); + return false; + } + + if (repeat < 0 || repeat > 15) + { + setErrorMessage("Invalid repeats, expects (0-15)"); + return false; + } + + return true; + } + + setErrorMessage("Invalid arguments"); + return false; +}