few changes for RTS/CTS control
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_AT_firmware by
CommandTerminal/CmdTxChannel.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 |
1:e52ae6584f1c | 1 | #include "CmdTxChannel.h" |
Mike Fiore |
1:e52ae6584f1c | 2 | |
Mike Fiore |
1:e52ae6584f1c | 3 | CmdTxChannel::CmdTxChannel(mDot* dot, mts::MTSSerial& serial) |
Mike Fiore |
1:e52ae6584f1c | 4 | : |
Mike Fiore |
1:e52ae6584f1c | 5 | Command(dot, "Tx Channels", "AT+TXCH", "List Tx channel frequencies for sub-band"), |
Mike Fiore |
1:e52ae6584f1c | 6 | _serial(serial) { |
Mike Fiore |
1:e52ae6584f1c | 7 | _help = std::string(text()) + ": " + std::string(desc()); |
Mike Fiore |
9:ff62b20f7000 | 8 | _usage = "<INDEX>,<FREQUENCY>,<DR_RANGE>"; |
Mike Fiore |
1:e52ae6584f1c | 9 | _queryable = true; |
Mike Fiore |
1:e52ae6584f1c | 10 | } |
Mike Fiore |
1:e52ae6584f1c | 11 | |
Mike Fiore |
1:e52ae6584f1c | 12 | uint32_t CmdTxChannel::action(std::vector<std::string> args) { |
Mike Fiore |
1:e52ae6584f1c | 13 | if (args.size() == 1) { |
Mike Fiore |
1:e52ae6584f1c | 14 | std::vector<uint32_t> channels = _dot->getChannels(); |
Mike Fiore |
1:e52ae6584f1c | 15 | |
Mike Fiore |
9:ff62b20f7000 | 16 | if (_dot->getFrequencyBand() == mDot::FB_868) { |
Mike Fiore |
9:ff62b20f7000 | 17 | for (int i = 0; i < 16; i++) { |
Mike Fiore |
9:ff62b20f7000 | 18 | _serial.writef("%d: %d 125k\r\n", i, channels[i]); |
Mike Fiore |
9:ff62b20f7000 | 19 | } |
Mike Fiore |
9:ff62b20f7000 | 20 | _serial.writef("D: %d 125k\r\n", channels[8]); |
Mike Fiore |
1:e52ae6584f1c | 21 | |
Mike Fiore |
1:e52ae6584f1c | 22 | } else { |
Mike Fiore |
9:ff62b20f7000 | 23 | |
Mike Fiore |
9:ff62b20f7000 | 24 | for (int i = 0; i < 8; i++) { |
Mike Fiore |
9:ff62b20f7000 | 25 | _serial.writef("%d: %d 125k\r\n", i, channels[i]); |
Mike Fiore |
9:ff62b20f7000 | 26 | } |
Mike Fiore |
1:e52ae6584f1c | 27 | |
Mike Fiore |
1:e52ae6584f1c | 28 | _serial.writef("U: %d 500k\r\n", channels[8]); |
Mike Fiore |
1:e52ae6584f1c | 29 | _serial.writef("D: %d 500k\r\n", channels[9]); |
Mike Fiore |
1:e52ae6584f1c | 30 | } |
Mike Fiore |
1:e52ae6584f1c | 31 | } |
Mike Fiore |
1:e52ae6584f1c | 32 | |
Mike Fiore |
9:ff62b20f7000 | 33 | if (args.size() == 4) { |
Mike Fiore |
9:ff62b20f7000 | 34 | int index; |
Mike Fiore |
9:ff62b20f7000 | 35 | int frequency; |
Mike Fiore |
9:ff62b20f7000 | 36 | int datarateRange; |
Mike Fiore |
9:ff62b20f7000 | 37 | |
Mike Fiore |
9:ff62b20f7000 | 38 | sscanf(args[1].c_str(), "%d", &index); |
Mike Fiore |
9:ff62b20f7000 | 39 | sscanf(args[2].c_str(), "%d", &frequency); |
Mike Fiore |
9:ff62b20f7000 | 40 | sscanf(args[3].c_str(), "%02x", &datarateRange); |
Mike Fiore |
9:ff62b20f7000 | 41 | |
Mike Fiore |
9:ff62b20f7000 | 42 | _dot->addChannel(index, frequency, datarateRange); |
Mike Fiore |
9:ff62b20f7000 | 43 | } |
Mike Fiore |
9:ff62b20f7000 | 44 | |
Mike Fiore |
1:e52ae6584f1c | 45 | return 0; |
Mike Fiore |
1:e52ae6584f1c | 46 | } |
Mike Fiore |
1:e52ae6584f1c | 47 | |
Mike Fiore |
9:ff62b20f7000 | 48 | bool CmdTxChannel::verify(std::vector<std::string> args) { |
Mike Fiore |
9:ff62b20f7000 | 49 | if (args.size() == 1) |
Mike Fiore |
9:ff62b20f7000 | 50 | return true; |
Mike Fiore |
9:ff62b20f7000 | 51 | |
Mike Fiore |
9:ff62b20f7000 | 52 | if (args.size() == 4) { |
Mike Fiore |
9:ff62b20f7000 | 53 | |
Mike Fiore |
9:ff62b20f7000 | 54 | int index; |
Mike Fiore |
9:ff62b20f7000 | 55 | int frequency; |
Mike Fiore |
9:ff62b20f7000 | 56 | int datarateRange; |
Mike Fiore |
9:ff62b20f7000 | 57 | |
Mike Fiore |
9:ff62b20f7000 | 58 | sscanf(args[1].c_str(), "%d", &index); |
Mike Fiore |
9:ff62b20f7000 | 59 | sscanf(args[2].c_str(), "%d", &frequency); |
Mike Fiore |
9:ff62b20f7000 | 60 | sscanf(args[3].c_str(), "%02x", &datarateRange); |
Mike Fiore |
9:ff62b20f7000 | 61 | |
Mike Fiore |
9:ff62b20f7000 | 62 | if (_dot->getFrequencyBand() == mDot::FB_868) { |
Mike Fiore |
9:ff62b20f7000 | 63 | if (index < 3 || index > 15) { |
Mike Fiore |
9:ff62b20f7000 | 64 | setErrorMessage("Invalid index, expects (3-15)"); |
Mike Fiore |
9:ff62b20f7000 | 65 | return false; |
Mike Fiore |
9:ff62b20f7000 | 66 | } |
Mike Fiore |
9:ff62b20f7000 | 67 | |
Mike Fiore |
9:ff62b20f7000 | 68 | if (frequency != 0 && (frequency < 863000000 || frequency > 870000000)) { |
Mike Fiore |
9:ff62b20f7000 | 69 | setErrorMessage("Invalid frequency, expects (863000000-870000000)"); |
Mike Fiore |
9:ff62b20f7000 | 70 | return false; |
Mike Fiore |
9:ff62b20f7000 | 71 | } |
Mike Fiore |
9:ff62b20f7000 | 72 | } else { |
Mike Fiore |
9:ff62b20f7000 | 73 | setErrorMessage("US915 Channels cannot be changed, use AT+FSB to limit"); |
Mike Fiore |
9:ff62b20f7000 | 74 | return false; |
Mike Fiore |
9:ff62b20f7000 | 75 | } |
Mike Fiore |
9:ff62b20f7000 | 76 | |
Mike Fiore |
9:ff62b20f7000 | 77 | return true; |
Mike Fiore |
9:ff62b20f7000 | 78 | } else { |
Mike Fiore |
9:ff62b20f7000 | 79 | setErrorMessage("Invalid arguments"); |
Mike Fiore |
9:ff62b20f7000 | 80 | return false; |
Mike Fiore |
9:ff62b20f7000 | 81 | } |
Mike Fiore |
9:ff62b20f7000 | 82 | |
Mike Fiore |
9:ff62b20f7000 | 83 | } |