mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Committer:
Mike Fiore
Date:
Mon Apr 04 09:00:31 2016 -0500
Revision:
9:ff62b20f7000
Parent:
4:666017851052
Child:
14:f9a77400b622
update to version 1.0.8 of AT firmware

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 4:666017851052 1 #include "CmdWakePin.h"
Mike Fiore 4:666017851052 2
Mike Fiore 4:666017851052 3 CmdWakePin::CmdWakePin(mDot* dot, mts::MTSSerial& serial)
Mike Fiore 4:666017851052 4 :
Mike Fiore 9:ff62b20f7000 5 Command(dot, "Wake Pin", "AT+WP", "Wakeup DIO pin of sleep mode (1-8) (default: DI8, 1:DIN), deep-sleep uses DIO7"),
Mike Fiore 4:666017851052 6 _serial(serial) {
Mike Fiore 4:666017851052 7 _help = std::string(text()) + ": " + std::string(desc());
Mike Fiore 9:ff62b20f7000 8 _usage = "(1-8)";
Mike Fiore 4:666017851052 9 _queryable = true;
Mike Fiore 4:666017851052 10 }
Mike Fiore 4:666017851052 11
Mike Fiore 4:666017851052 12 uint32_t CmdWakePin::action(std::vector<std::string> args) {
Mike Fiore 4:666017851052 13 if (args.size() == 1) {
Mike Fiore 4:666017851052 14 if (_dot->getVerbose())
Mike Fiore 4:666017851052 15 _serial.writef("%s: ", name());
Mike Fiore 4:666017851052 16
Mike Fiore 4:666017851052 17 _serial.writef("%s\r\n", mDot::pinName2Str(_dot->getWakePin()).c_str());
Mike Fiore 4:666017851052 18 } else if (args.size() == 2) {
Mike Fiore 9:ff62b20f7000 19 int pin;
Mike Fiore 9:ff62b20f7000 20 sscanf(args[1].c_str(), "%d", &pin);
Mike Fiore 4:666017851052 21
Mike Fiore 4:666017851052 22 _dot->setWakePin(mDot::pinNum2Name(pin));
Mike Fiore 4:666017851052 23 }
Mike Fiore 4:666017851052 24
Mike Fiore 4:666017851052 25 return 0;
Mike Fiore 4:666017851052 26 }
Mike Fiore 4:666017851052 27
Mike Fiore 4:666017851052 28 bool CmdWakePin::verify(std::vector<std::string> args) {
Mike Fiore 4:666017851052 29 if (args.size() == 1)
Mike Fiore 4:666017851052 30 return true;
Mike Fiore 4:666017851052 31
Mike Fiore 4:666017851052 32 if (args.size() == 2) {
Mike Fiore 9:ff62b20f7000 33 int pin;
Mike Fiore 9:ff62b20f7000 34 if (sscanf(args[1].c_str(), "%d", &pin) != 1) {
Mike Fiore 4:666017851052 35 setErrorMessage("Invalid argument");
Mike Fiore 4:666017851052 36 return false;
Mike Fiore 4:666017851052 37 }
Mike Fiore 4:666017851052 38
Mike Fiore 9:ff62b20f7000 39 if (pin < 1 || pin > 8) {
Mike Fiore 9:ff62b20f7000 40 setErrorMessage("Invalid pin, expects (1-8)");
Mike Fiore 4:666017851052 41 return false;
Mike Fiore 4:666017851052 42 }
Mike Fiore 4:666017851052 43
Mike Fiore 4:666017851052 44 return true;
Mike Fiore 4:666017851052 45 }
Mike Fiore 4:666017851052 46
Mike Fiore 4:666017851052 47 setErrorMessage("Invalid arguments");
Mike Fiore 4:666017851052 48 return false;
Mike Fiore 4:666017851052 49 }