firm newest
Dependencies: MTS-Serial libmDot-dev-mbed5-deprecated
CommandTerminal/CmdWakePin.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 "CmdWakePin.h" |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 2 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 3 | CmdWakePin::CmdWakePin() |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 4 | #if defined(TARGET_MTS_MDOT_F411RE) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 5 | : Command("Wake Pin", "AT+WP", "Wakeup DIO pin of sleep mode (1-8) (default: DI8, 1:DIN), deep-sleep uses DIO7", "(1-8)") |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 6 | #else |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 7 | : Command("Wake Pin", "AT+WP", "Wakeup GPIO pin of sleep mode (1-6) (default: WAKE, 1:UART1_RX), deep-sleep uses WAKE", "(1-6)") |
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 CmdWakePin::action(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 14 | if (args.size() == 1) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 15 | CommandTerminal::Serial()->writef("%s\r\n", mDot::pinName2Str(CommandTerminal::Dot()->getWakePin()).c_str()); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 16 | } else if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 17 | int pin; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 18 | sscanf(args[1].c_str(), "%d", &pin); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 19 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 20 | CommandTerminal::Dot()->setWakePin(mDot::pinNum2Name(pin)); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 21 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 22 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 23 | return 0; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 24 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 25 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 26 | bool CmdWakePin::verify(std::vector<std::string> args) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 27 | if (args.size() == 1) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 28 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 29 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 30 | if (args.size() == 2) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 31 | int pin; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 32 | if (sscanf(args[1].c_str(), "%d", &pin) != 1) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 33 | CommandTerminal::setErrorMessage("Invalid argument"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 34 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 35 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 36 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 37 | #if defined(TARGET_MTS_MDOT_F411RE) |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 38 | if (pin < 1 || pin > 8) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 39 | CommandTerminal::setErrorMessage("Invalid pin, expects (1-8)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 40 | #else |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 41 | if (pin < 1 || pin > 6) { |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 42 | CommandTerminal::setErrorMessage("Invalid pin, expects (1-6)"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 43 | #endif /* TARGET_MTS_MDOT_F411RE */ |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 44 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 45 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 46 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 47 | return true; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 48 | } |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 49 | |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 50 | CommandTerminal::setErrorMessage("Invalid arguments"); |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 51 | return false; |
nguyenhoang9x5555 | 0:3c869a8cb8f8 | 52 | } |