mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Committer:
Mike Fiore
Date:
Fri Nov 04 14:25:43 2016 -0500
Revision:
14:f9a77400b622
Parent:
9:ff62b20f7000
update from git revision 2.0.16

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 9:ff62b20f7000 1 /*
Mike Fiore 9:ff62b20f7000 2 * CmdPreserveSession.cpp
Mike Fiore 9:ff62b20f7000 3 *
Mike Fiore 9:ff62b20f7000 4 * Created on: Nov 4, 2015
Mike Fiore 9:ff62b20f7000 5 * Author: jreiss
Mike Fiore 9:ff62b20f7000 6 */
Mike Fiore 9:ff62b20f7000 7
Mike Fiore 9:ff62b20f7000 8 #include "CmdPreserveSession.h"
Mike Fiore 9:ff62b20f7000 9
Mike Fiore 14:f9a77400b622 10 CmdPreserveSession::CmdPreserveSession()
Mike Fiore 9:ff62b20f7000 11 :
Mike Fiore 14:f9a77400b622 12 Command("Preserve Session", "AT+PS", "Save network session info through reset or power down in AUTO_OTA mode (0:off, 1:on)", "(0,1)")
Mike Fiore 9:ff62b20f7000 13 {
Mike Fiore 9:ff62b20f7000 14 _queryable = true;
Mike Fiore 9:ff62b20f7000 15 }
Mike Fiore 9:ff62b20f7000 16
Mike Fiore 9:ff62b20f7000 17 CmdPreserveSession::~CmdPreserveSession()
Mike Fiore 9:ff62b20f7000 18 {
Mike Fiore 9:ff62b20f7000 19 // TODO Auto-generated destructor stub
Mike Fiore 9:ff62b20f7000 20 }
Mike Fiore 9:ff62b20f7000 21
Mike Fiore 9:ff62b20f7000 22 uint32_t CmdPreserveSession::action(std::vector<std::string> args) {
Mike Fiore 9:ff62b20f7000 23
Mike Fiore 9:ff62b20f7000 24 if (args.size() == 1) {
Mike Fiore 14:f9a77400b622 25 CommandTerminal::Serial()->writef("%u\r\n", CommandTerminal::Dot()->getPreserveSession());
Mike Fiore 9:ff62b20f7000 26 } else {
Mike Fiore 14:f9a77400b622 27 CommandTerminal::Dot()->setPreserveSession(args[1] == "1");
Mike Fiore 9:ff62b20f7000 28 }
Mike Fiore 9:ff62b20f7000 29
Mike Fiore 9:ff62b20f7000 30 return mDot::MDOT_OK;
Mike Fiore 9:ff62b20f7000 31 }
Mike Fiore 9:ff62b20f7000 32
Mike Fiore 9:ff62b20f7000 33 bool CmdPreserveSession::verify(std::vector<std::string> args) {
Mike Fiore 9:ff62b20f7000 34 if (args.size() == 1)
Mike Fiore 9:ff62b20f7000 35 return true;
Mike Fiore 9:ff62b20f7000 36
Mike Fiore 9:ff62b20f7000 37 if (args.size() == 2) {
Mike Fiore 9:ff62b20f7000 38
Mike Fiore 9:ff62b20f7000 39 if (args[1] != "1" && args[1] != "0") {
Mike Fiore 14:f9a77400b622 40 CommandTerminal::setErrorMessage("Invalid parameter, expects (0: off, 1: on)");
Mike Fiore 9:ff62b20f7000 41 return false;
Mike Fiore 9:ff62b20f7000 42 }
Mike Fiore 9:ff62b20f7000 43
Mike Fiore 9:ff62b20f7000 44 return true;
Mike Fiore 9:ff62b20f7000 45 }
Mike Fiore 9:ff62b20f7000 46
Mike Fiore 14:f9a77400b622 47 CommandTerminal::setErrorMessage("Invalid arguments");
Mike Fiore 9:ff62b20f7000 48 return false;
Mike Fiore 9:ff62b20f7000 49 }