firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdJoinRetries.cpp@1:c1c6549b9333, 2018-10-22 (annotated)
- Committer:
- nguyenhoang9x5555
- Date:
- Mon Oct 22 01:56:09 2018 +0000
- Revision:
- 1:c1c6549b9333
- Parent:
- 0:3c869a8cb8f8
hey
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 1 | #include "CmdJoinRetries.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdJoinRetries::CmdJoinRetries() |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 4 | : |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | Command("Join Retries", "AT+JR", "US915/AU915 AUTO_OTA Frequency sub-band search retries (0:disable,1-255:attempts)", "(0-255)") { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | _queryable = true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 8 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 9 | uint32_t CmdJoinRetries::action(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 10 | if (args.size() == 1) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 11 | CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getJoinRetries()); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 12 | } else if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 13 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | int retries; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | sscanf(args[1].c_str(), "%d", &retries); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | if (CommandTerminal::Dot()->setJoinRetries(retries) != mDot::MDOT_OK) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | return 1; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 | bool CmdJoinRetries::verify(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 26 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 27 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 28 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 29 | if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 30 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 31 | int retries; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 32 | if (sscanf(args[1].c_str(), "%d", &retries) == 1) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 33 | if (retries < 0 || retries > 255) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 34 | CommandTerminal::setErrorMessage("Invalid retries, expects (0-255)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 35 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 36 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 37 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 38 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 39 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 40 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 41 | CommandTerminal::setErrorMessage("Invalid arguments"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 42 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 43 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 44 |