few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdJoinDelay.cpp@11:77b7911263da, 2016-10-25 (annotated)
- Committer:
- serg838
- Date:
- Tue Oct 25 05:39:39 2016 +0000
- Revision:
- 11:77b7911263da
- Parent:
- 9:ff62b20f7000
RTS/CTS changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
9:ff62b20f7000 | 1 | /* |
Mike Fiore |
9:ff62b20f7000 | 2 | * CmdJoinDelay.cpp |
Mike Fiore |
9:ff62b20f7000 | 3 | * |
Mike Fiore |
9:ff62b20f7000 | 4 | * Created on: Nov 4, 2015 |
Mike Fiore |
9:ff62b20f7000 | 5 | * Author: jreiss |
Mike Fiore |
9:ff62b20f7000 | 6 | */ |
Mike Fiore |
9:ff62b20f7000 | 7 | |
Mike Fiore |
9:ff62b20f7000 | 8 | #include "CmdJoinDelay.h" |
Mike Fiore |
9:ff62b20f7000 | 9 | |
Mike Fiore |
9:ff62b20f7000 | 10 | CmdJoinDelay::CmdJoinDelay(mDot* dot, mts::MTSSerial& serial) |
Mike Fiore |
9:ff62b20f7000 | 11 | : |
Mike Fiore |
9:ff62b20f7000 | 12 | Command(dot, "Join Delay", "AT+JD", "Number of seconds before receive windows are opened for join (1 - 15)"), |
Mike Fiore |
9:ff62b20f7000 | 13 | _serial(serial) |
Mike Fiore |
9:ff62b20f7000 | 14 | { |
Mike Fiore |
9:ff62b20f7000 | 15 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
9:ff62b20f7000 | 16 | _usage = "(1-15)"; |
Mike Fiore |
9:ff62b20f7000 | 17 | _queryable = true; |
Mike Fiore |
9:ff62b20f7000 | 18 | } |
Mike Fiore |
9:ff62b20f7000 | 19 | |
Mike Fiore |
9:ff62b20f7000 | 20 | CmdJoinDelay::~CmdJoinDelay() |
Mike Fiore |
9:ff62b20f7000 | 21 | { |
Mike Fiore |
9:ff62b20f7000 | 22 | // TODO Auto-generated destructor stub |
Mike Fiore |
9:ff62b20f7000 | 23 | } |
Mike Fiore |
9:ff62b20f7000 | 24 | |
Mike Fiore |
9:ff62b20f7000 | 25 | uint32_t CmdJoinDelay::action(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 26 | if (args.size() == 1) { |
Mike Fiore |
9:ff62b20f7000 | 27 | if (_dot->getVerbose()) |
Mike Fiore |
9:ff62b20f7000 | 28 | _serial.writef("Join Delay: "); |
Mike Fiore |
9:ff62b20f7000 | 29 | |
Mike Fiore |
9:ff62b20f7000 | 30 | _serial.writef("%u\r\n", _dot->getJoinDelay()); |
Mike Fiore |
9:ff62b20f7000 | 31 | } else if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 32 | int32_t code; |
Mike Fiore |
9:ff62b20f7000 | 33 | uint32_t joinDelay; |
Mike Fiore |
9:ff62b20f7000 | 34 | sscanf(args[1].c_str(), "%lu", &joinDelay); |
Mike Fiore |
9:ff62b20f7000 | 35 | |
Mike Fiore |
9:ff62b20f7000 | 36 | if ((code = _dot->setJoinDelay(joinDelay)) != mDot::MDOT_OK) { |
Mike Fiore |
9:ff62b20f7000 | 37 | |
Mike Fiore |
9:ff62b20f7000 | 38 | setErrorMessage(_dot->getLastError());; |
Mike Fiore |
9:ff62b20f7000 | 39 | return 1; |
Mike Fiore |
9:ff62b20f7000 | 40 | } |
Mike Fiore |
9:ff62b20f7000 | 41 | } |
Mike Fiore |
9:ff62b20f7000 | 42 | return 0; |
Mike Fiore |
9:ff62b20f7000 | 43 | } |
Mike Fiore |
9:ff62b20f7000 | 44 | |
Mike Fiore |
9:ff62b20f7000 | 45 | bool CmdJoinDelay::verify(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 46 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 47 | return true; |
Mike Fiore |
9:ff62b20f7000 | 48 | |
Mike Fiore |
9:ff62b20f7000 | 49 | if (args.size() == 2) { |
Mike Fiore |
9:ff62b20f7000 | 50 | |
Mike Fiore |
9:ff62b20f7000 | 51 | int joinDelay; |
Mike Fiore |
9:ff62b20f7000 | 52 | if (sscanf(args[1].c_str(), "%d", &joinDelay) == 1) { |
Mike Fiore |
9:ff62b20f7000 | 53 | if (joinDelay > 15 || joinDelay < 1) { |
Mike Fiore |
9:ff62b20f7000 | 54 | setErrorMessage("Invalid join delay, expects (1-15)"); |
Mike Fiore |
9:ff62b20f7000 | 55 | return false; |
Mike Fiore |
9:ff62b20f7000 | 56 | } |
Mike Fiore |
9:ff62b20f7000 | 57 | return true; |
Mike Fiore |
9:ff62b20f7000 | 58 | } |
Mike Fiore |
9:ff62b20f7000 | 59 | } |
Mike Fiore |
9:ff62b20f7000 | 60 | |
Mike Fiore |
9:ff62b20f7000 | 61 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 62 | return false; |
Mike Fiore |
9:ff62b20f7000 | 63 | } |