mDot AT-Firmware for testing

Dependencies:   MTS-Serial libmDot-mbed5

Fork of Dot-AT-Firmware by MultiTech

Committer:
Fran6
Date:
Mon Aug 14 12:40:21 2017 +0000
Revision:
16:3b1d46c1db11
Parent:
14:f9a77400b622
mDot AT-Firmware

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:e52ae6584f1c 1 #include "CmdTxPower.h"
Mike Fiore 1:e52ae6584f1c 2
Mike Fiore 14:f9a77400b622 3 CmdTxPower::CmdTxPower() :
Mike Fiore 14:f9a77400b622 4 Command("Tx Power", "AT+TXP", "Set the radio TX power before antenna gain in dBm", "(0-30)") {
Mike Fiore 1:e52ae6584f1c 5 _queryable = true;
Mike Fiore 1:e52ae6584f1c 6 }
Mike Fiore 1:e52ae6584f1c 7
Mike Fiore 1:e52ae6584f1c 8 uint32_t CmdTxPower::action(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 9 {
Mike Fiore 1:e52ae6584f1c 10 if (args.size() == 1)
Mike Fiore 1:e52ae6584f1c 11 {
Mike Fiore 14:f9a77400b622 12 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getTxPower());
Mike Fiore 1:e52ae6584f1c 13 }
Mike Fiore 1:e52ae6584f1c 14 else if (args.size() == 2)
Mike Fiore 1:e52ae6584f1c 15 {
Mike Fiore 9:ff62b20f7000 16 int power = 0;
Mike Fiore 9:ff62b20f7000 17 sscanf(args[1].c_str(), "%d", &power);
Mike Fiore 1:e52ae6584f1c 18
Mike Fiore 14:f9a77400b622 19 if (CommandTerminal::Dot()->setTxPower(power) != mDot::MDOT_OK)
Mike Fiore 1:e52ae6584f1c 20 {
Mike Fiore 14:f9a77400b622 21 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
Mike Fiore 1:e52ae6584f1c 22 return 1;
Mike Fiore 1:e52ae6584f1c 23 }
Mike Fiore 1:e52ae6584f1c 24 }
Mike Fiore 1:e52ae6584f1c 25
Mike Fiore 1:e52ae6584f1c 26 return 0;
Mike Fiore 1:e52ae6584f1c 27 }
Mike Fiore 1:e52ae6584f1c 28
Mike Fiore 1:e52ae6584f1c 29 bool CmdTxPower::verify(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 30 {
Mike Fiore 1:e52ae6584f1c 31 if (args.size() == 1)
Mike Fiore 1:e52ae6584f1c 32 return true;
Mike Fiore 1:e52ae6584f1c 33
Mike Fiore 1:e52ae6584f1c 34 if (args.size() == 2)
Mike Fiore 1:e52ae6584f1c 35 {
Mike Fiore 9:ff62b20f7000 36 int power = 0;
Mike Fiore 9:ff62b20f7000 37 if (sscanf(args[1].c_str(), "%d", &power) != 1) {
Mike Fiore 14:f9a77400b622 38 CommandTerminal::setErrorMessage("Invalid argument");
Mike Fiore 1:e52ae6584f1c 39 return false;
Mike Fiore 1:e52ae6584f1c 40 }
Mike Fiore 1:e52ae6584f1c 41
Mike Fiore 14:f9a77400b622 42 if (power < 0 || power > 30)
Mike Fiore 1:e52ae6584f1c 43 {
Mike Fiore 14:f9a77400b622 44 CommandTerminal::setErrorMessage("Invalid power, expects (0-30)");
Mike Fiore 1:e52ae6584f1c 45 return false;
Mike Fiore 1:e52ae6584f1c 46 }
Mike Fiore 1:e52ae6584f1c 47
Mike Fiore 1:e52ae6584f1c 48 return true;
Mike Fiore 1:e52ae6584f1c 49 }
Mike Fiore 1:e52ae6584f1c 50
Mike Fiore 14:f9a77400b622 51 CommandTerminal::setErrorMessage("Invalid arguments");
Mike Fiore 1:e52ae6584f1c 52 return false;
Mike Fiore 1:e52ae6584f1c 53 }
Mike Fiore 1:e52ae6584f1c 54