few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdJoinRetries.cpp@9:ff62b20f7000, 2016-04-04 (annotated)
- Committer:
- Mike Fiore
- Date:
- Mon Apr 04 09:00:31 2016 -0500
- Revision:
- 9:ff62b20f7000
- Parent:
- 1:e52ae6584f1c
update to version 1.0.8 of AT firmware
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
1:e52ae6584f1c | 1 | #include "CmdJoinRetries.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | |
Mike Fiore |
1:e52ae6584f1c | 3 | CmdJoinRetries::CmdJoinRetries(mDot* dot, mts::MTSSerial& serial) |
Mike Fiore |
1:e52ae6584f1c | 4 | : |
Mike Fiore |
9:ff62b20f7000 | 5 | Command(dot, "Join Retries", "AT+JR", "US915 AUTO_OTA Frequency sub-band search retries (0:disable,1-255:attempts)"), |
Mike Fiore |
1:e52ae6584f1c | 6 | _serial(serial) { |
Mike Fiore |
1:e52ae6584f1c | 7 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
1:e52ae6584f1c | 8 | _usage = "(0-255)"; |
Mike Fiore |
1:e52ae6584f1c | 9 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 10 | } |
Mike Fiore |
1:e52ae6584f1c | 11 | |
Mike Fiore |
1:e52ae6584f1c | 12 | uint32_t CmdJoinRetries::action(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 13 | if (args.size() == 1) { |
Mike Fiore |
1:e52ae6584f1c | 14 | if (_dot->getVerbose()) |
Mike Fiore |
1:e52ae6584f1c | 15 | _serial.writef("Join Retries: "); |
Mike Fiore |
1:e52ae6584f1c | 16 | |
Mike Fiore |
1:e52ae6584f1c | 17 | _serial.writef("%u\r\n", _dot->getJoinRetries()); |
Mike Fiore |
1:e52ae6584f1c | 18 | } else if (args.size() == 2) { |
Mike Fiore |
1:e52ae6584f1c | 19 | int32_t code; |
Mike Fiore |
9:ff62b20f7000 | 20 | int retries; |
Mike Fiore |
9:ff62b20f7000 | 21 | sscanf(args[1].c_str(), "%d", &retries); |
Mike Fiore |
1:e52ae6584f1c | 22 | |
Mike Fiore |
1:e52ae6584f1c | 23 | if ((code = _dot->setJoinRetries(retries)) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
9:ff62b20f7000 | 25 | setErrorMessage(_dot->getLastError());; |
Mike Fiore |
1:e52ae6584f1c | 26 | return 1; |
Mike Fiore |
1:e52ae6584f1c | 27 | } |
Mike Fiore |
1:e52ae6584f1c | 28 | } |
Mike Fiore |
1:e52ae6584f1c | 29 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 30 | } |
Mike Fiore |
1:e52ae6584f1c | 31 | |
Mike Fiore |
1:e52ae6584f1c | 32 | bool CmdJoinRetries::verify(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 33 | if (args.size() == 1) |
Mike Fiore |
1:e52ae6584f1c | 34 | return true; |
Mike Fiore |
1:e52ae6584f1c | 35 | |
Mike Fiore |
1:e52ae6584f1c | 36 | if (args.size() == 2) { |
Mike Fiore |
1:e52ae6584f1c | 37 | |
Mike Fiore |
9:ff62b20f7000 | 38 | int retries; |
Mike Fiore |
9:ff62b20f7000 | 39 | if (sscanf(args[1].c_str(), "%d", &retries) == 1) { |
Mike Fiore |
9:ff62b20f7000 | 40 | if (retries < 0 || retries > 255) { |
Mike Fiore |
1:e52ae6584f1c | 41 | setErrorMessage("Invalid retries, expects (0-255)"); |
Mike Fiore |
1:e52ae6584f1c | 42 | return false; |
Mike Fiore |
1:e52ae6584f1c | 43 | } |
Mike Fiore |
1:e52ae6584f1c | 44 | return true; |
Mike Fiore |
1:e52ae6584f1c | 45 | } |
Mike Fiore |
1:e52ae6584f1c | 46 | } |
Mike Fiore |
1:e52ae6584f1c | 47 | |
Mike Fiore |
1:e52ae6584f1c | 48 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
1:e52ae6584f1c | 49 | return false; |
Mike Fiore |
1:e52ae6584f1c | 50 | } |
Mike Fiore |
1:e52ae6584f1c | 51 |