firm newest

Dependencies:   MTS-Serial libmDot-dev-mbed5-deprecated

Committer:
nguyenhoang9x5555
Date:
Mon Oct 22 01:56:09 2018 +0000
Revision:
1:c1c6549b9333
Parent:
0:3c869a8cb8f8
hey

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nguyenhoang9x5555 0:3c869a8cb8f8 1 #include "CmdJoinRx2Frequency.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2 #include "CommandTerminal.h"
nguyenhoang9x5555 0:3c869a8cb8f8 3
nguyenhoang9x5555 0:3c869a8cb8f8 4 CmdJoinRx2Frequency::CmdJoinRx2Frequency()
nguyenhoang9x5555 0:3c869a8cb8f8 5 :
nguyenhoang9x5555 0:3c869a8cb8f8 6 Command("Join Rx2 Frequency", "AT+JR2F", "Join Rx2 frequency", "(US:902000000-928000000,AU:915000000-928000000,EU:863000000-870000000)") {
nguyenhoang9x5555 0:3c869a8cb8f8 7
nguyenhoang9x5555 0:3c869a8cb8f8 8 }
nguyenhoang9x5555 0:3c869a8cb8f8 9
nguyenhoang9x5555 0:3c869a8cb8f8 10 uint32_t CmdJoinRx2Frequency::action(std::vector<std::string> args) {
nguyenhoang9x5555 0:3c869a8cb8f8 11
nguyenhoang9x5555 0:3c869a8cb8f8 12 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 13 {
nguyenhoang9x5555 0:3c869a8cb8f8 14 CommandTerminal::Serial()->writef("%lu\r\n", CommandTerminal::Dot()->getJoinRx2Frequency());
nguyenhoang9x5555 0:3c869a8cb8f8 15 }
nguyenhoang9x5555 0:3c869a8cb8f8 16 else if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 17 {
nguyenhoang9x5555 0:3c869a8cb8f8 18 int frequency = 0;
nguyenhoang9x5555 0:3c869a8cb8f8 19
nguyenhoang9x5555 0:3c869a8cb8f8 20 sscanf(args[1].c_str(), "%d", &frequency);
nguyenhoang9x5555 0:3c869a8cb8f8 21 if (CommandTerminal::Dot()->setJoinRx2Frequency(frequency) != mDot::MDOT_OK)
nguyenhoang9x5555 0:3c869a8cb8f8 22 {
nguyenhoang9x5555 0:3c869a8cb8f8 23 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());
nguyenhoang9x5555 0:3c869a8cb8f8 24 ;
nguyenhoang9x5555 0:3c869a8cb8f8 25 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 26 }
nguyenhoang9x5555 0:3c869a8cb8f8 27 }
nguyenhoang9x5555 0:3c869a8cb8f8 28
nguyenhoang9x5555 0:3c869a8cb8f8 29 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 30 }
nguyenhoang9x5555 0:3c869a8cb8f8 31
nguyenhoang9x5555 0:3c869a8cb8f8 32 bool CmdJoinRx2Frequency::verify(std::vector<std::string> args) {
nguyenhoang9x5555 0:3c869a8cb8f8 33 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 34 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 35
nguyenhoang9x5555 0:3c869a8cb8f8 36 if (args.size() == 2) {
nguyenhoang9x5555 0:3c869a8cb8f8 37 int frequency = ULONG_MAX;
nguyenhoang9x5555 0:3c869a8cb8f8 38 if (sscanf(args[1].c_str(), "%d", &frequency) != 1) {
nguyenhoang9x5555 0:3c869a8cb8f8 39 CommandTerminal::setErrorMessage("Invalid argument");
nguyenhoang9x5555 0:3c869a8cb8f8 40 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 41 }
nguyenhoang9x5555 0:3c869a8cb8f8 42
nguyenhoang9x5555 0:3c869a8cb8f8 43 if (frequency != 0 && (frequency < int(CommandTerminal::Dot()->getMinFrequency()) || frequency > int(CommandTerminal::Dot()->getMaxFrequency()))) {
nguyenhoang9x5555 0:3c869a8cb8f8 44 char tmp[256];
nguyenhoang9x5555 0:3c869a8cb8f8 45 sprintf(tmp, "Invalid frequency, expects (0,%lu-%lu)", CommandTerminal::Dot()->getMinFrequency(), CommandTerminal::Dot()->getMaxFrequency());
nguyenhoang9x5555 0:3c869a8cb8f8 46 CommandTerminal::setErrorMessage(tmp);
nguyenhoang9x5555 0:3c869a8cb8f8 47 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 48 }
nguyenhoang9x5555 0:3c869a8cb8f8 49 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 50 }
nguyenhoang9x5555 0:3c869a8cb8f8 51
nguyenhoang9x5555 0:3c869a8cb8f8 52 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 53 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 54 }