AT Command Set mDot firmware with updated libmDot, to fix endian problem with joining LoRaWAN network
Dependencies: MTS-Serial libmDot mbed-rtos mbed-src
Fork of mDot_AT_firmware by
CmdFrequencySubBand.cpp
00001 #include "CmdFrequencySubBand.h" 00002 00003 CmdFrequencySubBand::CmdFrequencySubBand(mDot* dot, mts::MTSSerial& serial) : 00004 Command(dot, "Frequency Sub-band", "AT+FSB", "Set the frequency sub-band for US 915, (0:ALL, 1-8)"), _serial(serial) 00005 { 00006 _help = std::string(text()) + ": " + std::string(desc()); 00007 _usage = "(0-8)"; 00008 _queryable = true; 00009 } 00010 00011 uint32_t CmdFrequencySubBand::action(std::vector<std::string> args) 00012 { 00013 00014 if (args.size() == 1) 00015 { 00016 if (_dot->getVerbose()) 00017 _serial.writef("Frequency Sub Band: "); 00018 00019 _serial.writef("%u\r\n", _dot->getFrequencySubBand()); 00020 } 00021 else if (args.size() == 2) 00022 { 00023 int32_t code; 00024 uint32_t band; 00025 sscanf(args[1].c_str(), "%lu", &band); 00026 00027 if ((code = _dot->setFrequencySubBand(band)) != mDot::MDOT_OK) { 00028 std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); 00029 setErrorMessage(error); 00030 return 1; 00031 } 00032 } 00033 00034 return 0; 00035 } 00036 00037 bool CmdFrequencySubBand::verify(std::vector<std::string> args) 00038 { 00039 if (args.size() == 1) 00040 return true; 00041 00042 if (args.size() == 2) 00043 { 00044 uint32_t band; 00045 if (sscanf(args[1].c_str(), "%u", &band) != 1) { 00046 setErrorMessage("Invalid arguments"); 00047 return false; 00048 } 00049 00050 if (band < mDot::FSB_ALL || band > mDot::FSB_8) { 00051 setErrorMessage("Invalid channel band, expects (0-8)"); 00052 return false; 00053 } 00054 00055 return true; 00056 } 00057 00058 setErrorMessage("Invalid arguments"); 00059 return false; 00060 }
Generated on Tue Jul 12 2022 21:40:57 by
1.7.2
