![](/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/CmdLbt.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 17:95c9eb69329a
Added ability to force the AT terminal to use the USB debug port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jenkins@jenkinsdm1 | 17:95c9eb69329a | 1 | #include "CmdLbt.h" |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 2 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 3 | CmdLbt::CmdLbt() : |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 4 | Command("Listen Before Talk", "AT+LBT", "Enable/Disable listen before talk (0,0: disable, time,threshold: enable)", "time(0-65535 us),threshold(-127-128 dBm) (0,0: disable, time,threshold: enable)") |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 5 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 6 | _queryable = true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 7 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 8 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 9 | uint32_t CmdLbt::action(std::vector<std::string> args) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 10 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 11 | if (args.size() == 1) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 12 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 13 | CommandTerminal::Serial()->writef("%u,%d\r\n", CommandTerminal::Dot()->getLbtTimeUs(), CommandTerminal::Dot()->getLbtThreshold()); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 14 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 15 | else |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 16 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 17 | uint32_t us; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 18 | int32_t rssi; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 19 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 20 | sscanf(args[1].c_str(), "%lu", &us); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 21 | sscanf(args[2].c_str(), "%ld", &rssi); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 22 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 23 | CommandTerminal::Dot()->setLbtTimeUs((uint16_t)us); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 24 | CommandTerminal::Dot()->setLbtThreshold((int8_t)rssi); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 25 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 26 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 27 | return 0; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 28 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 29 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 30 | bool CmdLbt::verify(std::vector<std::string> args) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 31 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 32 | if (args.size() == 1) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 33 | return true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 34 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 35 | if (args.size() == 3) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 36 | uint32_t us; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 37 | int32_t rssi; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 38 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 39 | if (args[1].find("-") != std::string::npos || sscanf(args[1].c_str(), "%lu", &us) != 1 || us > 65535) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 40 | CommandTerminal::setErrorMessage("Invalid LBT time, expects 0-65535 us"); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 41 | return false; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 42 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 43 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 44 | if (sscanf(args[2].c_str(), "%ld", &rssi) != 1 || rssi < -127 || rssi > 128) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 45 | CommandTerminal::setErrorMessage("Invalid LBT threshold, expects -127-128 dBm"); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 46 | return false; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 47 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 48 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 49 | return true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 50 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 51 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 52 | CommandTerminal::setErrorMessage("Invalid arguments"); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 53 | return false; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 54 | } |