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
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 9:ff62b20f7000 1 /*
Mike Fiore 9:ff62b20f7000 2 * CmdRxDelay.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 "CmdRxDelay.h"
Mike Fiore 9:ff62b20f7000 9
Mike Fiore 9:ff62b20f7000 10 CmdRxDelay::CmdRxDelay(mDot* dot, mts::MTSSerial& serial)
Mike Fiore 9:ff62b20f7000 11 :
Mike Fiore 9:ff62b20f7000 12 Command(dot, "Rx Delay", "AT+RXD", "Number of seconds before receive windows are opened (1 - 15)"),
Mike Fiore 9:ff62b20f7000 13 _serial(serial)
Mike Fiore 9:ff62b20f7000 14 {
Mike Fiore 9:ff62b20f7000 15 _help = std::string(text()) + ": " + std::string(desc());
Mike Fiore 9:ff62b20f7000 16 _usage = "(1-15)";
Mike Fiore 9:ff62b20f7000 17 _queryable = true;
Mike Fiore 9:ff62b20f7000 18 }
Mike Fiore 9:ff62b20f7000 19
Mike Fiore 9:ff62b20f7000 20 CmdRxDelay::~CmdRxDelay()
Mike Fiore 9:ff62b20f7000 21 {
Mike Fiore 9:ff62b20f7000 22 // TODO Auto-generated destructor stub
Mike Fiore 9:ff62b20f7000 23 }
Mike Fiore 9:ff62b20f7000 24
Mike Fiore 9:ff62b20f7000 25 uint32_t CmdRxDelay::action(std::vector<std::string> args) {
Mike Fiore 9:ff62b20f7000 26 if (args.size() == 1) {
Mike Fiore 9:ff62b20f7000 27 if (_dot->getVerbose())
Mike Fiore 9:ff62b20f7000 28 _serial.writef("Rx Delay: ");
Mike Fiore 9:ff62b20f7000 29
Mike Fiore 9:ff62b20f7000 30 _serial.writef("%u\r\n", _dot->getRxDelay());
Mike Fiore 9:ff62b20f7000 31 } else if (args.size() == 2) {
Mike Fiore 9:ff62b20f7000 32 int32_t code;
Mike Fiore 9:ff62b20f7000 33 int rxDelay;
Mike Fiore 9:ff62b20f7000 34 sscanf(args[1].c_str(), "%d", &rxDelay);
Mike Fiore 9:ff62b20f7000 35
Mike Fiore 9:ff62b20f7000 36 if ((code = _dot->setRxDelay(rxDelay)) != mDot::MDOT_OK) {
Mike Fiore 9:ff62b20f7000 37
Mike Fiore 9:ff62b20f7000 38 setErrorMessage(_dot->getLastError());;
Mike Fiore 9:ff62b20f7000 39 return 1;
Mike Fiore 9:ff62b20f7000 40 }
Mike Fiore 9:ff62b20f7000 41 }
Mike Fiore 9:ff62b20f7000 42 return 0;
Mike Fiore 9:ff62b20f7000 43 }
Mike Fiore 9:ff62b20f7000 44
Mike Fiore 9:ff62b20f7000 45 bool CmdRxDelay::verify(std::vector<std::string> args) {
Mike Fiore 9:ff62b20f7000 46 if (args.size() == 1)
Mike Fiore 9:ff62b20f7000 47 return true;
Mike Fiore 9:ff62b20f7000 48
Mike Fiore 9:ff62b20f7000 49 if (args.size() == 2) {
Mike Fiore 9:ff62b20f7000 50
Mike Fiore 9:ff62b20f7000 51 int rxDelay;
Mike Fiore 9:ff62b20f7000 52 if (sscanf(args[1].c_str(), "%d", &rxDelay) == 1) {
Mike Fiore 9:ff62b20f7000 53
Mike Fiore 9:ff62b20f7000 54 if (rxDelay > 15 || rxDelay < 1) {
Mike Fiore 9:ff62b20f7000 55 setErrorMessage("Invalid rx delay, expects (1-15)");
Mike Fiore 9:ff62b20f7000 56 return false;
Mike Fiore 9:ff62b20f7000 57 }
Mike Fiore 9:ff62b20f7000 58
Mike Fiore 9:ff62b20f7000 59 return true;
Mike Fiore 9:ff62b20f7000 60 }
Mike Fiore 9:ff62b20f7000 61 }
Mike Fiore 9:ff62b20f7000 62
Mike Fiore 9:ff62b20f7000 63 setErrorMessage("Invalid arguments");
Mike Fiore 9:ff62b20f7000 64 return false;
Mike Fiore 9:ff62b20f7000 65 }