Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
CmdWakePin.cpp
00001 #include "CmdWakePin.h" 00002 00003 CmdWakePin::CmdWakePin(mDot* dot, mts::MTSSerial& serial) 00004 : 00005 Command(dot, "Wake Pin", "AT+WP", "Wakeup DIO pin of sleep mode (1-8) (default: DI8, 1:DIN), deep-sleep uses DIO7"), 00006 _serial(serial) { 00007 _help = std::string(text()) + ": " + std::string(desc()); 00008 _usage = "(1-8)"; 00009 _queryable = true; 00010 } 00011 00012 uint32_t CmdWakePin::action(std::vector<std::string> args) { 00013 if (args.size() == 1) { 00014 if (_dot->getVerbose()) 00015 _serial.writef("%s: ", name()); 00016 00017 _serial.writef("%s\r\n", mDot::pinName2Str(_dot->getWakePin()).c_str()); 00018 } else if (args.size() == 2) { 00019 int pin; 00020 sscanf(args[1].c_str(), "%d", &pin); 00021 00022 _dot->setWakePin(mDot::pinNum2Name(pin)); 00023 } 00024 00025 return 0; 00026 } 00027 00028 bool CmdWakePin::verify(std::vector<std::string> args) { 00029 if (args.size() == 1) 00030 return true; 00031 00032 if (args.size() == 2) { 00033 int pin; 00034 if (sscanf(args[1].c_str(), "%d", &pin) != 1) { 00035 setErrorMessage("Invalid argument"); 00036 return false; 00037 } 00038 00039 if (pin < 1 || pin > 8) { 00040 setErrorMessage("Invalid pin, expects (1-8)"); 00041 return false; 00042 } 00043 00044 return true; 00045 } 00046 00047 setErrorMessage("Invalid arguments"); 00048 return false; 00049 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
