firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdWakeMode.cpp@0:3c869a8cb8f8, 2018-10-18 (annotated)
- Committer:
- nguyenhoang9x5555
- Date:
- Thu Oct 18 04:18:48 2018 +0000
- Revision:
- 0:3c869a8cb8f8
DOT AT FIRMWARE 18102018
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 1 | #include "CmdWakeMode.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdWakeMode::CmdWakeMode() : |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 4 | #if defined(TARGET_MTS_MDOT_F411RE) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | Command("Wake Mode", "AT+WM", "Wakeup mode, INTERRUPT uses DIO7 as wake-up pin (0:INTERVAL,1:INTERRUPT,2:INTERVAL_OR_INTERRUPT)", "(0:INTERVAL,1:INTERRUPT,2:INTERVAL_OR_INTERRUPT)") |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | #else |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | Command("Wake Mode", "AT+WM", "Wakeup mode, INTERRUPT uses WAKE as wake-up pin (0:INTERVAL,1:INTERRUPT,2:INTERVAL_OR_INTERRUPT)", "(0:INTERVAL,1:INTERRUPT,2:INTERVAL_OR_INTERRUPT)") |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 8 | #endif /* TARGET_MTS_MDOT_F411RE */ |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 9 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 10 | _queryable = true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 11 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 12 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 13 | uint32_t CmdWakeMode::action(std::vector<std::string> args) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getWakeMode()); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | else if (args.size() == 2) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | int mode; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | sscanf(args[1].c_str(), "%d", &mode); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | if (CommandTerminal::Dot()->setWakeMode(mode) != mDot::MDOT_OK) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 26 | return 1; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 27 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 28 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 29 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 30 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 31 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 32 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 33 | bool CmdWakeMode::verify(std::vector<std::string> args) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 34 | { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 35 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 36 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 37 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 38 | if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 39 | int mode; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 40 | if (sscanf(args[1].c_str(), "%d", &mode) != 1) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 41 | CommandTerminal::setErrorMessage("Invalid argument"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 42 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 43 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 44 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 45 | if (mode != 0 && mode != 1 && mode != 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 46 | CommandTerminal::setErrorMessage("Invalid mode, expects (0:INTERVAL,1:INTERRUPT,2:INTERVAL_OR_INTERRUPT)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 47 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 48 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 49 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 50 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 51 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 52 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 53 | CommandTerminal::setErrorMessage("Invalid arguments"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 54 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 55 | } |