Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MTS-Serial libmDot mbed-rtos mbed
Fork of mDot_USB_AT_firmware by
CmdRxFrequency.cpp
00001 #include "CmdRxFrequency.h" 00002 00003 CmdRxFrequency::CmdRxFrequency(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Rx Frequency", "AT+RXF", "Set the Rx frequency for +RECV,+RECVC"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 if (_dot->getFrequencyBand() == mDot::FB_868) 00008 _usage = "(0,863000000-870000000)"; 00009 else 00010 _usage = "(0,902000000-928000000)"; 00011 _queryable = true; 00012 } 00013 00014 uint32_t CmdRxFrequency::action(std::vector<std::string> args) 00015 { 00016 if (args.size() == 1) 00017 { 00018 if (_dot->getVerbose()) 00019 _serial.writef("Rx Frequency: "); 00020 00021 _serial.writef("%lu\r\n", _dot->getRxFrequency()); 00022 } 00023 else if (args.size() == 2) 00024 { 00025 int32_t code; 00026 int frequency = 0; 00027 sscanf(args[1].c_str(), "%d", &frequency); 00028 if ((code = _dot->setRxFrequency(frequency)) != mDot::MDOT_OK) 00029 { 00030 00031 setErrorMessage(_dot->getLastError());; 00032 return 1; 00033 } 00034 } 00035 00036 return 0; 00037 } 00038 00039 bool CmdRxFrequency::verify(std::vector<std::string> args) 00040 { 00041 if (args.size() == 1) 00042 return true; 00043 00044 if (args.size() == 2) 00045 { 00046 int frequency; 00047 if (sscanf(args[1].c_str(), "%d", &frequency) != 1) { 00048 setErrorMessage("Invalid argument"); 00049 return false; 00050 } 00051 00052 if (frequency != 0 && (frequency < int(_dot->getMinFrequency()) || frequency > int(_dot->getMaxFrequency()))) { 00053 if (_dot->getFrequencyBand() == mDot::FB_868) 00054 setErrorMessage("Invalid timeout, expects (0,863000000-870000000)"); 00055 else 00056 setErrorMessage("Invalid timeout, expects (0,902000000-928000000)"); 00057 00058 return false; 00059 } 00060 00061 return true; 00062 } 00063 00064 setErrorMessage("Invalid arguments"); 00065 return false; 00066 }
Generated on Tue Jul 12 2022 20:37:29 by
1.7.2
