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 "CmdRxFrequency.h"
Mike Fiore 1:e52ae6584f1c 2
Mike Fiore 14:f9a77400b622 3 CmdRxFrequency::CmdRxFrequency() :
Mike Fiore 14:f9a77400b622 4 Command("Rx Frequency", "AT+RXF", "Set the Rx frequency for +RECV,+RECVC", "US:(0,902000000-928000000) EU:(0,863000000-870000000)")
Mike Fiore 1:e52ae6584f1c 5 {
Mike Fiore 1:e52ae6584f1c 6 _queryable = true;
Mike Fiore 1:e52ae6584f1c 7 }
Mike Fiore 1:e52ae6584f1c 8
Mike Fiore 1:e52ae6584f1c 9 uint32_t CmdRxFrequency::action(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 10 {
Mike Fiore 1:e52ae6584f1c 11 if (args.size() == 1)
Mike Fiore 1:e52ae6584f1c 12 {
Mike Fiore 14:f9a77400b622 13 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getRxFrequency());
Mike Fiore 1:e52ae6584f1c 14 }
Mike Fiore 1:e52ae6584f1c 15 else if (args.size() == 2)
Mike Fiore 1:e52ae6584f1c 16 {
Mike Fiore 14:f9a77400b622 17
Mike Fiore 9:ff62b20f7000 18 int frequency = 0;
Mike Fiore 9:ff62b20f7000 19 sscanf(args[1].c_str(), "%d", &frequency);
Mike Fiore 14:f9a77400b622 20 if (CommandTerminal::Dot()->setRxFrequency(frequency) != mDot::MDOT_OK)
Mike Fiore 1:e52ae6584f1c 21 {
Mike Fiore 9:ff62b20f7000 22
Mike Fiore 14:f9a77400b622 23 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
Mike Fiore 1:e52ae6584f1c 24 return 1;
Mike Fiore 1:e52ae6584f1c 25 }
Mike Fiore 1:e52ae6584f1c 26 }
Mike Fiore 1:e52ae6584f1c 27
Mike Fiore 1:e52ae6584f1c 28 return 0;
Mike Fiore 1:e52ae6584f1c 29 }
Mike Fiore 1:e52ae6584f1c 30
Mike Fiore 1:e52ae6584f1c 31 bool CmdRxFrequency::verify(std::vector<std::string> args)
Mike Fiore 1:e52ae6584f1c 32 {
Mike Fiore 1:e52ae6584f1c 33 if (args.size() == 1)
Mike Fiore 1:e52ae6584f1c 34 return true;
Mike Fiore 1:e52ae6584f1c 35
Mike Fiore 1:e52ae6584f1c 36 if (args.size() == 2)
Mike Fiore 1:e52ae6584f1c 37 {
Mike Fiore 9:ff62b20f7000 38 int frequency;
Mike Fiore 9:ff62b20f7000 39 if (sscanf(args[1].c_str(), "%d", &frequency) != 1) {
Mike Fiore 14:f9a77400b622 40 CommandTerminal::setErrorMessage("Invalid argument");
Mike Fiore 1:e52ae6584f1c 41 return false;
Mike Fiore 1:e52ae6584f1c 42 }
Mike Fiore 1:e52ae6584f1c 43
Mike Fiore 14:f9a77400b622 44
Mike Fiore 14:f9a77400b622 45 if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) {
Mike Fiore 14:f9a77400b622 46 if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_EU868)
Mike Fiore 14:f9a77400b622 47 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,863000000-870000000)");
Mike Fiore 14:f9a77400b622 48 else if (CommandTerminal::Dot()->getFrequencyBand() == mDot::FB_AU915)
Mike Fiore 14:f9a77400b622 49 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,915000000-928000000)");
Mike Fiore 1:e52ae6584f1c 50 else
Mike Fiore 14:f9a77400b622 51 CommandTerminal::setErrorMessage("Invalid frequency, expects (0,902000000-928000000)");
Mike Fiore 1:e52ae6584f1c 52
Mike Fiore 1:e52ae6584f1c 53 return false;
Mike Fiore 1:e52ae6584f1c 54 }
Mike Fiore 1:e52ae6584f1c 55
Mike Fiore 1:e52ae6584f1c 56 return true;
Mike Fiore 1:e52ae6584f1c 57 }
Mike Fiore 1:e52ae6584f1c 58
Mike Fiore 14:f9a77400b622 59 CommandTerminal::setErrorMessage("Invalid arguments");
Mike Fiore 1:e52ae6584f1c 60 return false;
Mike Fiore 1:e52ae6584f1c 61 }