![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
AT terminal for the mDot using the USB debug port instead of the serial port.
Dependencies: MTS-Serial libmDot-mbed5
Fork of Dot-AT-Firmware by
CommandTerminal/CmdDefaultFrequencyBand.cpp@18:f5d28d621bb0, 2018-03-02 (annotated)
- Committer:
- pferland
- Date:
- Fri Mar 02 20:01:38 2018 +0000
- Revision:
- 18:f5d28d621bb0
- Parent:
- 17:95c9eb69329a
Added ability to force the AT terminal to use the USB debug port
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jenkins@jenkinsdm1 | 17:95c9eb69329a | 1 | #include "CmdDefaultFrequencyBand.h" |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 2 | #include "ChannelPlans.h" |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 3 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 4 | CmdDefaultFrequencyBand::CmdDefaultFrequencyBand() : |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 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)") |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 6 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 7 | _queryable = true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 8 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 9 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 10 | uint32_t CmdDefaultFrequencyBand::action(std::vector<std::string> args) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 11 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 12 | if (args.size() == 1) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 13 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 14 | CommandTerminal::Serial()->writef("%s\r\n", CommandTerminal::Dot()->FrequencyBandStr(CommandTerminal::Dot()->getDefaultFrequencyBand()).c_str()); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 15 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 16 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 17 | #ifdef DEBUG_MAC |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 18 | else if (args.size() == 2) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 19 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 20 | uint8_t band = lora::ChannelPlan::US915; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 21 | std::string band_str = mts::Text::toUpper(args[1]); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 22 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 23 | if (mDot::FrequencyBandStr(lora::ChannelPlan::NONE) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 24 | band = lora::ChannelPlan::NONE; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 25 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 26 | if (mDot::FrequencyBandStr(lora::ChannelPlan::US915) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 27 | band = lora::ChannelPlan::US915; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 28 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 29 | if (mDot::FrequencyBandStr(lora::ChannelPlan::AU915) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 30 | band = lora::ChannelPlan::AU915; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 31 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 32 | if (mDot::FrequencyBandStr(lora::ChannelPlan::EU868) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 33 | band = lora::ChannelPlan::EU868; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 34 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 35 | if (mDot::FrequencyBandStr(lora::ChannelPlan::AS923) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 36 | band = lora::ChannelPlan::AS923; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 37 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 38 | if (mDot::FrequencyBandStr(lora::ChannelPlan::KR920) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 39 | band = lora::ChannelPlan::KR920; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 40 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 41 | if (mDot::FrequencyBandStr(lora::ChannelPlan::AS923_JAPAN) == band_str) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 42 | band = lora::ChannelPlan::AS923_JAPAN; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 43 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 44 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 45 | if (CommandTerminal::Dot()->setDefaultFrequencyBand(band) != mDot::MDOT_OK) { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 46 | CommandTerminal::setErrorMessage(CommandTerminal::Dot()->getLastError());; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 47 | return 1; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 48 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 49 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 50 | #endif |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 51 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 52 | return 0; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 53 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 54 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 55 | bool CmdDefaultFrequencyBand::verify(std::vector<std::string> args) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 56 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 57 | if (args.size() == 1) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 58 | return true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 59 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 60 | #ifdef DEBUG_MAC |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 61 | if (args.size() == 2) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 62 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 63 | std::string band = mts::Text::toUpper(args[1]); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 64 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 65 | if (mDot::FrequencyBandStr(lora::ChannelPlan::NONE) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 66 | mDot::FrequencyBandStr(lora::ChannelPlan::US915) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 67 | mDot::FrequencyBandStr(lora::ChannelPlan::AU915) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 68 | mDot::FrequencyBandStr(lora::ChannelPlan::EU868) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 69 | mDot::FrequencyBandStr(lora::ChannelPlan::AS923) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 70 | mDot::FrequencyBandStr(lora::ChannelPlan::KR920) != band && |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 71 | mDot::FrequencyBandStr(lora::ChannelPlan::AS923_JAPAN) != band) |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 72 | { |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 73 | CommandTerminal::setErrorMessage("Invalid parameter, expects (NONE,US915,AU915,EU868,AS923,KR920,AS923-JAPAN)"); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 74 | return false; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 75 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 76 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 77 | return true; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 78 | } |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 79 | #endif |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 80 | |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 81 | CommandTerminal::setErrorMessage("Invalid arguments"); |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 82 | return false; |
jenkins@jenkinsdm1 | 17:95c9eb69329a | 83 | } |