![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CmdJoinByteOrder.cpp@4:666017851052, 2015-08-18 (annotated)
- Committer:
- Mike Fiore
- Date:
- Tue Aug 18 11:21:43 2015 -0500
- Revision:
- 4:666017851052
- Child:
- 9:ff62b20f7000
update mdot-firmware to 0.1.2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Mike Fiore |
4:666017851052 | 1 | #include "CmdJoinByteOrder.h" |
Mike Fiore |
4:666017851052 | 2 | |
Mike Fiore |
4:666017851052 | 3 | CmdJoinByteOrder::CmdJoinByteOrder(mDot* dot, mts::MTSSerial& serial) : |
Mike Fiore |
4:666017851052 | 4 | Command(dot, "Join Byte Order", "AT+JBO", "Send EUI's in join request with configured byte ordering (0:LSB,1:MSB)"), _serial(serial) |
Mike Fiore |
4:666017851052 | 5 | { |
Mike Fiore |
4:666017851052 | 6 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
4:666017851052 | 7 | _usage = "(0:LSB,1:MSB)"; |
Mike Fiore |
4:666017851052 | 8 | _queryable = true; |
Mike Fiore |
4:666017851052 | 9 | } |
Mike Fiore |
4:666017851052 | 10 | |
Mike Fiore |
4:666017851052 | 11 | uint32_t CmdJoinByteOrder::action(std::vector<std::string> args) |
Mike Fiore |
4:666017851052 | 12 | { |
Mike Fiore |
4:666017851052 | 13 | if (args.size() == 1) |
Mike Fiore |
4:666017851052 | 14 | { |
Mike Fiore |
4:666017851052 | 15 | if (_dot->getVerbose()) |
Mike Fiore |
4:666017851052 | 16 | _serial.writef("Join Byte Order: "); |
Mike Fiore |
4:666017851052 | 17 | |
Mike Fiore |
4:666017851052 | 18 | _serial.writef("%d\r\n", _dot->getJoinByteOrder()); |
Mike Fiore |
4:666017851052 | 19 | } |
Mike Fiore |
4:666017851052 | 20 | else if (args.size() == 2) |
Mike Fiore |
4:666017851052 | 21 | { |
Mike Fiore |
4:666017851052 | 22 | int32_t code; |
Mike Fiore |
4:666017851052 | 23 | mDot::JoinByteOrder order = mDot::LSB; |
Mike Fiore |
4:666017851052 | 24 | |
Mike Fiore |
4:666017851052 | 25 | if (args[1] == "1") |
Mike Fiore |
4:666017851052 | 26 | order = mDot::MSB; |
Mike Fiore |
4:666017851052 | 27 | |
Mike Fiore |
4:666017851052 | 28 | if ((code = _dot->setJoinByteOrder(order)) != mDot::MDOT_OK) |
Mike Fiore |
4:666017851052 | 29 | { |
Mike Fiore |
4:666017851052 | 30 | std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); |
Mike Fiore |
4:666017851052 | 31 | setErrorMessage(error); |
Mike Fiore |
4:666017851052 | 32 | return 1; |
Mike Fiore |
4:666017851052 | 33 | } |
Mike Fiore |
4:666017851052 | 34 | } |
Mike Fiore |
4:666017851052 | 35 | |
Mike Fiore |
4:666017851052 | 36 | return 0; |
Mike Fiore |
4:666017851052 | 37 | } |
Mike Fiore |
4:666017851052 | 38 | |
Mike Fiore |
4:666017851052 | 39 | bool CmdJoinByteOrder::verify(std::vector<std::string> args) |
Mike Fiore |
4:666017851052 | 40 | { |
Mike Fiore |
4:666017851052 | 41 | if (args.size() == 1) |
Mike Fiore |
4:666017851052 | 42 | return true; |
Mike Fiore |
4:666017851052 | 43 | |
Mike Fiore |
4:666017851052 | 44 | if (args.size() == 2) |
Mike Fiore |
4:666017851052 | 45 | { |
Mike Fiore |
4:666017851052 | 46 | if (args[1] != "0" && args[1] != "1") { |
Mike Fiore |
4:666017851052 | 47 | setErrorMessage("Invalid argument"); |
Mike Fiore |
4:666017851052 | 48 | return false; |
Mike Fiore |
4:666017851052 | 49 | } |
Mike Fiore |
4:666017851052 | 50 | |
Mike Fiore |
4:666017851052 | 51 | return true; |
Mike Fiore |
4:666017851052 | 52 | } |
Mike Fiore |
4:666017851052 | 53 | |
Mike Fiore |
4:666017851052 | 54 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
4:666017851052 | 55 | return false; |
Mike Fiore |
4:666017851052 | 56 | } |