From bca5f50214f103a2c8605778a6311f8e9a5902fe Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Tue, 19 Jul 2016 10:14:13 -0500 Subject: mts-lora datarate changes --- .gitmodules | 4 +- CommandTerminal/CmdDisplayConfig.cpp | 2 +- CommandTerminal/CmdFactoryDefault.cpp | 2 +- CommandTerminal/CmdFrequencyBand.cpp | 10 +-- CommandTerminal/CmdTxDataRate.cpp | 131 ++++++++++++++++++++++------------ FileName.h | 2 +- Mode/Mode.cpp | 4 +- Mode/ModeDemo.cpp | 6 +- Mode/ModeJoin.cpp | 5 +- Mode/ModeSingle.cpp | 33 ++------- Mode/ModeSweep.cpp | 32 ++++----- main.cpp | 28 +++++--- mdot-library | 2 +- parser_function.txt | 2 +- 14 files changed, 145 insertions(+), 118 deletions(-) diff --git a/.gitmodules b/.gitmodules index d9b13e1..69cfdcd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "mdot-library"] path = mdot-library - url = ssh://sw.multitech.prv/git/mbed/mdot-library.git + url = git@gitlab.multitech.net:lora-mote/mdot-library.git [submodule "libs/MTS-Serial"] path = libs/MTS-Serial - url = ssh://sw.multitech.prv/git/mbed/MTS-Serial.git + url = git@gitlab.multitech.net:mbed/MTS-Serial.git diff --git a/CommandTerminal/CmdDisplayConfig.cpp b/CommandTerminal/CmdDisplayConfig.cpp index 31fc100..58ba86d 100644 --- a/CommandTerminal/CmdDisplayConfig.cpp +++ b/CommandTerminal/CmdDisplayConfig.cpp @@ -38,7 +38,7 @@ uint32_t CmdDisplayConfig::action(std::vector args) { _serial.writef("%s\r\n", mts::Text::bin2hexString(_dot->getDeviceId(), ":").c_str()); _serial.writef("Frequency Band:\t\t%s\r\n", mDot::FrequencyBandStr(_dot->getFrequencyBand()).c_str()); - if (_dot->getFrequencyBand() == mDot::FB_915) + if (_dot->getFrequencyBand() == mDot::FB_US915) _serial.writef("Frequency Sub Band:\t%u\r\n", _dot->getFrequencySubBand()); _serial.writef("Public Network:\t\t%s\r\n", _dot->getPublicNetwork() ? "on" : "off"); diff --git a/CommandTerminal/CmdFactoryDefault.cpp b/CommandTerminal/CmdFactoryDefault.cpp index 955535e..a8554cb 100644 --- a/CommandTerminal/CmdFactoryDefault.cpp +++ b/CommandTerminal/CmdFactoryDefault.cpp @@ -29,7 +29,7 @@ uint32_t CmdFactoryDefault::action(std::vector args) _dot->resetConfig(); //Factory defaults for the DotBox. - _dot->setTxDataRate(mDot::SF_7); + _dot->setTxDataRate(mDot::DR0); _dot->setFrequencySubBand(1); _dot->setWakeDelay(242); //DotBox +MaxSize is stored here. Default is 242. _dot->setWakeInterval(11); //DotBox +MinSize is stored here. Default is 11. diff --git a/CommandTerminal/CmdFrequencyBand.cpp b/CommandTerminal/CmdFrequencyBand.cpp index 4057f7a..26b7831 100644 --- a/CommandTerminal/CmdFrequencyBand.cpp +++ b/CommandTerminal/CmdFrequencyBand.cpp @@ -40,10 +40,10 @@ uint32_t CmdFrequencyBand::action(std::vector args) else if (args.size() == 2) { int32_t code; - uint8_t band = mDot::FB_915; + uint8_t band = mDot::FB_US915; - if (mDot::FrequencyBandStr(mDot::FB_868).find(args[1]) != std::string::npos) { - band = mDot::FB_868; + if (mDot::FrequencyBandStr(mDot::FB_EU868).find(args[1]) != std::string::npos) { + band = mDot::FB_EU868; } if ((code = _dot->setFrequencyBand(band)) != mDot::MDOT_OK) { @@ -65,8 +65,8 @@ bool CmdFrequencyBand::verify(std::vector args) #ifdef DEBUG_MAC if (args.size() == 2) { - if (mDot::FrequencyBandStr(mDot::FB_868).find(args[1]) == std::string::npos && - mDot::FrequencyBandStr(mDot::FB_915).find(args[1]) == std::string::npos) + if (mDot::FrequencyBandStr(mDot::FB_EU868).find(args[1]) == std::string::npos && + mDot::FrequencyBandStr(mDot::FB_US915).find(args[1]) == std::string::npos) { setErrorMessage("Invalid parameter, expects (868,915)"); return false; diff --git a/CommandTerminal/CmdTxDataRate.cpp b/CommandTerminal/CmdTxDataRate.cpp index 846562b..004ee8e 100644 --- a/CommandTerminal/CmdTxDataRate.cpp +++ b/CommandTerminal/CmdTxDataRate.cpp @@ -15,49 +15,59 @@ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - #include "CmdTxDataRate.h" +#include "MTSText.h" +#include "MTSLog.h" -CmdTxDataRate::CmdTxDataRate(mDot* dot, mts::MTSSerial& serial) : - Command(dot, "Tx Data Rate", "AT+TXDR", "Set the Tx data rate for LoRa demo mode"), _serial(serial) +CmdTxDataRate::CmdTxDataRate(mDot* dot, mts::MTSSerial& serial) +: + Command(dot, "Tx Data Rate", "AT+TXDR", "Set the Tx data rate for all channels"), + _serial(serial) { _help = std::string(text()) + ": " + std::string(desc()); if (_dot->getFrequencyBand() == mDot::FB_915) - _usage = "(7-10)"; + _usage = "(7-10|DR0-DR4|DR8-DR13)"; else - _usage = "(7-12)"; + _usage = "(7-12|DR0-DR7)"; _queryable = true; } -uint32_t CmdTxDataRate::action(std::vector args) -{ +uint32_t CmdTxDataRate::action(std::vector args) { if (args.size() == 1) - { + { if (_dot->getVerbose()) _serial.writef("Tx Data Rate: "); - _serial.writef("%s\r\n", mDot::DataRateStr(_dot->getTxDataRate()).c_str()); - } - else if (args.size() == 2) - { + _serial.writef("DR%d - %s\r\n", _dot->getTxDataRate(), _dot->getDateRateDetails(_dot->getTxDataRate()).c_str()); + } else if (args.size() == 2) { + std::string dr = mts::Text::toUpper(args[1]); int32_t code; - uint8_t datarate = 0; + int datarate = -1; uint8_t i; - for (i = 0; i < 8; i++) - { - if (mDot::DataRateStr(i).find(args[1].c_str()) != std::string::npos) - { - datarate = i; - break; + int res = sscanf(dr.c_str(), "%d", &datarate); + + if (res == 0) { + for (i = 0; i < 24; i++) { + if (mDot::DataRateStr(i).find(dr) != std::string::npos) { + datarate = i; + break; + } + } + } else { + if (datarate > 6) { + // Convert SF to DR + if (_dot->getFrequencyBand() == mDot::FB_915) { + datarate = 10 - datarate; + } else { + datarate = 12 - datarate; + } } } - if ((code = _dot->setTxDataRate(datarate)) != mDot::MDOT_OK) - { - std::string error = mDot::getReturnCodeString(code) + " - " + _dot->getLastError(); - setErrorMessage(error); + if ((code = _dot->setTxDataRate(datarate)) != mDot::MDOT_OK) { + setErrorMessage(_dot->getLastError()); return 1; } } @@ -65,36 +75,69 @@ uint32_t CmdTxDataRate::action(std::vector args) return 0; } -bool CmdTxDataRate::verify(std::vector args) -{ +bool CmdTxDataRate::verify(std::vector args) { if (args.size() == 1) return true; - if (args.size() == 2) - { + if (args.size() == 2) { + std::string dr = mts::Text::toUpper(args[1]); + uint8_t i; int datarate = -1; - for (i = 0; i < 8; i++) - { - if (mDot::DataRateStr(i).find(args[1].c_str()) != std::string::npos) - { - datarate = i; - break; + + int res = sscanf(dr.c_str(), "%d", &datarate); + + if (res == 0) { + for (i = 0; i < 24; i++) { + + if (mDot::DataRateStr(i).find(dr) != std::string::npos) { + uint8_t _dr = i; + + if (_dr > 15) { + _dr = 12 + (mDot::SF_12 - _dr); + + if (_dot->getFrequencyBand() == mDot::FB_868) { + if (_dr == mDot::SF_7H) { + _dr = mDot::DR6; + } else if (_dr == mDot::SF_FSK) { + _dr = mDot::DR7; + } else { + _dr = 12 - _dr; + } + } else { + + _dr = 10 - _dr; + } + } + + datarate = _dr; + break; + } + } + } else { + if (_dot->getFrequencyBand() == mDot::FB_915 && datarate > 10) { + datarate = -1; + } else if (_dot->getFrequencyBand() == mDot::FB_868 && datarate > 12) { + datarate = -1; + } else if (datarate > 6) { + // Convert SF to DR + if (_dot->getFrequencyBand() == mDot::FB_915) { + datarate = 10 - datarate; + } else { + datarate = 12 - datarate; + } } } - if (datarate < 0) - { - if (_dot->getFrequencyBand() == mDot::FB_915) - setErrorMessage("Invalid data rate, expects (7-10)"); - else - setErrorMessage("Invalid data rate, expects (7-12)"); - return false; - } - if (_dot->getFrequencyBand() == mDot::FB_915) { - if (datarate < 2) { - setErrorMessage("Invalid data rate, expects (7-10)"); + // DR8-13 used for P2P modes + if (datarate < 0 || datarate > 13 || (datarate >= 5 && datarate <= 7)) { + setErrorMessage("Invalid data rate, expects (7-10|DR0-DR4|DR8-DR13)"); + return false; + } + } else { + if (datarate < 0 || datarate > 7) { + setErrorMessage("Invalid data rate, expects (7-12|DR0-DR7)"); return false; } } diff --git a/FileName.h b/FileName.h index 23468e2..2b671a4 100644 --- a/FileName.h +++ b/FileName.h @@ -19,6 +19,6 @@ #ifndef __FILENAME_H__ #define __FILENAME_H__ -extern char* file_name; +extern char file_name[]; #endif diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp index 389bf7f..bed78ec 100644 --- a/Mode/Mode.cpp +++ b/Mode/Mode.cpp @@ -49,7 +49,7 @@ Mode::Mode(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, G _index(0), _band(_dot->getFrequencyBand()), _sub_band(_dot->getFrequencySubBand()), - _data_rate(mDot::SF_7), + _data_rate(mDot::DR0), _power(2), _next_tx(0), _send_data(false), @@ -129,7 +129,7 @@ bool Mode::appendDataFile(const DataItem& data) { (data.gps_lock) ? alt_buf : "", (data.gps_lock) ? time_buf : "", data.status ? stats_buf : ",,,", - _dot->DataRateStr(data.data_rate).substr(3).c_str(), + _dot->DataRateStr(data.data_rate).substr(2).c_str(), data.power); if (size < 0) { diff --git a/Mode/ModeDemo.cpp b/Mode/ModeDemo.cpp index 44732c1..4add135 100644 --- a/Mode/ModeDemo.cpp +++ b/Mode/ModeDemo.cpp @@ -41,9 +41,9 @@ bool ModeDemo::start() { _initial_data_rate = _dot->getTxDataRate(); // use configured data rate and power if possible - if (_band == mDot::FB_915 && _initial_data_rate == mDot::SF_10) { - logInfo("using SF_9 instead of SF_10 - SF_10 max packet size is too small for data"); - _dot->setTxDataRate(mDot::SF_9); + if (_band == mDot::FB_915 && _initial_data_rate == mDot::DR0) { + logInfo("using DR1 instead of DR0 - DR0 max packet size is too small for data"); + _dot->setTxDataRate(mDot::DR1); } _state = show_help; diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index 5618eca..4bdc6cd 100644 --- a/Mode/ModeJoin.cpp +++ b/Mode/ModeJoin.cpp @@ -42,7 +42,7 @@ bool ModeJoin::start() { _initial_data_rate = _dot->getTxDataRate(); _initial_power = _dot->getTxPower(); - _data_rate = (_band == mDot::FB_915) ? mDot::SF_10 : mDot::SF_12; + _data_rate = mDot::DR0; _power = 20; _joined = false; @@ -123,8 +123,7 @@ void ModeJoin::display() { _sub_band = _dot->getFrequencySubBand(); _join.updateFsb(_sub_band); } - // mDot::DataRateStr returns format SF_XX - we only want to display the XX part - _join.updateRate(_dot->DataRateStr(_data_rate).substr(3)); + _join.updateRate(_dot->DataRateStr(_data_rate).substr(2)); _join.updatePower(_power); _join.updateAttempt(_lora->getJoinAttempts()); } diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp index 347f636..982d8b9 100644 --- a/Mode/ModeSingle.cpp +++ b/Mode/ModeSingle.cpp @@ -176,8 +176,8 @@ bool ModeSingle::start() { _state = failure; _failure.display(); _failure.updateId(_index); - // mDot::DataRateStr returns format SF_XX - we only want to display the XX part - _failure.updateRate(_dot->DataRateStr(_data_rate).substr(3)); + // mDot::DataRateStr returns format DRXX - we only want to display the XX part + _failure.updateRate(_dot->DataRateStr(_data_rate).substr(2)); updateData(_data, single, false); appendDataFile(_data); _failure.updatePower(_power); @@ -291,7 +291,7 @@ void ModeSingle::displaySuccess() { _success.display(); _success.updateId(_index); // mDot::DataRateStr returns format SF_XX - we only want to display the XX part - _success.updateRate(_dot->DataRateStr(_data_rate).substr(3)); + _success.updateRate(_dot->DataRateStr(_data_rate).substr(2)); _success.updatePower(_power); _success.updateStats(_link_check_result); if (_gps_available && _gps->getLockStatus()) { @@ -312,7 +312,7 @@ std::string ModeSingle::formatRatePower() { size_t size; msg += "DR="; - msg += _dot->DataRateStr(_data_rate).substr(3); + msg += _dot->DataRateStr(_data_rate).substr(2); msg += " P="; size = snprintf(buf, sizeof(buf), "%u", _power); msg.append(buf, size); @@ -323,28 +323,9 @@ std::string ModeSingle::formatRatePower() { void ModeSingle::incrementRatePower() { if (_power == 20) { _power = 2; - switch (_data_rate) { - case mDot::SF_7: - _data_rate = mDot::SF_8; - break; - case mDot::SF_8: - _data_rate = mDot::SF_9; - break; - case mDot::SF_9: - _data_rate = mDot::SF_10; - break; - case mDot::SF_10: - if (_band == mDot::FB_915) - _data_rate = mDot::SF_7; - else - _data_rate = mDot::SF_11; - break; - case mDot::SF_11: - _data_rate = mDot::SF_12; - break; - case mDot::SF_12: - _data_rate = mDot::SF_7; - break; + _data_rate++; + if (_band == mDot::FB_915 && _data_rate > mDot::DR4 || _band == mDot::FB_868 && _data_rate > mDot::DR7) { + _data_rate = mDot::DR0; } } else { _power += 3; diff --git a/Mode/ModeSweep.cpp b/Mode/ModeSweep.cpp index 6ff4e34..b6bef24 100644 --- a/Mode/ModeSweep.cpp +++ b/Mode/ModeSweep.cpp @@ -207,8 +207,7 @@ bool ModeSweep::start() { _state = failure; _failure.display(); _failure.updateId(_index); - // mDot::DataRateStr returns format SF_XX - we only want to display the XX part - _failure.updateRate(_dot->DataRateStr(_data_rate).substr(3)); + _failure.updateRate(_dot->DataRateStr(_data_rate).substr(2)); _failure.updatePower(_power); if (_gps_available && _gps->getLockStatus()) { GPSPARSER::latitude lat = _gps->getLatitude(); @@ -343,8 +342,7 @@ void ModeSweep::displayHelp() { void ModeSweep::displaySuccess() { _success.display(); _success.updateId(_index); - // mDot::DataRateStr returns format SF_XX - we only want to display the XX part - _success.updateRate(_dot->DataRateStr(_data_rate).substr(3)); + _success.updateRate(_dot->DataRateStr(_data_rate).substr(2)); _success.updatePower(_power); _success.updateStats(_link_check_result); if (_gps_available && _gps->getLockStatus()) { @@ -383,23 +381,21 @@ std::vector ModeSweep::generatePoints() { uint8_t ModeSweep::payloadToRate(uint8_t payload) { if (_band == mDot::FB_915) { - if (payload <= mDot::MaxLengths_915[mDot::SF_10]) - return mDot::SF_10; - else if (payload <= mDot::MaxLengths_915[mDot::SF_9]) - return mDot::SF_9; - else if (payload <= mDot::MaxLengths_915[mDot::SF_8]) - return mDot::SF_8; + if (payload <= mDot::MaxLengths_915[mDot::DR0]) + return mDot::DR0; + else if (payload <= mDot::MaxLengths_915[mDot::DR1]) + return mDot::DR1; + else if (payload <= mDot::MaxLengths_915[mDot::DR2]) + return mDot::DR2; else - return mDot::SF_7; + return mDot::DR4; } else { - if (payload <= mDot::MaxLengths_868[mDot::SF_12]) - return mDot::SF_12; - else if (payload <= mDot::MaxLengths_868[mDot::SF_9]) - return mDot::SF_9; + if (payload <= mDot::MaxLengths_868[mDot::DR0]) + return mDot::DR0; + else if (payload <= mDot::MaxLengths_868[mDot::DR3]) + return mDot::DR3; else - return mDot::SF_7; + return mDot::DR6; } - - return mDot::SF_7; } diff --git a/main.cpp b/main.cpp index 9166354..464b00a 100644 --- a/main.cpp +++ b/main.cpp @@ -45,6 +45,9 @@ #include "FileName.h" #include +#define DISABLE_DUTY_CYCLE true + + // LCD and LED controllers SPI lcd_spi(SPI1_MOSI, SPI1_MISO, SPI1_SCK); I2C led_i2c(I2C_SDA, I2C_SCL); @@ -60,7 +63,7 @@ osThreadId main_id; ButtonHandler* buttons; // LoRa controller -LoRaHandler* lora; +LoRaHandler* loraHandler; mDot* dot; // GPS @@ -81,14 +84,13 @@ ModeConfig* modeConfig; Serial debug(USBTX, USBRX); // Survey Data File -char* file_name; +char file_name[] = "SurveyData.txt"; // Prototypes void mainMenu(); int main() { debug.baud(115200); - file_name = "SurveyData.txt"; lcd = new DOGS102(lcd_spi, lcd_spi_cs, lcd_cd); // NCP5623B::LEDs 1 & 2 are the screen backlight - not used on default build @@ -98,7 +100,13 @@ int main() { main_id = Thread::gettid(); buttons = new ButtonHandler(main_id); dot = mDot::getInstance(); - lora = new LoRaHandler(main_id); + + dot->setDisableDutyCycle(DISABLE_DUTY_CYCLE); + + // Seed the RNG + srand(dot->getRadioRandom()); + + loraHandler = new LoRaHandler(main_id); gps = new GPSPARSER(&gps_serial, led_cont); sensors = new SensorHandler(); @@ -106,11 +114,11 @@ int main() { MTSLog::setLogLevel(MTSLog::TRACE_LEVEL); - modeJoin = new ModeJoin(lcd, buttons, dot, lora, gps, sensors); - modeSingle = new ModeSingle(lcd, buttons, dot, lora, gps, sensors); - modeSweep = new ModeSweep(lcd, buttons, dot, lora, gps, sensors); - modeDemo = new ModeDemo(lcd, buttons, dot, lora, gps, sensors); - modeConfig = new ModeConfig(lcd, buttons, dot, lora, gps, sensors); + modeJoin = new ModeJoin(lcd, buttons, dot, loraHandler, gps, sensors); + modeSingle = new ModeSingle(lcd, buttons, dot, loraHandler, gps, sensors); + modeSweep = new ModeSweep(lcd, buttons, dot, loraHandler, gps, sensors); + modeDemo = new ModeDemo(lcd, buttons, dot, loraHandler, gps, sensors); + modeConfig = new ModeConfig(lcd, buttons, dot, loraHandler, gps, sensors); osDelay(1000); logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no "); @@ -159,7 +167,7 @@ void mainMenu() { // reset session between modes dot->resetNetworkSession(); - lora->resetActivityLed(); + loraHandler->resetActivityLed(); LayoutScrollSelect menu(lcd, items, product, menu_strings[0]); menu.display(); diff --git a/mdot-library b/mdot-library index f924703..dad8ecc 160000 --- a/mdot-library +++ b/mdot-library @@ -1 +1 @@ -Subproject commit f9247034c1eb0efc07ccf1d77312421fec75ace8 +Subproject commit dad8ecc852ff6cbc3af9836e2931676e6194d25c diff --git a/parser_function.txt b/parser_function.txt index 06a7a60..4bc16f9 100644 --- a/parser_function.txt +++ b/parser_function.txt @@ -182,7 +182,7 @@ while (msg_pntr < msg.payload.length){ } } -pData.sf_val = parseInt(msg.datr.replace("SF"," "),10); +pData.sf_val = parseInt(msg.datr.replace("DR"," "),10); context.global.data_out = pData; -- cgit v1.2.3 From 345b51d7c6a85e6d7cb7d507af7df104e65e99af Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:34:05 -0500 Subject: Replace LoRaHandler.cpp --- LoRaHandler/LoRaHandler.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/LoRaHandler/LoRaHandler.cpp b/LoRaHandler/LoRaHandler.cpp index de9f0b1..d52ca54 100644 --- a/LoRaHandler/LoRaHandler.cpp +++ b/LoRaHandler/LoRaHandler.cpp @@ -87,12 +87,16 @@ void l_worker(void const* argument) { l->_mutex.unlock(); if (ret == mDot::MDOT_OK) { l->_status = LoRaHandler::join_success; + osSignalSet(l->_main, loraSignal); + l->_tick.detach(); + l->_activity_led = LoRaHandler::green; } else { l->_status = LoRaHandler::join_failure; + osSignalSet(l->_main, loraSignal); + l->_tick.detach(); + l->_activity_led = LoRaHandler::red; } - osSignalSet(l->_main, loraSignal); - l->_tick.detach(); - l->_activity_led = LoRaHandler::green; + break; default: @@ -180,3 +184,4 @@ void LoRaHandler::resetActivityLed() { _activity_led = red; } + -- cgit v1.2.3 From b3786e3cf0a1ebe7d7982b2d50f1223bd462f344 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:34:30 -0500 Subject: Upload new file --- Layout/LayoutSemtech.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 Layout/LayoutSemtech.h diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h new file mode 100644 index 0000000..374c1ff --- /dev/null +++ b/Layout/LayoutSemtech.h @@ -0,0 +1,75 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LAYOUTSEMTECH_H__ +#define __LAYOUTSEMTECH_H__ + +#include "Layout.h" +#include "GPSPARSER.h" +#include "LoRaHandler.h" + +class LayoutSemtech : public Layout +{ +public: + LayoutSemtech(DOGS102* lcd, uint8_t band); + ~LayoutSemtech(); + + void display(); + void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr); + + void sending(); + void updateSw2(string str); + void sendResult(string str); + void updateNextCh(int count_down); + void updateSw1(string Sw1, string Sw2, int dr, int power, int padding); + void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp); + +private: + uint8_t _band; + + Label _lDr; + Label _lFSB; + Label _lSend; + Label _lTemp; + Label _lNoGps; + Label _lPower; + Label _lNoLink; + Label _lPadding; + Label _lNoChannel; + + Field _fDr; + Field _fSw1; + Field _fSw2; + Field _fFSB; + Field _fTemp; + Field _fPower; + Field _fNextCh; + Field _fGpsLat; + Field _fGpsLon; + Field _fResult; + Field _fGpsTime; + Field _fDownSnr; + Field _fPadding; + Field _fDownRssi; +}; + +#endif + + + + -- cgit v1.2.3 From e005a667e764b13cfa9584c6c7bece7c1fc868ad Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:34:47 -0500 Subject: Upload new file --- LayoutSemtech.cpp | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 LayoutSemtech.cpp diff --git a/LayoutSemtech.cpp b/LayoutSemtech.cpp new file mode 100644 index 0000000..dcaf2ad --- /dev/null +++ b/LayoutSemtech.cpp @@ -0,0 +1,193 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LayoutSemtech.h" + + +LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) + : Layout(lcd), + _lDr(8,0,"DR"), + _lFSB(0,0,"FSB"), + _lPower(13,0,"P"), + _lTemp(8,6,"Temp "), + _lPadding(0,6,"Pad"), + _lSend(3,3,"Sending..."), + _lNoGps(0,4,"No Gps Lock"), + _lNoLink(0,2,"No Link Data"), + _lNoChannel(0,3,"No Free Channel"), + _fFSB(3,0,1), + _fDr(10,0,2), + _fSw2(0,7,9), + _fSw1(13,7,4), + _fTemp(13,6,4), + _fPower(14,0,2), + _fNextCh(0,5,17), + _fGpsLat(0,3,17), + _fGpsLon(0,4,17), + _fResult(3,3,16), + _fPadding(4,6,3), + _fDownSnr(12,2,5), + _fGpsTime(0,5,16), + _fDownRssi(0,2,11), + _band(band) +{} + +LayoutSemtech::~LayoutSemtech() {} + +void LayoutSemtech::display() {} + +void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) +{ + char buf[17]; + size_t size; + + clear(); + startUpdate(); + + writeLabel(_lDr); + writeLabel(_lTemp); + writeLabel(_lPower); + writeLabel(_lPadding); + if (_band == mDot::FB_915) { + writeLabel(_lFSB); + } + if(success) { + size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); + writeField(_fDownRssi, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0); + writeField(_fDownSnr, buf, size); + } else writeLabel(_lNoLink); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",dr); + writeField(_fDr, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",power); + writeField(_fPower, buf, size, true); + + if (_band == mDot::FB_915) { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",fsb); + writeField(_fFSB, buf, size, true); + } + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",padding); + writeField(_fPadding, buf, size, true); + + endUpdate(); +} + +void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding) +{ + size_t size; + char buf[17]; + string temp; + for(int i = Sw1.size(); i<4; i++) temp+=" "; + temp+=Sw1; + writeField(_fSw1, temp, true); + startUpdate(); + if(Sw2=="Data Rate") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",dr); + writeField(_fDr, buf, size, true); + } else if(Sw2=="Power") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",power); + writeField(_fPower, buf, size, true); + } else if(Sw2=="Padding") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",padding); + writeField(_fPadding, buf, size, true); + } + endUpdate(); +} + +void LayoutSemtech::updateSw2(string Sw2) +{ + writeField(_fSw2, Sw2, true); +} + +void LayoutSemtech::sending() +{ + clear(); + writeLabel(_lSend); +} + +void LayoutSemtech::sendResult(string str) +{ + clear(); + writeField(_fResult,str,true); +} + + +void LayoutSemtech::updateNextCh(int count_down) +{ + clear(); + size_t size; + char buf[17]; + size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down); + writeField(_fNextCh, buf, size, true); + writeLabel(_lNoChannel); +} + +void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp) +{ + char buf[17]; + size_t size; + + startUpdate(); + + if(GPS) { + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lon.degrees), + lon.minutes, + (lon.seconds * 6) / 1000, + (lon.seconds * 6) % 1000, + (lon.degrees > 0) ? 'E' : 'W'); + writeField(_fGpsLon, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lat.degrees), + lat.minutes, + (lat.seconds * 6) / 1000, + (lat.seconds * 6) % 1000, + (lat.degrees > 0) ? 'N' : 'S'); + writeField(_fGpsLat, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", + time.tm_hour, + time.tm_min, + time.tm_mon + 1, + time.tm_mday, + time.tm_year + 1900); + writeField(_fGpsTime, buf, size, true); + + } else writeLabel(_lNoGps); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%.1f",temp); + writeField(_fTemp, buf, size, true); + + endUpdate(); +} -- cgit v1.2.3 From 703c272f58baa73dcfb588842470a31f0f793462 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:34:59 -0500 Subject: Delete LayoutSemtech.cpp --- LayoutSemtech.cpp | 193 ------------------------------------------------------ 1 file changed, 193 deletions(-) delete mode 100644 LayoutSemtech.cpp diff --git a/LayoutSemtech.cpp b/LayoutSemtech.cpp deleted file mode 100644 index dcaf2ad..0000000 --- a/LayoutSemtech.cpp +++ /dev/null @@ -1,193 +0,0 @@ -/* Copyright (c) <2016> , MIT License - * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all copies or - * substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "LayoutSemtech.h" - - -LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) - : Layout(lcd), - _lDr(8,0,"DR"), - _lFSB(0,0,"FSB"), - _lPower(13,0,"P"), - _lTemp(8,6,"Temp "), - _lPadding(0,6,"Pad"), - _lSend(3,3,"Sending..."), - _lNoGps(0,4,"No Gps Lock"), - _lNoLink(0,2,"No Link Data"), - _lNoChannel(0,3,"No Free Channel"), - _fFSB(3,0,1), - _fDr(10,0,2), - _fSw2(0,7,9), - _fSw1(13,7,4), - _fTemp(13,6,4), - _fPower(14,0,2), - _fNextCh(0,5,17), - _fGpsLat(0,3,17), - _fGpsLon(0,4,17), - _fResult(3,3,16), - _fPadding(4,6,3), - _fDownSnr(12,2,5), - _fGpsTime(0,5,16), - _fDownRssi(0,2,11), - _band(band) -{} - -LayoutSemtech::~LayoutSemtech() {} - -void LayoutSemtech::display() {} - -void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) -{ - char buf[17]; - size_t size; - - clear(); - startUpdate(); - - writeLabel(_lDr); - writeLabel(_lTemp); - writeLabel(_lPower); - writeLabel(_lPadding); - if (_band == mDot::FB_915) { - writeLabel(_lFSB); - } - if(success) { - size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); - writeField(_fDownRssi, buf, size); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0); - writeField(_fDownSnr, buf, size); - } else writeLabel(_lNoLink); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",dr); - writeField(_fDr, buf, size, true); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",power); - writeField(_fPower, buf, size, true); - - if (_band == mDot::FB_915) { - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",fsb); - writeField(_fFSB, buf, size, true); - } - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",padding); - writeField(_fPadding, buf, size, true); - - endUpdate(); -} - -void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding) -{ - size_t size; - char buf[17]; - string temp; - for(int i = Sw1.size(); i<4; i++) temp+=" "; - temp+=Sw1; - writeField(_fSw1, temp, true); - startUpdate(); - if(Sw2=="Data Rate") { - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",dr); - writeField(_fDr, buf, size, true); - } else if(Sw2=="Power") { - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",power); - writeField(_fPower, buf, size, true); - } else if(Sw2=="Padding") { - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",padding); - writeField(_fPadding, buf, size, true); - } - endUpdate(); -} - -void LayoutSemtech::updateSw2(string Sw2) -{ - writeField(_fSw2, Sw2, true); -} - -void LayoutSemtech::sending() -{ - clear(); - writeLabel(_lSend); -} - -void LayoutSemtech::sendResult(string str) -{ - clear(); - writeField(_fResult,str,true); -} - - -void LayoutSemtech::updateNextCh(int count_down) -{ - clear(); - size_t size; - char buf[17]; - size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down); - writeField(_fNextCh, buf, size, true); - writeLabel(_lNoChannel); -} - -void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp) -{ - char buf[17]; - size_t size; - - startUpdate(); - - if(GPS) { - size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", - abs(lon.degrees), - lon.minutes, - (lon.seconds * 6) / 1000, - (lon.seconds * 6) % 1000, - (lon.degrees > 0) ? 'E' : 'W'); - writeField(_fGpsLon, buf, size, true); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", - abs(lat.degrees), - lat.minutes, - (lat.seconds * 6) / 1000, - (lat.seconds * 6) % 1000, - (lat.degrees > 0) ? 'N' : 'S'); - writeField(_fGpsLat, buf, size, true); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", - time.tm_hour, - time.tm_min, - time.tm_mon + 1, - time.tm_mday, - time.tm_year + 1900); - writeField(_fGpsTime, buf, size, true); - - } else writeLabel(_lNoGps); - - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%.1f",temp); - writeField(_fTemp, buf, size, true); - - endUpdate(); -} -- cgit v1.2.3 From 172705f116714555decd2635b3a4cca0f32f4a8c Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:35:12 -0500 Subject: Upload new file --- Layout/LayoutSemtech.cpp | 193 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 Layout/LayoutSemtech.cpp diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp new file mode 100644 index 0000000..dcaf2ad --- /dev/null +++ b/Layout/LayoutSemtech.cpp @@ -0,0 +1,193 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LayoutSemtech.h" + + +LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) + : Layout(lcd), + _lDr(8,0,"DR"), + _lFSB(0,0,"FSB"), + _lPower(13,0,"P"), + _lTemp(8,6,"Temp "), + _lPadding(0,6,"Pad"), + _lSend(3,3,"Sending..."), + _lNoGps(0,4,"No Gps Lock"), + _lNoLink(0,2,"No Link Data"), + _lNoChannel(0,3,"No Free Channel"), + _fFSB(3,0,1), + _fDr(10,0,2), + _fSw2(0,7,9), + _fSw1(13,7,4), + _fTemp(13,6,4), + _fPower(14,0,2), + _fNextCh(0,5,17), + _fGpsLat(0,3,17), + _fGpsLon(0,4,17), + _fResult(3,3,16), + _fPadding(4,6,3), + _fDownSnr(12,2,5), + _fGpsTime(0,5,16), + _fDownRssi(0,2,11), + _band(band) +{} + +LayoutSemtech::~LayoutSemtech() {} + +void LayoutSemtech::display() {} + +void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) +{ + char buf[17]; + size_t size; + + clear(); + startUpdate(); + + writeLabel(_lDr); + writeLabel(_lTemp); + writeLabel(_lPower); + writeLabel(_lPadding); + if (_band == mDot::FB_915) { + writeLabel(_lFSB); + } + if(success) { + size = snprintf(buf, sizeof(buf), "DWN %3d dbm", rssi.last); + writeField(_fDownRssi, buf, size); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), " %2.1f", (float)snr.last / 10.0); + writeField(_fDownSnr, buf, size); + } else writeLabel(_lNoLink); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",dr); + writeField(_fDr, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",power); + writeField(_fPower, buf, size, true); + + if (_band == mDot::FB_915) { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",fsb); + writeField(_fFSB, buf, size, true); + } + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",padding); + writeField(_fPadding, buf, size, true); + + endUpdate(); +} + +void LayoutSemtech::updateSw1(string Sw1, string Sw2, int dr, int power, int padding) +{ + size_t size; + char buf[17]; + string temp; + for(int i = Sw1.size(); i<4; i++) temp+=" "; + temp+=Sw1; + writeField(_fSw1, temp, true); + startUpdate(); + if(Sw2=="Data Rate") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",dr); + writeField(_fDr, buf, size, true); + } else if(Sw2=="Power") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",power); + writeField(_fPower, buf, size, true); + } else if(Sw2=="Padding") { + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d",padding); + writeField(_fPadding, buf, size, true); + } + endUpdate(); +} + +void LayoutSemtech::updateSw2(string Sw2) +{ + writeField(_fSw2, Sw2, true); +} + +void LayoutSemtech::sending() +{ + clear(); + writeLabel(_lSend); +} + +void LayoutSemtech::sendResult(string str) +{ + clear(); + writeField(_fResult,str,true); +} + + +void LayoutSemtech::updateNextCh(int count_down) +{ + clear(); + size_t size; + char buf[17]; + size = snprintf(buf, sizeof(buf), "Countdown:%d",count_down); + writeField(_fNextCh, buf, size, true); + writeLabel(_lNoChannel); +} + +void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp) +{ + char buf[17]; + size_t size; + + startUpdate(); + + if(GPS) { + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lon.degrees), + lon.minutes, + (lon.seconds * 6) / 1000, + (lon.seconds * 6) % 1000, + (lon.degrees > 0) ? 'E' : 'W'); + writeField(_fGpsLon, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%d %d %d.%03d %c", + abs(lat.degrees), + lat.minutes, + (lat.seconds * 6) / 1000, + (lat.seconds * 6) % 1000, + (lat.degrees > 0) ? 'N' : 'S'); + writeField(_fGpsLat, buf, size, true); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%02d:%02d %02d/%02d/%04d", + time.tm_hour, + time.tm_min, + time.tm_mon + 1, + time.tm_mday, + time.tm_year + 1900); + writeField(_fGpsTime, buf, size, true); + + } else writeLabel(_lNoGps); + + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%.1f",temp); + writeField(_fTemp, buf, size, true); + + endUpdate(); +} -- cgit v1.2.3 From a431bf590dfe3360abdda47df4e9808c4064b8dc Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:35:35 -0500 Subject: Upload new file --- Layout/LayoutSemtechJoin.h | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 Layout/LayoutSemtechJoin.h diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h new file mode 100644 index 0000000..09ae474 --- /dev/null +++ b/Layout/LayoutSemtechJoin.h @@ -0,0 +1,58 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __LAYOUTSEMTECHJOIN_H__ +#define __LAYOUTSEMTECHJOIN_H__ + +#include "Layout.h" +#include "mDot.h" + +class LayoutSemtechJoin : public Layout { + public: + LayoutSemtechJoin(DOGS102* lcd, uint8_t band); + ~LayoutSemtechJoin(); + + void display(); + + void updateId(std::string id); + void updateKey(std::string key); + void updateFsb(uint8_t band); + void updateRate(std::string rate); + void updatePower(uint32_t power); + + private: + uint8_t _band; + + Label _lId; + Label _lKey; + Label _lFsb; + Label _lRate; + Label _lJoin; + Label _lPower; + + Field _fId; + Field _fKey; + Field _fFsb; + Field _fRate; + Field _fPower; + Field _fStatus; + Field _fSubBand; +}; + +#endif + -- cgit v1.2.3 From 2e2fd69055e52853eaf489ccd3454ac30a0f70ce Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:35:58 -0500 Subject: Upload new file --- Layout/LayoutSemtechJoin.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Layout/LayoutSemtechJoin.cpp diff --git a/Layout/LayoutSemtechJoin.cpp b/Layout/LayoutSemtechJoin.cpp new file mode 100644 index 0000000..f7dbf80 --- /dev/null +++ b/Layout/LayoutSemtechJoin.cpp @@ -0,0 +1,91 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "LayoutSemtechJoin.h" + +LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band) + : Layout(lcd), + _lId(0, 1, "NI="), + _lKey(0, 2, "NK="), + _lFsb(0, 3, "FSB="), + _lRate(0, 5, "DR="), + _lPower(6, 5, "P="), + _lJoin(0, 7, "Join"), + _fId(3, 1, 14), + _fFsb(4, 3, 2), + _fKey(3, 2, 14), + _fRate(3, 5, 2), + _fPower(8, 5, 2), + _fSubBand(16,7,1), + _fStatus(0, 0, 17), + _band(band) +{} + +LayoutSemtechJoin::~LayoutSemtechJoin() {} + +void LayoutSemtechJoin::display() +{ + clear(); + startUpdate(); + + writeLabel(_lId); + writeLabel(_lKey); + if (_band == mDot::FB_915) { + writeLabel(_lFsb); + } + writeLabel(_lRate); + writeLabel(_lPower); + writeLabel(_lJoin); + + endUpdate(); +} + +void LayoutSemtechJoin::updateId(std::string id) +{ + writeField(_fId, id, true); +} + +void LayoutSemtechJoin::updateKey(std::string key) +{ + writeField(_fKey, key, true); +} + +void LayoutSemtechJoin::updateFsb(uint8_t band) +{ + if (_band == mDot::FB_915) { + char buf[8]; + size_t size; + size = snprintf(buf, sizeof(buf), "%u", band); + writeField(_fFsb, buf, size, true); + writeField(_fSubBand, buf, size, true); + } +} + +void LayoutSemtechJoin::updateRate(std::string rate) +{ + writeField(_fRate, rate, true); +} + +void LayoutSemtechJoin::updatePower(uint32_t power) +{ + char buf[16]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%lu", power); + writeField(_fPower, buf, size, true); +} -- cgit v1.2.3 From 7c3d442cae66edcd1c4a7686a9feff0aa9f503d1 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:36:18 -0500 Subject: Upload new file --- Mode/ModeSemtech.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Mode/ModeSemtech.h diff --git a/Mode/ModeSemtech.h b/Mode/ModeSemtech.h new file mode 100644 index 0000000..11a3de8 --- /dev/null +++ b/Mode/ModeSemtech.h @@ -0,0 +1,77 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef __MODESEMTECH_H__ +#define __MODESEMTECH_H__ + +#include "Mode.h" +#include "ModeJoin.h" +#include "LayoutHelp.h" +#include "LayoutSemtech.h" +#include "LayoutSemtechJoin.h" + +class ModeSemtech : public Mode +{ +public: + ModeSemtech(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors); + ~ModeSemtech(); + + bool start(); + +private: + enum {DATA_RATE, FSB, PADDING, POWER, INTERVAL}; + enum {BAND_CHANGE, SENDING, PARAMETERS}; + + LayoutHelp _help; + LayoutSemtech _sem; + LayoutSemtechJoin _sem_join; + + ModeJoin* _join; + + Timer _send_timer, _button_timer; + + float _temp_C; + std::vector _send_data; + uint8_t _parameter, _padding, _interval, + _max_padding, _band; + bool _drAll, _link_check, _GPS; + string _Sw1, _Sw2; + + struct tm _time; + mDot::snr_stats _snr; + mDot::rssi_stats _rssi; + GPSPARSER::latitude _latitude; + GPSPARSER::longitude _longitude; + + void init(); + void send(); + void setBand(); + void sendData(); + void formatData(); + void changeBand(); + void drIncrement(); + void updateScreen(); + void editParameter(); + void changeDataRate(); + void changeParameter(); + string intToString(int num); + +}; + +#endif + -- cgit v1.2.3 From 947d89601174e822639581653c95943ed1d6d2c4 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 28 Jul 2016 10:36:35 -0500 Subject: Upload new file --- Mode/ModeSemtech.cpp | 335 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 Mode/ModeSemtech.cpp diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp new file mode 100644 index 0000000..e6ae52b --- /dev/null +++ b/Mode/ModeSemtech.cpp @@ -0,0 +1,335 @@ +/* Copyright (c) <2016> , MIT License + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or + * substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include "ModeSemtech.h" +#include "MTSLog.h" +#include "rtos.h" +#include "mbed.h" +#include +//this is exactly what it sounds like +#define TWO_TO_THE_THIRTY_ONE_MINUS_ONE 2147483647 +#define PACKETSIZE 11 + + + + +ModeSemtech::ModeSemtech(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors) + : Mode(lcd, buttons, dot, lora, gps, sensors), + _sem(lcd,_band), + _help(lcd), + _sem_join(lcd,_band) +{} + +string ModeSemtech::intToString(int num) +{ + return static_cast(&(ostringstream() << num))->str(); +} + +void ModeSemtech::init() +{ + //resets all parameters when re-entering mode + _interval = 5; + _padding = 0; + _power = 20; + _band = _dot->getFrequencyBand(); + _parameter = POWER; + _drAll=false; + _link_check = false; + _GPS = false; + _sub_band = _dot->getFrequencySubBand(); + _data_rate = mDot::DR4; + _max_padding = _dot->getMaxPacketLength()-PACKETSIZE; + _Sw2 = "Power"; + _Sw1 = intToString(_power); + _help.display(); + osDelay(2000); + if(_band==mDot::FB_868){ + _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate); + _state = PARAMETERS; + } + else { _state = BAND_CHANGE; + changeBand(); + } + _send_timer.start(); +} + +void ModeSemtech::drIncrement() +{ + _data_rate++; + if (_data_rate > mDot::DR5) { + _drAll = true; + _data_rate=0; + } + _dot->setTxDataRate(_data_rate); + logInfo("new data rate %s, POWER %lu", mDot::DataRateStr(_data_rate).c_str(), _power); + _max_padding = _dot->getMaxPacketLength()-PACKETSIZE; +} + +void ModeSemtech::changeDataRate() +{ + if(_drAll) { + if(_band == mDot::FB_868) _data_rate = -1; + else _data_rate = mDot::DR1; + _drAll = false; + } + drIncrement(); +} + +void ModeSemtech::changeParameter() +{ + _parameter++; + if(_band==mDot::FB_868&&_parameter==FSB)_parameter++; + if(_parameter>INTERVAL)_parameter=0; + switch(_parameter) { + case DATA_RATE: + _Sw2 = "Data Rate"; + _Sw1 = intToString(_data_rate); + if(_drAll)_Sw1 = "All"; + break; + case FSB: + _Sw2 = "FSB"; + _Sw1 = intToString(_sub_band); + break; + case PADDING: + _Sw2 = "Padding"; + _Sw1 = intToString(_padding); + break; + case POWER: + _Sw2 = "Power"; + _Sw1 = intToString(_power); + break; + case INTERVAL: + _Sw2 = "Interval"; + _Sw1 = intToString(_interval); + break; + default: + break; + } +} + +void ModeSemtech::editParameter() +{ + switch(_parameter) { + case POWER: + if(_power<20)_power+=3; + else _power = 2; + _Sw1 = intToString(_power); + _dot->setTxPower(_power); + break; + + case DATA_RATE: + changeDataRate(); + _Sw1 = intToString(_data_rate); + if(_drAll)_Sw1="All"; + break; + + case FSB: + _send_timer.stop(); + _send_timer.reset(); + _state = BAND_CHANGE; + _dot->resetNetworkSession(); + _lora->resetActivityLed(); + changeBand(); + break; + + case PADDING: + if(_padding<_max_padding)_padding +=10 - (_padding%10); + else _padding = 0; + if(_padding>_max_padding)_padding = _max_padding; + _Sw1 = intToString(_padding); + break; + + default: + if(_interval<60)_interval += 5; + else _interval = 5; + _Sw1 = intToString(_interval); + break; + } +} + +void ModeSemtech::formatData() +{ + _send_data.clear(); + uint32_t lat = 0; + uint32_t lng = 0; + _temp_C+=0.5; + + if(_GPS) { + if(_latitude.degrees<0) lat = ~(int)((_latitude.degrees - ((double)_latitude.minutes/60.0) - ((double)_latitude.seconds/600000.0))*((double)-TWO_TO_THE_THIRTY_ONE_MINUS_ONE/90.0)+1.5); + else lat = (int)((_latitude.degrees + ((double)_latitude.minutes/60.0) + ((double)_latitude.seconds/600000.0))*((double)TWO_TO_THE_THIRTY_ONE_MINUS_ONE/90.0)+0.5); + if(_longitude.degrees<0) lng = ~(int)((_longitude.degrees - ((double)_longitude.minutes/60.0) - ((double)_longitude.seconds/600000.0))*((double)-TWO_TO_THE_THIRTY_ONE_MINUS_ONE/180.0)+1.5); + else lng = (int)((_longitude.degrees + ((double)_longitude.minutes/60.0) + ((double)_longitude.seconds/600000.0))*((double)TWO_TO_THE_THIRTY_ONE_MINUS_ONE/180.0)+0.5); + } + _send_data.push_back(0); + _send_data.push_back((int8_t) _temp_C); + _send_data.push_back(0); + for(int i=24; i>=0; i-=8)_send_data.push_back((lat>>i)&0xFF); + for(int i=24; i>=0; i-=8)_send_data.push_back((lng>>i)&0xFF); + for(int i=0; i<(_padding>_max_padding ? _max_padding : _padding); i++) _send_data.push_back(0); +} + +void ModeSemtech::setBand() +{ + _sub_band++; + if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL; + _dot->setFrequencySubBand(_sub_band); +} + +void ModeSemtech::changeBand() +{ + _sem_join.display(); + _sem_join.updatePower(_power); + _sem_join.updateFsb(_sub_band); + _sem_join.updateId(_dot->getNetworkName()); + _sem_join.updateRate(intToString(_data_rate)); + _sem_join.updateKey(_dot->getNetworkPassphrase()); +} + +void ModeSemtech::updateScreen() +{ + _temp_C = _sensors->getTemp(SensorHandler::CELSIUS); + if(_gps->getLockStatus()&& _gps_available) { + _GPS = true; + _latitude = _gps->getLatitude(); + _longitude = _gps->getLongitude(); + _time = _gps->getTimestamp(); + } else _GPS = false; + _sem.updateStats( _GPS, _longitude, _latitude, _time, _temp_C); + _sem.updateSw1(_Sw1,_Sw2,_data_rate,_power,_padding); + _sem.updateSw2(_Sw2); +} + +void ModeSemtech::send() +{ + _state = SENDING; + _send_timer.stop(); + if(_band==mDot::FB_868) { + while(_dot->getNextTxMs()>0) { + _sem.updateNextCh((int)(_dot->getNextTxMs()/1000)); + osDelay(250); + } + } + formatData(); + _sem.sending(); + _send_timer.reset(); + _send_timer.start(); + _lora->send(_send_data); + osDelay(500); +} + +bool ModeSemtech::start() +{ + init(); + _button_timer.start(); + ButtonHandler::ButtonEvent be; + osSignalClear(_main_id, buttonSignal | loraSignal); + if(_band==mDot::FB_915)_join = new ModeJoin(_lcd, _buttons, _dot, _lora, _gps, _sensors); + + while (true) { + if(_state==PARAMETERS)updateScreen(); + + osEvent e = Thread::signal_wait(0, 250); + if (e.status == osEventSignal) { + if (e.value.signals & buttonSignal) { + _button_timer.reset(); + be = _buttons->getButtonEvent(); + + switch(be) { + case ButtonHandler::sw1_press: + switch(_state) { + case BAND_CHANGE: + setBand(); + changeBand(); + break; + + case SENDING: + break; + + case PARAMETERS: + editParameter(); + break; + } + break; + case ButtonHandler::sw2_press: + switch(_state) { + case BAND_CHANGE: + if(_join->start()){ + _state = PARAMETERS; + _send_timer.start(); + _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, DATA_RATE); + _dot->setTxDataRate(_data_rate); + } else changeBand(); + break; + + case SENDING: + break; + + case PARAMETERS: + changeParameter(); + break; + } + break; + case ButtonHandler::sw1_hold: + _send_timer.stop(); + _send_timer.reset(); + return true; + + default: + break; + } + + } + } + if (e.value.signals & loraSignal) { + _ls = _lora->getStatus(); + switch (_ls) { + + case LoRaHandler::send_success: + _sem.sendResult("Send Sucess!"); + _link_check = true; + _snr = _dot->getSnrStats(); + _rssi = _dot->getRssiStats(); + osDelay(500); + _button_timer.reset(); + _state = PARAMETERS; + _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate); + if(_drAll)drIncrement(); + break; + + case LoRaHandler::send_failure: + _sem.sendResult("Send Failed."); + _link_check = false; + osDelay(500); + _button_timer.reset(); + _state = PARAMETERS; + _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate); + if(_drAll)drIncrement(); + break; + + default: + break; + } + + } + + if(_send_timer.read_ms()>_interval*1000&&_button_timer.read_ms()>3000) send(); + + } +} + + -- cgit v1.2.3 From ea479ea809810ff02488cbcb1cd2ce5f56b8f95a Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Fri, 29 Jul 2016 09:35:20 -0500 Subject: Replace ModeSemtech.cpp --- Mode/ModeSemtech.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp index e6ae52b..2cbd5fc 100644 --- a/Mode/ModeSemtech.cpp +++ b/Mode/ModeSemtech.cpp @@ -60,12 +60,13 @@ void ModeSemtech::init() osDelay(2000); if(_band==mDot::FB_868){ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate); + _sem.initial(); _state = PARAMETERS; + _send_timer.start(); } else { _state = BAND_CHANGE; changeBand(); } - _send_timer.start(); } void ModeSemtech::drIncrement() -- cgit v1.2.3 From 768951bf1beb7a368b1a94b71a95c832d1f2fcc6 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Mon, 8 Aug 2016 08:56:50 -0500 Subject: update mdot-library --- mdot-library | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdot-library b/mdot-library index dad8ecc..6381399 160000 --- a/mdot-library +++ b/mdot-library @@ -1 +1 @@ -Subproject commit dad8ecc852ff6cbc3af9836e2931676e6194d25c +Subproject commit 638139926b7918f5cf34e7bf9ef7b169a4e929cd -- cgit v1.2.3 From e80da86edcd65ab6925cf2e1ab9f579146da2637 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:47:07 -0500 Subject: Replace LayoutSemtechJoin.cpp --- Layout/LayoutSemtechJoin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Layout/LayoutSemtechJoin.cpp b/Layout/LayoutSemtechJoin.cpp index f7dbf80..7bb7ac0 100644 --- a/Layout/LayoutSemtechJoin.cpp +++ b/Layout/LayoutSemtechJoin.cpp @@ -20,6 +20,7 @@ LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band) : Layout(lcd), + _band(band), _lId(0, 1, "NI="), _lKey(0, 2, "NK="), _lFsb(0, 3, "FSB="), @@ -27,13 +28,12 @@ LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band) _lPower(6, 5, "P="), _lJoin(0, 7, "Join"), _fId(3, 1, 14), - _fFsb(4, 3, 2), _fKey(3, 2, 14), + _fFsb(4, 3, 2), _fRate(3, 5, 2), _fPower(8, 5, 2), - _fSubBand(16,7,1), _fStatus(0, 0, 17), - _band(band) + _fSubBand(16,7,1) {} LayoutSemtechJoin::~LayoutSemtechJoin() {} -- cgit v1.2.3 From 7be7e57c6f5067fc33f11d9823b6702590704682 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:48:31 -0500 Subject: Replace LayoutSemtech.cpp --- Layout/LayoutSemtech.cpp | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp index dcaf2ad..e31d149 100644 --- a/Layout/LayoutSemtech.cpp +++ b/Layout/LayoutSemtech.cpp @@ -21,36 +21,42 @@ LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) : Layout(lcd), + _band(band), _lDr(8,0,"DR"), _lFSB(0,0,"FSB"), - _lPower(13,0,"P"), - _lTemp(8,6,"Temp "), - _lPadding(0,6,"Pad"), _lSend(3,3,"Sending..."), + _lTemp(8,6,"Temp "), _lNoGps(0,4,"No Gps Lock"), - _lNoLink(0,2,"No Link Data"), + _lPower(13,0,"P"), + _lBlank(0,1," "), + _lNoLink(0,1,"Send Failed"), + _lPadding(0,6,"Pad"), _lNoChannel(0,3,"No Free Channel"), - _fFSB(3,0,1), _fDr(10,0,2), - _fSw2(0,7,9), _fSw1(13,7,4), + _fSw2(0,7,9), + _fFSB(3,0,1), _fTemp(13,6,4), _fPower(14,0,2), _fNextCh(0,5,17), _fGpsLat(0,3,17), _fGpsLon(0,4,17), _fResult(3,3,16), - _fPadding(4,6,3), - _fDownSnr(12,2,5), _fGpsTime(0,5,16), - _fDownRssi(0,2,11), - _band(band) + _fDownSnr(12,2,5), + _fPadding(4,6,3), + _fDownRssi(0,2,11) {} LayoutSemtech::~LayoutSemtech() {} void LayoutSemtech::display() {} +void LayoutSemtech::initial() +{ + writeLabel(_lBlank); +} + void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) { char buf[17]; @@ -191,3 +197,4 @@ void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::l endUpdate(); } + -- cgit v1.2.3 From 93e044d9d55af4cdf4f9f75c12129a8d318fcfa1 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:49:05 -0500 Subject: Replace LayoutSemtechJoin.h --- Layout/LayoutSemtechJoin.h | 106 +++++++++++++++++++++++++++------------------ 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h index 09ae474..dd62fd6 100644 --- a/Layout/LayoutSemtechJoin.h +++ b/Layout/LayoutSemtechJoin.h @@ -1,58 +1,78 @@ /* Copyright (c) <2016> , MIT License * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or + * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef __LAYOUTSEMTECHJOIN_H__ -#define __LAYOUTSEMTECHJOIN_H__ +#ifndef __LAYOUTSEMTECH_H__ +#define __LAYOUTSEMTECH_H__ #include "Layout.h" -#include "mDot.h" - -class LayoutSemtechJoin : public Layout { - public: - LayoutSemtechJoin(DOGS102* lcd, uint8_t band); - ~LayoutSemtechJoin(); - - void display(); - - void updateId(std::string id); - void updateKey(std::string key); - void updateFsb(uint8_t band); - void updateRate(std::string rate); - void updatePower(uint32_t power); - - private: - uint8_t _band; - - Label _lId; - Label _lKey; - Label _lFsb; - Label _lRate; - Label _lJoin; - Label _lPower; - - Field _fId; - Field _fKey; - Field _fFsb; - Field _fRate; - Field _fPower; - Field _fStatus; - Field _fSubBand; +#include "GPSPARSER.h" +#include "LoRaHandler.h" + +class LayoutSemtech : public Layout +{ +public: + LayoutSemtech(DOGS102* lcd, uint8_t band); + ~LayoutSemtech(); + + void display(); + void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr); + + void sending(); + void initial(); + void updateSw2(string str); + void sendResult(string str); + void updateNextCh(int count_down); + void updateSw1(string Sw1, string Sw2, int dr, int power, int padding); + void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp); + +private: + uint8_t _band; + + Label _lDr; + Label _lFSB; + Label _lSend; + Label _lTemp; + Label _lNoGps; + Label _lPower; + Label _lBlank; + Label _lNoLink; + Label _lPadding; + Label _lNoChannel; + + Field _fDr; + Field _fSw1; + Field _fSw2; + Field _fFSB; + Field _fTemp; + Field _fPower; + Field _fNextCh; + Field _fGpsLat; + Field _fGpsLon; + Field _fResult; + Field _fGpsTime; + Field _fDownSnr; + Field _fPadding; + Field _fDownRssi; }; #endif + + + + -- cgit v1.2.3 From 6ef3714eaa2095dfd2b7bf111157ef0362cf0e64 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:49:34 -0500 Subject: Replace LayoutSemtechJoin.h --- Layout/LayoutSemtechJoin.h | 105 +++++++++++++++++++-------------------------- 1 file changed, 43 insertions(+), 62 deletions(-) diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h index dd62fd6..f848334 100644 --- a/Layout/LayoutSemtechJoin.h +++ b/Layout/LayoutSemtechJoin.h @@ -1,78 +1,59 @@ /* Copyright (c) <2016> , MIT License * - * Permission is hereby granted, free of charge, to any person obtaining a copy of this software - * and associated documentation files (the "Software"), to deal in the Software without restriction, - * including without limitation the rights to use, copy, modify, merge, publish, distribute, - * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software + * and associated documentation files (the "Software"), to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, publish, distribute, + * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or + * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING - * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING + * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef __LAYOUTSEMTECH_H__ -#define __LAYOUTSEMTECH_H__ +#ifndef __LAYOUTSEMTECHJOIN_H__ +#define __LAYOUTSEMTECHJOIN_H__ #include "Layout.h" -#include "GPSPARSER.h" -#include "LoRaHandler.h" - -class LayoutSemtech : public Layout -{ -public: - LayoutSemtech(DOGS102* lcd, uint8_t band); - ~LayoutSemtech(); - - void display(); - void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr); - - void sending(); - void initial(); - void updateSw2(string str); - void sendResult(string str); - void updateNextCh(int count_down); - void updateSw1(string Sw1, string Sw2, int dr, int power, int padding); - void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp); - -private: - uint8_t _band; - - Label _lDr; - Label _lFSB; - Label _lSend; - Label _lTemp; - Label _lNoGps; - Label _lPower; - Label _lBlank; - Label _lNoLink; - Label _lPadding; - Label _lNoChannel; - - Field _fDr; - Field _fSw1; - Field _fSw2; - Field _fFSB; - Field _fTemp; - Field _fPower; - Field _fNextCh; - Field _fGpsLat; - Field _fGpsLon; - Field _fResult; - Field _fGpsTime; - Field _fDownSnr; - Field _fPadding; - Field _fDownRssi; +#include "mDot.h" + +class LayoutSemtechJoin : public Layout { + public: + LayoutSemtechJoin(DOGS102* lcd, uint8_t band); + ~LayoutSemtechJoin(); + + void display(); + + void updateId(std::string id); + void updateKey(std::string key); + void updateFsb(uint8_t band); + void updateRate(std::string rate); + void updatePower(uint32_t power); + + private: + uint8_t _band; + + Label _lId; + Label _lKey; + Label _lFsb; + Label _lRate; + Label _lPower; + Label _lJoin; + + Field _fId; + Field _fKey; + Field _fFsb; + Field _fRate; + Field _fPower; + Field _fStatus; + Field _fSubBand; }; #endif - - - -- cgit v1.2.3 From 3b8fe55decbeee5d916db47b9d299895f032c892 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:50:11 -0500 Subject: Replace LayoutSemtech.h --- Layout/LayoutSemtech.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h index 374c1ff..dd62fd6 100644 --- a/Layout/LayoutSemtech.h +++ b/Layout/LayoutSemtech.h @@ -33,6 +33,7 @@ public: void display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi,int power, int fsb, int padding, int dr); void sending(); + void initial(); void updateSw2(string str); void sendResult(string str); void updateNextCh(int count_down); @@ -48,6 +49,7 @@ private: Label _lTemp; Label _lNoGps; Label _lPower; + Label _lBlank; Label _lNoLink; Label _lPadding; Label _lNoChannel; @@ -73,3 +75,4 @@ private: + -- cgit v1.2.3 From 60f83dec0efc57cd61e94f78aa0b2503d5d7cd68 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:50:39 -0500 Subject: Replace ModeSemtech.cpp --- Mode/ModeSemtech.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp index 2cbd5fc..9de48ad 100644 --- a/Mode/ModeSemtech.cpp +++ b/Mode/ModeSemtech.cpp @@ -30,8 +30,8 @@ ModeSemtech::ModeSemtech(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors) : Mode(lcd, buttons, dot, lora, gps, sensors), - _sem(lcd,_band), _help(lcd), + _sem(lcd,_band), _sem_join(lcd,_band) {} @@ -334,3 +334,4 @@ bool ModeSemtech::start() } + -- cgit v1.2.3 From c8405492c3e606560d98f64b7907fa85f7174975 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 09:50:58 -0500 Subject: Replace ModeSemtech.h --- Mode/ModeSemtech.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mode/ModeSemtech.h b/Mode/ModeSemtech.h index 11a3de8..4812ec4 100644 --- a/Mode/ModeSemtech.h +++ b/Mode/ModeSemtech.h @@ -47,8 +47,7 @@ private: float _temp_C; std::vector _send_data; - uint8_t _parameter, _padding, _interval, - _max_padding, _band; + uint8_t _parameter, _padding, _interval,_max_padding, _band; bool _drAll, _link_check, _GPS; string _Sw1, _Sw2; -- cgit v1.2.3 From 54270b95f3fe169948ef551c49204defcda4033b Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 10:11:08 -0500 Subject: Replace main.cpp --- main.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/main.cpp b/main.cpp index 9166354..48b3552 100644 --- a/main.cpp +++ b/main.cpp @@ -41,6 +41,7 @@ #include "ModeSweep.h" #include "ModeDemo.h" #include "ModeConfig.h" +#include "ModeSemtech.h" // misc heders #include "FileName.h" #include @@ -76,6 +77,7 @@ ModeSingle* modeSingle; ModeSweep* modeSweep; ModeDemo* modeDemo; ModeConfig* modeConfig; +ModeSemtech* modeSemtech; // Serial debug port Serial debug(USBTX, USBRX); @@ -111,6 +113,7 @@ int main() { modeSweep = new ModeSweep(lcd, buttons, dot, lora, gps, sensors); modeDemo = new ModeDemo(lcd, buttons, dot, lora, gps, sensors); modeConfig = new ModeConfig(lcd, buttons, dot, lora, gps, sensors); + modeSemtech = new ModeSemtech(lcd, buttons, dot, lora, gps, sensors); osDelay(1000); logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no "); @@ -136,7 +139,8 @@ void mainMenu() { demo = 1, config, single, - sweep + sweep, + semtech } menu_items; std::string menu_strings[] = { @@ -144,7 +148,8 @@ void mainMenu() { "LoRa Demo", "Configuration", "Survey Single", - "Survey Sweep" + "Survey Sweep", + "Semtech" }; std::vector items; @@ -152,6 +157,7 @@ void mainMenu() { items.push_back(menu_strings[config]); items.push_back(menu_strings[single]); items.push_back(menu_strings[sweep]); + items.push_back(menu_strings[semtech]); while (true) { product = "MTDOT-BOX/EVB "; @@ -195,8 +201,14 @@ void mainMenu() { if (modeJoin->start()) modeSweep->start(); } + else if (selected == menu_strings[semtech]) { + if(dot->getFrequencyBand()==mDot::FB_868)modeJoin->start(); + modeSemtech->start(); + } mode_selected = false; } } + + -- cgit v1.2.3 From 173c34ce2472d33c957457de125a56a83ff11aa1 Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Wed, 14 Sep 2016 11:02:01 -0500 Subject: Submodule mdot-library 6381399..aefe95e: > * MTS-Lora 72d841c...ad44a4d (1): > * vendor/multitech/MTS-Utils ed7f7ea...348ee04 (1): > MTSText.cpp: fix premature deletion of buffer > don't use non-const size in array declarations > Submodule MTS-Lora 800a286..72d841c: > Merge branch 'master' of gitlab.multitech.net:lora-mote/MTS-Lora > Mac: do not reject packet address of 0x0 outright. Only if it does not match the assigned address. > * MTS-Lora e6086f8...800a286 (3): > don't use non-const value for size of array > MacEvents::MissedAck needs to be a pure virtual > * vendor/multitech/MTS-Utils 383d4cb...ed7f7ea (1): > don't declare array with non-const size - ARMCC errors out because of this > * MTS-Lora c978074...e6086f8 (1): > MockMacEventstests: Add MissedAck > Submodule MTS-Lora b1ee18b..c978074: > SxRadio: rearrange DIO defines to allow no software changes needed between xDot REV D and REV E > Revert "add #include of so applications built with static library build compile successfully" > Merge branch 'master' of gitlab.multitech.net:/lora-mote/mdot-library > add #include of so applications built with static library build compile successfully > add nvmRead/Write functions to mDot API to expose 6kB of EEPROM for customer use > move xDot EEPROM defines to LoRaConfig.h so mDot code can use them > remove idle thread > * MTS-Lora a789e27...7e9a42d (1): > adjust radio thread stack size to 2.5kB, pass RxBuffer to event layer instead of creating new buffer > * MTS-Lora 808526a...a789e27 (1): > add dedicated 3kB stack for radio thread - mbed 5.1 default stack size is too small > LinkCheck: reset check fail count on join or if check answer was received. > mDot: set default redundancy setting from config > Submodule MTS-Lora 1fdb442..808526a: > Link: use radio thread for resending and signal timer event from ISR > Merge branch 'master' of gitlab.multitech.net:lora-mote/mdot-library > mDot: fix missed acks for stats tracking > Submodule MTS-Lora 86d69d1..1fdb442: > Merge branch 'master' of gitlab.multitech.net:lora-mote/MTS-Lora > Mac: return error if packet has mac commands in opts and payload > Lora: reset stats in mac and link > Lora: update stats tracking for join fails and missed acks > mDot: Set P2P settings for AU915 to match US915, check AU DR according to LoRaWAN 1.0.1 > Submodule MTS-Lora 15942b2..86d69d1: > Mac: Send Continuous stay in CW mode until reset, per Marcus Glass > Submodule MTS-Lora b748288..15942b2: > ChannelPlan: ADR ACK reduce DR after deach ADR ACK DELAY > ChannelPlan: JoinBackoff update time_off_max after calculating the rand_time_off > Merge branch 'xdot-l151' > Submodule MTS-Lora 77bd63b..29b3148: > ChannelPlan: join backoff max should use uint3 > Submodule MTS-Lora 2466891..77bd63b: > ChannelPlan: consolidate the join backoff algorithm and update EU868 tests > ChannelPlan: add join back off testing. > ChannelPlan: include join time off air in time off air calculation. > Mac: move CalculateJoinBackoff into channel plan, set channel group after successful join > ChannelPlan: update EU868 calibrated power > Merge branch 'master' of gitlab.multitech.net:lora-mote/MTS-Lora > ChannelPlan: calculate join backoff US915 use exponential backoff from 15 seconds - 1 hour backoff after attempting join on each channel group at 125 and 500 kHz > Submodule MTS-Lora c7fe886..2466891: > Mac: compare time-off-air with join backoff time and return the greatest > mDot: log mDot ready as INFO > LoRaConfig: Default joindelay according to PublicNetwork setting > Merge branch 'master' of gitlab.multitech.net:lora-mote/mdot-library > mDot: log test mode messages as warnings > mDot: update header comments > update change.log --- mdot-library | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdot-library b/mdot-library index 6381399..aefe95e 160000 --- a/mdot-library +++ b/mdot-library @@ -1 +1 @@ -Subproject commit 638139926b7918f5cf34e7bf9ef7b169a4e929cd +Subproject commit aefe95ecaeb883397106170e9f99cea5035c1894 -- cgit v1.2.3 From 692b74778f6b95cf0c668dfdb85f39035e113baa Mon Sep 17 00:00:00 2001 From: Jason Reiss Date: Wed, 14 Sep 2016 11:02:19 -0500 Subject: Add AT+TXF and AT+SENDC debug commands --- CommandTerminal/CmdSendContinuous.cpp | 13 +++++++++++++ CommandTerminal/CmdSendContinuous.h | 18 ++++++++++++++++++ CommandTerminal/CmdTxFrequency.cpp | 26 ++++++++++++++++++++++++++ CommandTerminal/CmdTxFrequency.h | 20 ++++++++++++++++++++ CommandTerminal/CmdWriteProtectedConfig.cpp | 4 ++++ CommandTerminal/CmdWriteProtectedConfig.h | 1 + CommandTerminal/Commands.h | 2 ++ Mode/ModeConfig.cpp | 2 ++ 8 files changed, 86 insertions(+) create mode 100644 CommandTerminal/CmdSendContinuous.cpp create mode 100644 CommandTerminal/CmdSendContinuous.h create mode 100644 CommandTerminal/CmdTxFrequency.cpp create mode 100644 CommandTerminal/CmdTxFrequency.h diff --git a/CommandTerminal/CmdSendContinuous.cpp b/CommandTerminal/CmdSendContinuous.cpp new file mode 100644 index 0000000..843d5bf --- /dev/null +++ b/CommandTerminal/CmdSendContinuous.cpp @@ -0,0 +1,13 @@ +#include "CmdSendContinuous.h" + +CmdSendContinuous::CmdSendContinuous(mDot* dot) +: Command(dot, "Send Continuous", "AT+SENDC", "Send un-modulated data continuously") { +} + +uint32_t CmdSendContinuous::action(std::vector args) { + + _dot->sendContinuous(true); + + return 0; +} + diff --git a/CommandTerminal/CmdSendContinuous.h b/CommandTerminal/CmdSendContinuous.h new file mode 100644 index 0000000..403ab54 --- /dev/null +++ b/CommandTerminal/CmdSendContinuous.h @@ -0,0 +1,18 @@ + +#ifndef __CMDSENDCONTINUOUS_H__ +#define __CMDSENDCONTINUOUS_H__ + +#include "Command.h" + +class CmdSendContinuous : public Command { + +public: + + CmdSendContinuous(mDot* dot); + uint32_t action(std::vector args); + +private: + +}; + +#endif // __CMDSENDCONTINUOUS_H__ diff --git a/CommandTerminal/CmdTxFrequency.cpp b/CommandTerminal/CmdTxFrequency.cpp new file mode 100644 index 0000000..35e7f8d --- /dev/null +++ b/CommandTerminal/CmdTxFrequency.cpp @@ -0,0 +1,26 @@ +#include "CmdTxFrequency.h" +#include + + +CmdTxFrequency::CmdTxFrequency(mDot* dot) : + Command(dot, "Tx Frequency", "AT+TXF", "Set Tx frequency") { +} + +uint32_t CmdTxFrequency::action(std::vector args) +{ + if (args.size() == 2) + { + int frequency = 0; + + sscanf(args[1].c_str(), "%d", &frequency); + _dot->setTxFrequency(frequency); + } + + return 0; +} + +bool CmdTxFrequency::verify(std::vector args) +{ + return true; +} + diff --git a/CommandTerminal/CmdTxFrequency.h b/CommandTerminal/CmdTxFrequency.h new file mode 100644 index 0000000..22eb777 --- /dev/null +++ b/CommandTerminal/CmdTxFrequency.h @@ -0,0 +1,20 @@ +#ifndef __CMDTXFREQUENCY_H__ +#define __CMDTXFREQUENCY_H__ + +#include "Command.h" + +class CommandTerminal; + +class CmdTxFrequency : public Command { + +public: + + CmdTxFrequency(mDot* dot); + uint32_t action(std::vector args); + bool verify(std::vector args); + +private: + +}; + +#endif // __CMDTXFREQUENCY_H__ diff --git a/CommandTerminal/CmdWriteProtectedConfig.cpp b/CommandTerminal/CmdWriteProtectedConfig.cpp index 6c2d6ce..db22562 100644 --- a/CommandTerminal/CmdWriteProtectedConfig.cpp +++ b/CommandTerminal/CmdWriteProtectedConfig.cpp @@ -24,6 +24,10 @@ CmdWriteProtectedConfig::CmdWriteProtectedConfig(mDot* dot) : _help = std::string(text()) + ": " + std::string(desc()); } +CmdWriteProtectedConfig::~CmdWriteProtectedConfig() { + +} + uint32_t CmdWriteProtectedConfig::action(std::vector args) { if (!_dot->saveProtectedConfig()) { diff --git a/CommandTerminal/CmdWriteProtectedConfig.h b/CommandTerminal/CmdWriteProtectedConfig.h index e5ad3c7..51315fe 100644 --- a/CommandTerminal/CmdWriteProtectedConfig.h +++ b/CommandTerminal/CmdWriteProtectedConfig.h @@ -27,6 +27,7 @@ class CmdWriteProtectedConfig : public Command { public: CmdWriteProtectedConfig(mDot* dot); + virtual ~CmdWriteProtectedConfig(); virtual uint32_t action(std::vector args); private: diff --git a/CommandTerminal/Commands.h b/CommandTerminal/Commands.h index 9a06835..b041b19 100644 --- a/CommandTerminal/Commands.h +++ b/CommandTerminal/Commands.h @@ -49,4 +49,6 @@ #ifdef MTS_RADIO_DEBUG_COMMANDS #include "CmdWriteProtectedConfig.h" +#include "CmdSendContinuous.h" +#include "CmdTxFrequency.h" #endif diff --git a/Mode/ModeConfig.cpp b/Mode/ModeConfig.cpp index 56ba1a0..bd1967d 100644 --- a/Mode/ModeConfig.cpp +++ b/Mode/ModeConfig.cpp @@ -75,6 +75,8 @@ ModeConfig::ModeConfig(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHand #if MTS_RADIO_DEBUG_COMMANDS addCommand(new CmdWriteProtectedConfig(_dot)); + addCommand(new CmdSendContinuous(_dot)); + addCommand(new CmdTxFrequency(_dot)); #endif } -- cgit v1.2.3