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 "CmdDefaultFrequencyBand.h"
nguyenhoang9x5555 0:3c869a8cb8f8 2 #include "ChannelPlans.h"
nguyenhoang9x5555 0:3c869a8cb8f8 3
nguyenhoang9x5555 0:3c869a8cb8f8 4 CmdDefaultFrequencyBand::CmdDefaultFrequencyBand() :
nguyenhoang9x5555 0:3c869a8cb8f8 5 Command("Default Frequency Band", "AT+DFREQ", "Frequency Band Device Was Manufactured For 'US915', 'AU915', 'EU868', 'AS923', 'KR920', 'AS923-JAPAN', or 'NONE'", "(NONE,US915,AU915,EU868,AS923,KR920,AS923-JAPAN)")
nguyenhoang9x5555 0:3c869a8cb8f8 6 {
nguyenhoang9x5555 0:3c869a8cb8f8 7 _queryable = true;
nguyenhoang9x5555 0:3c869a8cb8f8 8 }
nguyenhoang9x5555 0:3c869a8cb8f8 9
nguyenhoang9x5555 0:3c869a8cb8f8 10 uint32_t CmdDefaultFrequencyBand::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("%s\r\n", CommandTerminal::Dot()->FrequencyBandStr(CommandTerminal::Dot()->getDefaultFrequencyBand()).c_str());
nguyenhoang9x5555 0:3c869a8cb8f8 15 }
nguyenhoang9x5555 0:3c869a8cb8f8 16
nguyenhoang9x5555 0:3c869a8cb8f8 17 #ifdef DEBUG_MAC
nguyenhoang9x5555 0:3c869a8cb8f8 18 else if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 19 {
nguyenhoang9x5555 0:3c869a8cb8f8 20 uint8_t band = lora::ChannelPlan::US915;
nguyenhoang9x5555 0:3c869a8cb8f8 21 std::string band_str = mts::Text::toUpper(args[1]);
nguyenhoang9x5555 0:3c869a8cb8f8 22
nguyenhoang9x5555 0:3c869a8cb8f8 23 if (mDot::FrequencyBandStr(lora::ChannelPlan::NONE) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 24 band = lora::ChannelPlan::NONE;
nguyenhoang9x5555 0:3c869a8cb8f8 25 }
nguyenhoang9x5555 0:3c869a8cb8f8 26 if (mDot::FrequencyBandStr(lora::ChannelPlan::US915) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 27 band = lora::ChannelPlan::US915;
nguyenhoang9x5555 0:3c869a8cb8f8 28 }
nguyenhoang9x5555 0:3c869a8cb8f8 29 if (mDot::FrequencyBandStr(lora::ChannelPlan::AU915) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 30 band = lora::ChannelPlan::AU915;
nguyenhoang9x5555 0:3c869a8cb8f8 31 }
nguyenhoang9x5555 0:3c869a8cb8f8 32 if (mDot::FrequencyBandStr(lora::ChannelPlan::EU868) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 33 band = lora::ChannelPlan::EU868;
nguyenhoang9x5555 0:3c869a8cb8f8 34 }
nguyenhoang9x5555 0:3c869a8cb8f8 35 if (mDot::FrequencyBandStr(lora::ChannelPlan::AS923) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 36 band = lora::ChannelPlan::AS923;
nguyenhoang9x5555 0:3c869a8cb8f8 37 }
nguyenhoang9x5555 0:3c869a8cb8f8 38 if (mDot::FrequencyBandStr(lora::ChannelPlan::KR920) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 39 band = lora::ChannelPlan::KR920;
nguyenhoang9x5555 0:3c869a8cb8f8 40 }
nguyenhoang9x5555 0:3c869a8cb8f8 41 if (mDot::FrequencyBandStr(lora::ChannelPlan::AS923_JAPAN) == band_str) {
nguyenhoang9x5555 0:3c869a8cb8f8 42 band = lora::ChannelPlan::AS923_JAPAN;
nguyenhoang9x5555 0:3c869a8cb8f8 43 }
nguyenhoang9x5555 0:3c869a8cb8f8 44
nguyenhoang9x5555 0:3c869a8cb8f8 45 if (CommandTerminal::Dot()->setDefaultFrequencyBand(band) != mDot::MDOT_OK) {
nguyenhoang9x5555 0:3c869a8cb8f8 46 CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());;
nguyenhoang9x5555 0:3c869a8cb8f8 47 return 1;
nguyenhoang9x5555 0:3c869a8cb8f8 48 }
nguyenhoang9x5555 0:3c869a8cb8f8 49 }
nguyenhoang9x5555 0:3c869a8cb8f8 50 #endif
nguyenhoang9x5555 0:3c869a8cb8f8 51
nguyenhoang9x5555 0:3c869a8cb8f8 52 return 0;
nguyenhoang9x5555 0:3c869a8cb8f8 53 }
nguyenhoang9x5555 0:3c869a8cb8f8 54
nguyenhoang9x5555 0:3c869a8cb8f8 55 bool CmdDefaultFrequencyBand::verify(std::vector<std::string> args)
nguyenhoang9x5555 0:3c869a8cb8f8 56 {
nguyenhoang9x5555 0:3c869a8cb8f8 57 if (args.size() == 1)
nguyenhoang9x5555 0:3c869a8cb8f8 58 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 59
nguyenhoang9x5555 0:3c869a8cb8f8 60 #ifdef DEBUG_MAC
nguyenhoang9x5555 0:3c869a8cb8f8 61 if (args.size() == 2)
nguyenhoang9x5555 0:3c869a8cb8f8 62 {
nguyenhoang9x5555 0:3c869a8cb8f8 63 std::string band = mts::Text::toUpper(args[1]);
nguyenhoang9x5555 0:3c869a8cb8f8 64
nguyenhoang9x5555 0:3c869a8cb8f8 65 if (mDot::FrequencyBandStr(lora::ChannelPlan::NONE) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 66 mDot::FrequencyBandStr(lora::ChannelPlan::US915) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 67 mDot::FrequencyBandStr(lora::ChannelPlan::AU915) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 68 mDot::FrequencyBandStr(lora::ChannelPlan::EU868) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 69 mDot::FrequencyBandStr(lora::ChannelPlan::AS923) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 70 mDot::FrequencyBandStr(lora::ChannelPlan::KR920) != band &&
nguyenhoang9x5555 0:3c869a8cb8f8 71 mDot::FrequencyBandStr(lora::ChannelPlan::AS923_JAPAN) != band)
nguyenhoang9x5555 0:3c869a8cb8f8 72 {
nguyenhoang9x5555 0:3c869a8cb8f8 73 CommandTerminal::setErrorMessage("Invalid parameter, expects (NONE,US915,AU915,EU868,AS923,KR920,AS923-JAPAN)");
nguyenhoang9x5555 0:3c869a8cb8f8 74 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 75 }
nguyenhoang9x5555 0:3c869a8cb8f8 76
nguyenhoang9x5555 0:3c869a8cb8f8 77 return true;
nguyenhoang9x5555 0:3c869a8cb8f8 78 }
nguyenhoang9x5555 0:3c869a8cb8f8 79 #endif
nguyenhoang9x5555 0:3c869a8cb8f8 80
nguyenhoang9x5555 0:3c869a8cb8f8 81 CommandTerminal::setErrorMessage("Invalid arguments");
nguyenhoang9x5555 0:3c869a8cb8f8 82 return false;
nguyenhoang9x5555 0:3c869a8cb8f8 83 }