From 09a46d7b25c72cae37a1674f0e3797e4ed0b69b4 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:11:22 -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 3379952cfbeebd5b9839309251916490c3b79c60 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:11:56 -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..7bb7ac0 --- /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), + _band(band), + _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), + _fKey(3, 2, 14), + _fFsb(4, 3, 2), + _fRate(3, 5, 2), + _fPower(8, 5, 2), + _fStatus(0, 0, 17), + _fSubBand(16,7,1) +{} + +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 394d7e57aa6e55002e8a11593a0ef1cb05cf38bc Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:12:22 -0500 Subject: Upload new file --- Layout/LayoutSemtech.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 Layout/LayoutSemtech.cpp diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp new file mode 100644 index 0000000..e31d149 --- /dev/null +++ b/Layout/LayoutSemtech.cpp @@ -0,0 +1,200 @@ +/* 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), + _band(band), + _lDr(8,0,"DR"), + _lFSB(0,0,"FSB"), + _lSend(3,3,"Sending..."), + _lTemp(8,6,"Temp "), + _lNoGps(0,4,"No Gps Lock"), + _lPower(13,0,"P"), + _lBlank(0,1," "), + _lNoLink(0,1,"Send Failed"), + _lPadding(0,6,"Pad"), + _lNoChannel(0,3,"No Free Channel"), + _fDr(10,0,2), + _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), + _fGpsTime(0,5,16), + _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]; + 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 be189276b0072a2615c29b5601c7154a517ef0a1 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:12:46 -0500 Subject: Upload new file --- Layout/LayoutSemtechJoin.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Layout/LayoutSemtechJoin.h diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h new file mode 100644 index 0000000..f848334 --- /dev/null +++ b/Layout/LayoutSemtechJoin.h @@ -0,0 +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 + * 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 _lPower; + Label _lJoin; + + Field _fId; + Field _fKey; + Field _fFsb; + Field _fRate; + Field _fPower; + Field _fStatus; + Field _fSubBand; +}; + +#endif + + -- cgit v1.2.3 From cdf950eaa909e60002f5e36b557bc23d004d2980 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:12:57 -0500 Subject: Upload new file --- Layout/LayoutSemtech.h | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Layout/LayoutSemtech.h diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h new file mode 100644 index 0000000..dd62fd6 --- /dev/null +++ b/Layout/LayoutSemtech.h @@ -0,0 +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 + * 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 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 6950c636f422c6d6d8bc21c2706b5d6e8ed69229 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:13:39 -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 c99c440cffd890ef0a02821b6996881f7ed4b854 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:14:01 -0500 Subject: Upload new file --- Mode/ModeSemtech.cpp | 337 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 337 insertions(+) create mode 100644 Mode/ModeSemtech.cpp diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp new file mode 100644 index 0000000..9de48ad --- /dev/null +++ b/Mode/ModeSemtech.cpp @@ -0,0 +1,337 @@ +/* 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), + _help(lcd), + _sem(lcd,_band), + _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); + _sem.initial(); + _state = PARAMETERS; + _send_timer.start(); + } + else { _state = BAND_CHANGE; + changeBand(); + } +} + +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 7902e991d5dd74415d5727c45fff31fcc1d37ea0 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:14:16 -0500 Subject: Upload new file --- Mode/ModeSemtech.h | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 Mode/ModeSemtech.h diff --git a/Mode/ModeSemtech.h b/Mode/ModeSemtech.h new file mode 100644 index 0000000..4812ec4 --- /dev/null +++ b/Mode/ModeSemtech.h @@ -0,0 +1,76 @@ +/* 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 310351160a0272d81f92e88f2385608ff6757edd Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:55:17 -0500 Subject: Update LayoutSemtech.h --- Layout/LayoutSemtech.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h index dd62fd6..5e410da 100644 --- a/Layout/LayoutSemtech.h +++ b/Layout/LayoutSemtech.h @@ -54,7 +54,7 @@ private: Label _lPadding; Label _lNoChannel; - Field _fDr; + Field _fDR; Field _fSw1; Field _fSw2; Field _fFSB; -- cgit v1.2.3 From 756000039cfe827a03a700b95d2fd58a9d73239a Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Mon, 8 Aug 2016 12:55:42 -0500 Subject: Update LayoutSemtech.cpp --- Layout/LayoutSemtech.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp index e31d149..f5eb3f2 100644 --- a/Layout/LayoutSemtech.cpp +++ b/Layout/LayoutSemtech.cpp @@ -22,7 +22,7 @@ LayoutSemtech::LayoutSemtech(DOGS102* lcd, uint8_t band) : Layout(lcd), _band(band), - _lDr(8,0,"DR"), + _lDR(8,0,"DR"), _lFSB(0,0,"FSB"), _lSend(3,3,"Sending..."), _lTemp(8,6,"Temp "), -- cgit v1.2.3 From 67bfcb079d5ecdd74a17d88831a7cdbb9de0651d Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:55:38 -0500 Subject: Replace main.cpp --- main.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/main.cpp b/main.cpp index 48b3552..fa91319 100644 --- a/main.cpp +++ b/main.cpp @@ -41,7 +41,7 @@ #include "ModeSweep.h" #include "ModeDemo.h" #include "ModeConfig.h" -#include "ModeSemtech.h" +#include "ModeGps.h" // misc heders #include "FileName.h" #include @@ -77,7 +77,7 @@ ModeSingle* modeSingle; ModeSweep* modeSweep; ModeDemo* modeDemo; ModeConfig* modeConfig; -ModeSemtech* modeSemtech; +ModeGps* modeGps; // Serial debug port Serial debug(USBTX, USBRX); @@ -113,7 +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); + modeGps = new ModeGps(lcd, buttons, dot, lora, gps, sensors, modeJoin); osDelay(1000); logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no "); @@ -140,7 +140,7 @@ void mainMenu() { config, single, sweep, - semtech + gps } menu_items; std::string menu_strings[] = { @@ -149,15 +149,14 @@ void mainMenu() { "Configuration", "Survey Single", "Survey Sweep", - "Semtech" + "Survey Gps" }; - std::vector items; items.push_back(menu_strings[demo]); items.push_back(menu_strings[config]); items.push_back(menu_strings[single]); items.push_back(menu_strings[sweep]); - items.push_back(menu_strings[semtech]); + items.push_back(menu_strings[gps]); while (true) { product = "MTDOT-BOX/EVB "; @@ -188,7 +187,6 @@ void mainMenu() { } } } - if (selected == menu_strings[demo]) { if (modeJoin->start()) modeDemo->start(); @@ -201,14 +199,10 @@ void mainMenu() { if (modeJoin->start()) modeSweep->start(); } - else if (selected == menu_strings[semtech]) { + else if (selected == menu_strings[gps]) { if(dot->getFrequencyBand()==mDot::FB_868)modeJoin->start(); - modeSemtech->start(); + modeGps->start(); } - mode_selected = false; } -} - - - +} \ No newline at end of file -- cgit v1.2.3 From 02e9f46074cd6f1518d470199708e3b8656c39ec Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:56:05 -0500 Subject: Delete LayoutSemtechJoin.cpp --- Layout/LayoutSemtechJoin.cpp | 91 -------------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 Layout/LayoutSemtechJoin.cpp diff --git a/Layout/LayoutSemtechJoin.cpp b/Layout/LayoutSemtechJoin.cpp deleted file mode 100644 index 7bb7ac0..0000000 --- a/Layout/LayoutSemtechJoin.cpp +++ /dev/null @@ -1,91 +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 "LayoutSemtechJoin.h" - -LayoutSemtechJoin::LayoutSemtechJoin(DOGS102* lcd, uint8_t band) - : Layout(lcd), - _band(band), - _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), - _fKey(3, 2, 14), - _fFsb(4, 3, 2), - _fRate(3, 5, 2), - _fPower(8, 5, 2), - _fStatus(0, 0, 17), - _fSubBand(16,7,1) -{} - -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 83cd5f155aa3fea4ae7e1b8f86ea1fa9c2651f26 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:56:21 -0500 Subject: Delete LayoutSemtechJoin.h --- Layout/LayoutSemtechJoin.h | 59 ---------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 Layout/LayoutSemtechJoin.h diff --git a/Layout/LayoutSemtechJoin.h b/Layout/LayoutSemtechJoin.h deleted file mode 100644 index f848334..0000000 --- a/Layout/LayoutSemtechJoin.h +++ /dev/null @@ -1,59 +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. - */ - -#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 _lPower; - Label _lJoin; - - Field _fId; - Field _fKey; - Field _fFsb; - Field _fRate; - Field _fPower; - Field _fStatus; - Field _fSubBand; -}; - -#endif - - -- cgit v1.2.3 From 33e5bc104595418161d9ba6e0f2752872b88d2c8 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:56:45 -0500 Subject: Replace LayoutSemtech.cpp --- Layout/LayoutSemtech.cpp | 112 ++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 64 deletions(-) diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp index f5eb3f2..69924ea 100644 --- a/Layout/LayoutSemtech.cpp +++ b/Layout/LayoutSemtech.cpp @@ -16,150 +16,135 @@ * 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) +#include "LayoutSurveyGps.h" +LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) : Layout(lcd), _band(band), _lDR(8,0,"DR"), _lFSB(0,0,"FSB"), - _lSend(3,3,"Sending..."), _lTemp(8,6,"Temp "), - _lNoGps(0,4,"No Gps Lock"), _lPower(13,0,"P"), - _lBlank(0,1," "), - _lNoLink(0,1,"Send Failed"), _lPadding(0,6,"Pad"), - _lNoChannel(0,3,"No Free Channel"), _fDr(10,0,2), _fSw1(13,7,4), _fSw2(0,7,9), _fFSB(3,0,1), _fTemp(13,6,4), _fPower(14,0,2), - _fNextCh(0,5,17), + _fNoLink(0,1,17), _fGpsLat(0,3,17), _fGpsLon(0,4,17), - _fResult(3,3,16), - _fGpsTime(0,5,16), + _fGpsTime(0,5,17), _fDownSnr(12,2,5), _fPadding(4,6,3), _fDownRssi(0,2,11) {} -LayoutSemtech::~LayoutSemtech() {} +LayoutSurveyGps::~LayoutSurveyGps() {} -void LayoutSemtech::display() {} +void LayoutSurveyGps::display() {} -void LayoutSemtech::initial() -{ - writeLabel(_lBlank); +void LayoutSurveyGps::initial(){ + writeField(_fNoLink, string(" "), true); } -void LayoutSemtech::display(bool success, mDot::snr_stats snr, mDot::rssi_stats rssi, int power, int fsb, int padding, int dr) -{ +void LayoutSurveyGps::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(_lDR); writeLabel(_lTemp); writeLabel(_lPower); writeLabel(_lPadding); + if (_band == mDot::FB_915) { - writeLabel(_lFSB); + 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); + size = snprintf(buf, sizeof(buf), " %2.1f", snr.last / 10.0); writeField(_fDownSnr, buf, size); - } else writeLabel(_lNoLink); + } else { + writeField(_fNoLink,string("Send Failed"),true); + } memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",dr); + size = snprintf(buf, sizeof(buf), "%d", dr); writeField(_fDr, buf, size, true); memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",power); + 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", fsb); + writeField(_fFSB, buf, size, true); } memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",padding); + 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) -{ +void LayoutSurveyGps::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+=" "; + for(int i = Sw1.size(); i<4; i++){ + temp+=" "; + } temp+=Sw1; writeField(_fSw1, temp, true); startUpdate(); - if(Sw2=="Data Rate") { + + if(Sw2 == "Data Rate") { memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",dr); + size = snprintf(buf, sizeof(buf), "%d", dr); writeField(_fDr, buf, size, true); - } else if(Sw2=="Power") { + } else if(Sw2 == "Power") { memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",power); + size = snprintf(buf, sizeof(buf), "%d", power); writeField(_fPower, buf, size, true); - } else if(Sw2=="Padding") { + } else if(Sw2 == "Padding") { memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%d",padding); + size = snprintf(buf, sizeof(buf), "%d", padding); writeField(_fPadding, buf, size, true); } endUpdate(); } -void LayoutSemtech::updateSw2(string Sw2) -{ +void LayoutSurveyGps::updateSw2(string Sw2){ writeField(_fSw2, Sw2, true); } -void LayoutSemtech::sending() -{ +void LayoutSurveyGps::sending(){ clear(); - writeLabel(_lSend); + writeField(_fGpsLat,string(" Sending..."),true); } -void LayoutSemtech::sendResult(string str) -{ +void LayoutSurveyGps::sendResult(string str){ clear(); - writeField(_fResult,str,true); + writeField(_fGpsLat,str,true); } - -void LayoutSemtech::updateNextCh(int count_down) -{ +void LayoutSurveyGps::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); + size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down); + writeField(_fGpsTime, buf, size, true); + writeField(_fGpsLon, string("No Free Channel"), true); } -void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp) -{ +void LayoutSurveyGps::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp){ char buf[17]; size_t size; - startUpdate(); if(GPS) { @@ -189,12 +174,11 @@ void LayoutSemtech::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::l time.tm_year + 1900); writeField(_fGpsTime, buf, size, true); - } else writeLabel(_lNoGps); - + } else { + writeField(_fGpsLon, string("No Gps Lock"), true); + } memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%.1f",temp); + size = snprintf(buf, sizeof(buf), "%.1f", temp); writeField(_fTemp, buf, size, true); - endUpdate(); -} - +} \ No newline at end of file -- cgit v1.2.3 From c2d8d027871136c508609a11f64b0d932234d0cb Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:57:13 -0500 Subject: Delete LayoutSemtech.cpp --- Layout/LayoutSemtech.cpp | 184 ----------------------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 Layout/LayoutSemtech.cpp diff --git a/Layout/LayoutSemtech.cpp b/Layout/LayoutSemtech.cpp deleted file mode 100644 index 69924ea..0000000 --- a/Layout/LayoutSemtech.cpp +++ /dev/null @@ -1,184 +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 "LayoutSurveyGps.h" -LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) - : Layout(lcd), - _band(band), - _lDR(8,0,"DR"), - _lFSB(0,0,"FSB"), - _lTemp(8,6,"Temp "), - _lPower(13,0,"P"), - _lPadding(0,6,"Pad"), - _fDr(10,0,2), - _fSw1(13,7,4), - _fSw2(0,7,9), - _fFSB(3,0,1), - _fTemp(13,6,4), - _fPower(14,0,2), - _fNoLink(0,1,17), - _fGpsLat(0,3,17), - _fGpsLon(0,4,17), - _fGpsTime(0,5,17), - _fDownSnr(12,2,5), - _fPadding(4,6,3), - _fDownRssi(0,2,11) -{} - -LayoutSurveyGps::~LayoutSurveyGps() {} - -void LayoutSurveyGps::display() {} - -void LayoutSurveyGps::initial(){ - writeField(_fNoLink, string(" "), true); -} - -void LayoutSurveyGps::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", snr.last / 10.0); - writeField(_fDownSnr, buf, size); - } else { - writeField(_fNoLink,string("Send Failed"),true); - } - - 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 LayoutSurveyGps::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 LayoutSurveyGps::updateSw2(string Sw2){ - writeField(_fSw2, Sw2, true); -} - -void LayoutSurveyGps::sending(){ - clear(); - writeField(_fGpsLat,string(" Sending..."),true); -} - -void LayoutSurveyGps::sendResult(string str){ - clear(); - writeField(_fGpsLat,str,true); -} - -void LayoutSurveyGps::updateNextCh(int count_down){ - clear(); - size_t size; - char buf[17]; - size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down); - writeField(_fGpsTime, buf, size, true); - writeField(_fGpsLon, string("No Free Channel"), true); -} - -void LayoutSurveyGps::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 { - writeField(_fGpsLon, string("No Gps Lock"), true); - } - memset(buf, 0, sizeof(buf)); - size = snprintf(buf, sizeof(buf), "%.1f", temp); - writeField(_fTemp, buf, size, true); - endUpdate(); -} \ No newline at end of file -- cgit v1.2.3 From a29f9887ce7cb03f9ed041178d721547c531fc8c Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:57:27 -0500 Subject: Delete LayoutSemtech.h --- Layout/LayoutSemtech.h | 78 -------------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 Layout/LayoutSemtech.h diff --git a/Layout/LayoutSemtech.h b/Layout/LayoutSemtech.h deleted file mode 100644 index 5e410da..0000000 --- a/Layout/LayoutSemtech.h +++ /dev/null @@ -1,78 +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. - */ - -#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 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 be93bde25e143848ca98cb04fba7f368740ad95c Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:57:41 -0500 Subject: Upload new file --- Layout/LayoutSurveyGps.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 Layout/LayoutSurveyGps.cpp diff --git a/Layout/LayoutSurveyGps.cpp b/Layout/LayoutSurveyGps.cpp new file mode 100644 index 0000000..69924ea --- /dev/null +++ b/Layout/LayoutSurveyGps.cpp @@ -0,0 +1,184 @@ +/* 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 "LayoutSurveyGps.h" +LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) + : Layout(lcd), + _band(band), + _lDR(8,0,"DR"), + _lFSB(0,0,"FSB"), + _lTemp(8,6,"Temp "), + _lPower(13,0,"P"), + _lPadding(0,6,"Pad"), + _fDr(10,0,2), + _fSw1(13,7,4), + _fSw2(0,7,9), + _fFSB(3,0,1), + _fTemp(13,6,4), + _fPower(14,0,2), + _fNoLink(0,1,17), + _fGpsLat(0,3,17), + _fGpsLon(0,4,17), + _fGpsTime(0,5,17), + _fDownSnr(12,2,5), + _fPadding(4,6,3), + _fDownRssi(0,2,11) +{} + +LayoutSurveyGps::~LayoutSurveyGps() {} + +void LayoutSurveyGps::display() {} + +void LayoutSurveyGps::initial(){ + writeField(_fNoLink, string(" "), true); +} + +void LayoutSurveyGps::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", snr.last / 10.0); + writeField(_fDownSnr, buf, size); + } else { + writeField(_fNoLink,string("Send Failed"),true); + } + + 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 LayoutSurveyGps::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 LayoutSurveyGps::updateSw2(string Sw2){ + writeField(_fSw2, Sw2, true); +} + +void LayoutSurveyGps::sending(){ + clear(); + writeField(_fGpsLat,string(" Sending..."),true); +} + +void LayoutSurveyGps::sendResult(string str){ + clear(); + writeField(_fGpsLat,str,true); +} + +void LayoutSurveyGps::updateNextCh(int count_down){ + clear(); + size_t size; + char buf[17]; + size = snprintf(buf, sizeof(buf), "Countdown:%d", count_down); + writeField(_fGpsTime, buf, size, true); + writeField(_fGpsLon, string("No Free Channel"), true); +} + +void LayoutSurveyGps::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 { + writeField(_fGpsLon, string("No Gps Lock"), true); + } + memset(buf, 0, sizeof(buf)); + size = snprintf(buf, sizeof(buf), "%.1f", temp); + writeField(_fTemp, buf, size, true); + endUpdate(); +} \ No newline at end of file -- cgit v1.2.3 From 74d27236a23b4337e53ce0d5972d69621c827669 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:57:54 -0500 Subject: Upload new file --- Layout/LayoutSurveyGps.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 Layout/LayoutSurveyGps.h diff --git a/Layout/LayoutSurveyGps.h b/Layout/LayoutSurveyGps.h new file mode 100644 index 0000000..f24d1d4 --- /dev/null +++ b/Layout/LayoutSurveyGps.h @@ -0,0 +1,65 @@ +/* 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 __LAYOUTSURVEYGPS_H__ +#define __LAYOUTSURVEYGPS_H__ + +#include "Layout.h" +#include "GPSPARSER.h" +#include "mDot.h" + +class LayoutSurveyGps : public Layout{ +public: + LayoutSurveyGps(DOGS102* lcd, uint8_t band); + ~LayoutSurveyGps(); + + 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 _lTemp; + Label _lPower; + Label _lPadding; + + Field _fDr; + Field _fSw1; + Field _fSw2; + Field _fFSB; + Field _fTemp; + Field _fPower; + Field _fNoLink; + Field _fGpsLat; + Field _fGpsLon; + Field _fGpsTime; + Field _fDownSnr; + Field _fPadding; + Field _fDownRssi; +}; +#endif \ No newline at end of file -- cgit v1.2.3 From 8a1ee5cd8030e9bb932a9d6f7b554e6555653d9a Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:58:09 -0500 Subject: Replace LayoutJoin.cpp --- Layout/LayoutJoin.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/Layout/LayoutJoin.cpp b/Layout/LayoutJoin.cpp index e115773..687437d 100644 --- a/Layout/LayoutJoin.cpp +++ b/Layout/LayoutJoin.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) <2016> , MIT License +/* /* 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, @@ -119,3 +119,31 @@ void LayoutJoin::displayCancel(bool display) { writeField(_fCancel, str, true); } +void LayoutJoin::updateJoinFsb(uint8_t band) { + char buf[8]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%u", band); + writeField(_fFsb, buf, size, true); + size = snprintf(buf, sizeof(buf), " %u", band); + writeField(_fCancel, buf, size, true); +} + +void LayoutJoin::displayEditFsb(string rate, uint32_t power, uint8_t band, string key, string id){ + clear(); + startUpdate(); + + writeLabel(_lId); + writeLabel(_lKey); + writeLabel(_lFsb); + writeLabel(_lRate); + writeLabel(_lPower); + writeField(_fCountdown, string("Join"), true); + updateId(id); + updateKey(key); + updateJoinFsb(band); + updateRate(rate); + updatePower(power); + + endUpdate(); +} -- cgit v1.2.3 From ecc4527be1284fafeb354690ed7b5c96aef73190 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:58:25 -0500 Subject: Replace LayoutJoin.h --- Layout/LayoutJoin.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Layout/LayoutJoin.h b/Layout/LayoutJoin.h index 56cea3f..6ab9cce 100644 --- a/Layout/LayoutJoin.h +++ b/Layout/LayoutJoin.h @@ -28,10 +28,12 @@ class LayoutJoin : public Layout { ~LayoutJoin(); void display(); + void displayEditFsb(string rate, uint32_t power, uint8_t band, string key, string id); void updateId(std::string id); void updateKey(std::string key); void updateFsb(uint8_t band); + void updateJoinFsb(uint8_t band); void updateRate(std::string rate); void updatePower(uint32_t power); void updateAttempt(uint32_t attempt); @@ -59,5 +61,4 @@ class LayoutJoin : public Layout { Field _fCancel; uint8_t _band; }; - #endif -- cgit v1.2.3 From a6e79dae96ea240a6cf034aa0f05da496f8c297d Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:58:43 -0500 Subject: Delete ModeSemtech.cpp --- Mode/ModeSemtech.cpp | 337 --------------------------------------------------- 1 file changed, 337 deletions(-) delete mode 100644 Mode/ModeSemtech.cpp diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp deleted file mode 100644 index 9de48ad..0000000 --- a/Mode/ModeSemtech.cpp +++ /dev/null @@ -1,337 +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 "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), - _help(lcd), - _sem(lcd,_band), - _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); - _sem.initial(); - _state = PARAMETERS; - _send_timer.start(); - } - else { _state = BAND_CHANGE; - changeBand(); - } -} - -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 a81a682e6352a0b6ac70a59f2b3daa020c5cf2ee Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:58:53 -0500 Subject: Delete ModeSemtech.h --- Mode/ModeSemtech.h | 76 ------------------------------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 Mode/ModeSemtech.h diff --git a/Mode/ModeSemtech.h b/Mode/ModeSemtech.h deleted file mode 100644 index 4812ec4..0000000 --- a/Mode/ModeSemtech.h +++ /dev/null @@ -1,76 +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. - */ - -#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 665776e4e07ecd4f0e6fe86ee0efe829ee25e473 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:59:17 -0500 Subject: Upload new file --- Mode/ModeGps.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Mode/ModeGps.h diff --git a/Mode/ModeGps.h b/Mode/ModeGps.h new file mode 100644 index 0000000..2bbfaa1 --- /dev/null +++ b/Mode/ModeGps.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 __MODEGPS_H__ +#define __MODEGPS_H__ + +#include "Mode.h" +#include "ModeJoin.h" +#include "LayoutHelp.h" +#include "LayoutSurveyGps.h" + +class ModeGps : public Mode{ +public: + ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join); + ~ModeGps(); + bool start(); + +private: + enum {DATA_RATE, + FSB, + PADDING, + POWER, + INTERVAL + }; + enum {BAND_CHANGE, + SENDING, + PARAMETERS + }; + + LayoutHelp _help; + LayoutSurveyGps _sem; + LayoutJoin _sem_join; + + ModeJoin* _join; + + Timer _send_timer, _button_timer; + + float _temp_C; + std::vector _send_data; + uint8_t _parameter, _padding, _interval,_max_padding; + 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 drIncrement(); + void updateScreen(); + void editParameter(); + void changeDataRate(); + void changeParameter(); + string intToString(int num); +}; +#endif \ No newline at end of file -- cgit v1.2.3 From 5bf6b285fac0fbb838be77db7c722d0483156cb6 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Wed, 10 Aug 2016 12:59:38 -0500 Subject: Upload new file --- Mode/ModeGps.cpp | 359 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 Mode/ModeGps.cpp diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp new file mode 100644 index 0000000..5befcbf --- /dev/null +++ b/Mode/ModeGps.cpp @@ -0,0 +1,359 @@ +/* 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 "ModeGps.h" +#include "MTSLog.h" +#include "rtos.h" +#include "mbed.h" +#define PACKETSIZE 11 + +ModeGps::ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join) + : Mode(lcd, buttons, dot, lora, gps, sensors), + _help(lcd), + _sem(lcd, _band), + _sem_join(lcd, _band), + _join(join) +{} + +string ModeGps::intToString(int num){ + char buf[3]; + snprintf(buf, sizeof(buf), "%d", num); + return buf; +} + +void ModeGps::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); + _sem.initial(); + _state = PARAMETERS; + _send_timer.start(); + } else { _state = BAND_CHANGE; + _sem_join.displayEditFsb(intToString(10), _power, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + } +} + +void ModeGps::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 ModeGps::changeDataRate(){ + if(_drAll) { + if(_band == mDot::FB_868){ + _data_rate = -1; + } else { + _data_rate = mDot::DR1; + } + _drAll = false; + } + drIncrement(); +} + +void ModeGps::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 ModeGps::editParameter(){ + switch(_parameter) { + case POWER: + if(_power<20){ + _power+=3; + } else { + _power = 2; + } + _Sw1 = intToString(_power); + _dot->setTxPower(_power); + break; + + case DATA_RATE: + changeDataRate(); + if(_drAll) { + _Sw1="All"; + } else { + _Sw1 = intToString(_data_rate); + } + break; + + case FSB: + _send_timer.stop(); + _send_timer.reset(); + _state = BAND_CHANGE; + _dot->resetNetworkSession(); + _lora->resetActivityLed(); + _sem_join.displayEditFsb(intToString(10),20, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + 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 ModeGps::formatData(){ + _send_data.clear(); + uint32_t lat = 0; + uint32_t lng = 0; + double degrees = 0; + double minutes = 0; + double seconds = 0; + _temp_C += 0.5; + + if(_GPS) { + degrees = _latitude.degrees; + minutes = _latitude.minutes; + seconds = _latitude.seconds; + if(degrees<0) { + lat = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/90.0 + 1.5)); + } else { + lat = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/90.0 + 0.5)); + } + degrees = _longitude.degrees; + minutes = _longitude.minutes; + seconds = _longitude.seconds; + if(degrees<0) { + lng = ~(int)((degrees - minutes/60.0 - seconds/600000.0)*(-INT_MAX/180.0 + 1.5)); + } else { + lng = (int)((degrees + minutes/60.0 + seconds/600000.0)*(INT_MAX/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 ModeGps::setBand(){ + _sub_band++; + if(_sub_band > mDot::FSB_8) _sub_band = mDot::FSB_ALL; + _dot->setFrequencySubBand(_sub_band); +} + +void ModeGps::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 ModeGps::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 ModeGps::start(){ + init(); + _button_timer.start(); + ButtonHandler::ButtonEvent be; + osSignalClear(_main_id, buttonSignal | loraSignal); + 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(); + _sem_join.updateJoinFsb(_sub_band); + break; + + case PARAMETERS: + editParameter(); + break; + + default: + 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); + _sem.initial(); + _dot->setTxDataRate(_data_rate); + } else _sem_join.updateJoinFsb(_sub_band); + break; + + case PARAMETERS: + changeParameter(); + break; + + default: + 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!"); + osDelay(500); + _link_check = true; + _snr = _dot->getSnrStats(); + _rssi = _dot->getRssiStats(); + _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."); + osDelay(500); + _link_check = false; + _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(); + } + } +} \ No newline at end of file -- cgit v1.2.3 From 20d9a20195865f511cc128a65e5cf842da771566 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 11 Aug 2016 11:48:12 -0500 Subject: Update ModeGps.cpp --- Mode/ModeGps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp index 5befcbf..b8ecedc 100644 --- a/Mode/ModeGps.cpp +++ b/Mode/ModeGps.cpp @@ -60,7 +60,7 @@ void ModeGps::init(){ _state = PARAMETERS; _send_timer.start(); } else { _state = BAND_CHANGE; - _sem_join.displayEditFsb(intToString(10), _power, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + _sem_join.displayEditFsb(_data_rate, _power, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); } } -- cgit v1.2.3 From 875d5ed6c71d2ef839bd8c020e42c7ddd9a29623 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:06:54 -0500 Subject: Replace LayoutJoin.cpp --- Layout/LayoutJoin.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Layout/LayoutJoin.cpp b/Layout/LayoutJoin.cpp index 687437d..a0ec1ee 100644 --- a/Layout/LayoutJoin.cpp +++ b/Layout/LayoutJoin.cpp @@ -75,8 +75,12 @@ void LayoutJoin::updateFsb(uint8_t band) { writeField(_fFsb, buf, size, true); } -void LayoutJoin::updateRate(std::string rate) { - writeField(_fRate, rate, true); +void LayoutJoin::updateRate(uint8_t rate) { + char buf[8]; + size_t size; + + size = snprintf(buf, sizeof(buf), "%u", rate); + writeField(_fRate, buf, size, true); } void LayoutJoin::updatePower(uint32_t power) { @@ -129,7 +133,7 @@ void LayoutJoin::updateJoinFsb(uint8_t band) { writeField(_fCancel, buf, size, true); } -void LayoutJoin::displayEditFsb(string rate, uint32_t power, uint8_t band, string key, string id){ +void LayoutJoin::displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id){ clear(); startUpdate(); -- cgit v1.2.3 From 1a729268b2ac7a0e79aee137c4f7c4e27e21f2c3 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:07:33 -0500 Subject: Replace Layout.h --- Layout/Layout.h | 84 +++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 48 deletions(-) diff --git a/Layout/Layout.h b/Layout/Layout.h index 90ffe8d..c493ce2 100644 --- a/Layout/Layout.h +++ b/Layout/Layout.h @@ -16,61 +16,49 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef __LAYOUT_H__ -#define __LAYOUT_H__ +#ifndef __LAYOUTJOIN_H__ +#define __LAYOUTJOIN_H__ -#include "DOGS102.h" -#include +#include "Layout.h" +#include "mDot.h" -class Label { +class LayoutJoin : public Layout { public: - Label(uint8_t col, uint8_t row, std::string value); + LayoutJoin(DOGS102* lcd, uint8_t band); + ~LayoutJoin(); - uint8_t _col; - uint8_t _row; - std::string _value; -}; - -class Field { - public: - Field(uint8_t col, uint8_t row, uint8_t maxSize); - - uint8_t _col; - uint8_t _row; - uint8_t _maxSize; -}; - -class Image { - public: - Image(uint8_t col, uint8_t row, const uint8_t* bmp); - - uint8_t _col; - uint8_t _row; - const uint8_t* _bmp; -}; + void display(); + void displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id); -class Layout { - public: - Layout(DOGS102* lcd); - ~Layout(); - - virtual void display() = 0; - - protected: - void clear(); - void startUpdate(); - void endUpdate(); - bool writeLabel(const Label& label); - bool writeField(const Field& field, const std::string& value, bool apply = false); - bool writeField(const Field& field, const char* value, size_t size, bool apply = false); - bool writeImage(const Image& image, bool apply = false); - void removeField(const Field& field); + void updateId(std::string id); + void updateKey(std::string key); + void updateFsb(uint8_t band); + void updateJoinFsb(uint8_t band); + void updateRate(uint8_t rate); + void updatePower(uint32_t power); + void updateAttempt(uint32_t attempt); + void updateStatus(std::string status); + void updateCountdown(uint32_t seconds); + void displayCancel(bool display = true); private: - bool writeText(uint8_t col, uint8_t row, const char* value, size_t size); - bool writeBmp(uint8_t col, uint8_t row, const uint8_t* bmp); + Label _lId; + Label _lKey; + Label _lFsb; + Label _lRate; + Label _lPower; + Label _lAttempt; - DOGS102* _lcd; + Field _fStatus; + Field _fId; + Field _fKey; + Field _fFsb; + Field _fRate; + Field _fPower; + Field _fAttempt; + Field _fCountdown; + Field _fCountdownLabel; + Field _fCancel; + uint8_t _band; }; - #endif -- cgit v1.2.3 -- cgit v1.2.3 From 0e672dc05936939e43ce9ff4ee7fdde860adb4d2 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:08:10 -0500 Subject: Replace ModeGps.cpp --- Mode/ModeGps.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp index b8ecedc..9acf9ad 100644 --- a/Mode/ModeGps.cpp +++ b/Mode/ModeGps.cpp @@ -20,6 +20,7 @@ #include "MTSLog.h" #include "rtos.h" #include "mbed.h" +#include "limits.h" #define PACKETSIZE 11 ModeGps::ModeGps(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors, ModeJoin* join) @@ -151,7 +152,7 @@ void ModeGps::editParameter(){ _state = BAND_CHANGE; _dot->resetNetworkSession(); _lora->resetActivityLed(); - _sem_join.displayEditFsb(intToString(10),20, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + _sem_join.displayEditFsb(mDot::DR4, 20, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); break; case PADDING: -- cgit v1.2.3 From b3bccc99b3e9a1403ad000c06d7786832e71251c Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:09:23 -0500 Subject: Replace LayoutJoin.h --- Layout/LayoutJoin.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Layout/LayoutJoin.h b/Layout/LayoutJoin.h index 6ab9cce..c493ce2 100644 --- a/Layout/LayoutJoin.h +++ b/Layout/LayoutJoin.h @@ -28,13 +28,13 @@ class LayoutJoin : public Layout { ~LayoutJoin(); void display(); - void displayEditFsb(string rate, uint32_t power, uint8_t band, string key, string id); + void displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id); void updateId(std::string id); void updateKey(std::string key); void updateFsb(uint8_t band); void updateJoinFsb(uint8_t band); - void updateRate(std::string rate); + void updateRate(uint8_t rate); void updatePower(uint32_t power); void updateAttempt(uint32_t attempt); void updateStatus(std::string status); -- cgit v1.2.3 From da0143627375761a5cb07a1f315aae3135f18b9e Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:10:00 -0500 Subject: Replace Layout.h --- Layout/Layout.h | 84 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/Layout/Layout.h b/Layout/Layout.h index c493ce2..90ffe8d 100644 --- a/Layout/Layout.h +++ b/Layout/Layout.h @@ -16,49 +16,61 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef __LAYOUTJOIN_H__ -#define __LAYOUTJOIN_H__ +#ifndef __LAYOUT_H__ +#define __LAYOUT_H__ -#include "Layout.h" -#include "mDot.h" +#include "DOGS102.h" +#include -class LayoutJoin : public Layout { +class Label { public: - LayoutJoin(DOGS102* lcd, uint8_t band); - ~LayoutJoin(); + Label(uint8_t col, uint8_t row, std::string value); - void display(); - void displayEditFsb(uint8_t rate, uint32_t power, uint8_t band, string key, string id); + uint8_t _col; + uint8_t _row; + std::string _value; +}; + +class Field { + public: + Field(uint8_t col, uint8_t row, uint8_t maxSize); + + uint8_t _col; + uint8_t _row; + uint8_t _maxSize; +}; + +class Image { + public: + Image(uint8_t col, uint8_t row, const uint8_t* bmp); + + uint8_t _col; + uint8_t _row; + const uint8_t* _bmp; +}; - void updateId(std::string id); - void updateKey(std::string key); - void updateFsb(uint8_t band); - void updateJoinFsb(uint8_t band); - void updateRate(uint8_t rate); - void updatePower(uint32_t power); - void updateAttempt(uint32_t attempt); - void updateStatus(std::string status); - void updateCountdown(uint32_t seconds); - void displayCancel(bool display = true); +class Layout { + public: + Layout(DOGS102* lcd); + ~Layout(); + + virtual void display() = 0; + + protected: + void clear(); + void startUpdate(); + void endUpdate(); + bool writeLabel(const Label& label); + bool writeField(const Field& field, const std::string& value, bool apply = false); + bool writeField(const Field& field, const char* value, size_t size, bool apply = false); + bool writeImage(const Image& image, bool apply = false); + void removeField(const Field& field); private: - Label _lId; - Label _lKey; - Label _lFsb; - Label _lRate; - Label _lPower; - Label _lAttempt; + bool writeText(uint8_t col, uint8_t row, const char* value, size_t size); + bool writeBmp(uint8_t col, uint8_t row, const uint8_t* bmp); - Field _fStatus; - Field _fId; - Field _fKey; - Field _fFsb; - Field _fRate; - Field _fPower; - Field _fAttempt; - Field _fCountdown; - Field _fCountdownLabel; - Field _fCancel; - uint8_t _band; + DOGS102* _lcd; }; + #endif -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From c73e774937b387edffeec634296662f906ba26f8 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Tue, 16 Aug 2016 14:41:23 -0500 Subject: Replace ModeJoin.cpp --- Mode/ModeJoin.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index 5618eca..1608567 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 = (_band == mDot::FB_915) ? mDot::DR4 : mDot::SF_12; _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->getTxDataRate()); _join.updatePower(_power); _join.updateAttempt(_lora->getJoinAttempts()); } -- cgit v1.2.3 -- cgit v1.2.3 From 3c06faea14065285b3330b9fc0976f20c79288f2 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 10:50:56 -0500 Subject: Replace ModeJoin.cpp --- Mode/ModeJoin.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index 1608567..0806dc7 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::DR4 : mDot::SF_12; + _data_rate = mDot::DR0; _power = 20; _joined = false; -- cgit v1.2.3 From e7250153659f36406467e984da45db2606386dc3 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 10:51:16 -0500 Subject: Replace ModeGps.h --- Mode/ModeGps.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mode/ModeGps.h b/Mode/ModeGps.h index 2bbfaa1..39b64ff 100644 --- a/Mode/ModeGps.h +++ b/Mode/ModeGps.h @@ -52,7 +52,7 @@ private: float _temp_C; std::vector _send_data; - uint8_t _parameter, _padding, _interval,_max_padding; + uint8_t _parameter, _padding, _interval, _max_padding; bool _drAll, _link_check, _GPS; string _Sw1, _Sw2; -- cgit v1.2.3 From 3d3b61133c9808cdff34c3b7f247d5f5096a1b72 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 10:51:30 -0500 Subject: Replace ModeGps.cpp --- Mode/ModeGps.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp index 9acf9ad..d97e77e 100644 --- a/Mode/ModeGps.cpp +++ b/Mode/ModeGps.cpp @@ -48,7 +48,7 @@ void ModeGps::init(){ _link_check = false; _GPS = false; _sub_band = _dot->getFrequencySubBand(); - _data_rate = mDot::DR4; + _data_rate = mDot::DR0; _max_padding = _dot->getMaxPacketLength() - PACKETSIZE; _Sw2 = "Power"; _Sw1 = intToString(_power); @@ -61,15 +61,15 @@ void ModeGps::init(){ _state = PARAMETERS; _send_timer.start(); } else { _state = BAND_CHANGE; - _sem_join.displayEditFsb(_data_rate, _power, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + _sem_join.displayEditFsb(_data_rate, _power, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); } } void ModeGps::drIncrement(){ _data_rate++; - if (_data_rate > mDot::DR5) { + if (_data_rate > mDot::DR3 && _band == mDot::FB_915 || _data_rate > mDot::DR5) { _drAll = true; - _data_rate=0; + _data_rate = 0; } _dot->setTxDataRate(_data_rate); logInfo("new data rate %s, POWER %lu", mDot::DataRateStr(_data_rate).c_str(), _power); @@ -78,11 +78,7 @@ void ModeGps::drIncrement(){ void ModeGps::changeDataRate(){ if(_drAll) { - if(_band == mDot::FB_868){ - _data_rate = -1; - } else { - _data_rate = mDot::DR1; - } + _data_rate = -1; _drAll = false; } drIncrement(); @@ -152,7 +148,7 @@ void ModeGps::editParameter(){ _state = BAND_CHANGE; _dot->resetNetworkSession(); _lora->resetActivityLed(); - _sem_join.displayEditFsb(mDot::DR4, 20, _band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); break; case PADDING: @@ -236,7 +232,7 @@ void ModeGps::updateScreen(){ _GPS = false; } _sem.updateStats( _GPS, _longitude, _latitude, _time, _temp_C); - _sem.updateSw1(_Sw1, _Sw2, _data_rate, _power, _padding); + _sem.updateSw1(_Sw1, _Sw2); _sem.updateSw2(_Sw2); } @@ -297,7 +293,7 @@ bool ModeGps::start(){ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, DATA_RATE); _sem.initial(); _dot->setTxDataRate(_data_rate); - } else _sem_join.updateJoinFsb(_sub_band); + } else _sem_join.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); break; case PARAMETERS: @@ -357,4 +353,4 @@ bool ModeGps::start(){ send(); } } -} \ No newline at end of file +} -- cgit v1.2.3 -- cgit v1.2.3 -- cgit v1.2.3 From 945c195b31bed7bd1e5e71842673f7b2deaf7613 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 10:53:14 -0500 Subject: Replace LayoutSurveyGps.cpp --- Layout/LayoutSurveyGps.cpp | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/Layout/LayoutSurveyGps.cpp b/Layout/LayoutSurveyGps.cpp index 69924ea..9974cac 100644 --- a/Layout/LayoutSurveyGps.cpp +++ b/Layout/LayoutSurveyGps.cpp @@ -92,31 +92,13 @@ void LayoutSurveyGps::display(bool success, mDot::snr_stats snr, mDot::rssi_stat endUpdate(); } -void LayoutSurveyGps::updateSw1(string Sw1, string Sw2, int dr, int power, int padding){ - size_t size; - char buf[17]; +void LayoutSurveyGps::updateSw1(string Sw1, string Sw2){ 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 LayoutSurveyGps::updateSw2(string Sw2){ @@ -181,4 +163,4 @@ void LayoutSurveyGps::updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER: size = snprintf(buf, sizeof(buf), "%.1f", temp); writeField(_fTemp, buf, size, true); endUpdate(); -} \ No newline at end of file +} -- cgit v1.2.3 From c696d42e74aa791f291880379cb7c11fcb14a697 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 10:53:37 -0500 Subject: Replace LayoutSurveyGps.h --- Layout/LayoutSurveyGps.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Layout/LayoutSurveyGps.h b/Layout/LayoutSurveyGps.h index f24d1d4..9e3194f 100644 --- a/Layout/LayoutSurveyGps.h +++ b/Layout/LayoutSurveyGps.h @@ -36,7 +36,7 @@ public: 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 updateSw1(string Sw1, string Sw2); void updateStats(bool GPS, GPSPARSER::longitude lon, GPSPARSER::latitude lat, struct tm time, float temp); private: @@ -62,4 +62,4 @@ private: Field _fPadding; Field _fDownRssi; }; -#endif \ No newline at end of file +#endif -- cgit v1.2.3 From 22ac88e687d71b2a8a558ba90fab3ca570600819 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 11:17:05 -0500 Subject: Update ModeJoin.cpp --- Mode/ModeJoin.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index 0806dc7..239eadb 100644 --- a/Mode/ModeJoin.cpp +++ b/Mode/ModeJoin.cpp @@ -126,5 +126,4 @@ void ModeJoin::display() { _join.updateRate(_dot->getTxDataRate()); _join.updatePower(_power); _join.updateAttempt(_lora->getJoinAttempts()); -} - +} \ No newline at end of file -- cgit v1.2.3 From 805e501c3d15b32491fd478150cf286dd9834757 Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 11:44:12 -0500 Subject: Replace main.cpp --- main.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index fa91319..63f3a18 100644 --- a/main.cpp +++ b/main.cpp @@ -61,7 +61,7 @@ osThreadId main_id; ButtonHandler* buttons; // LoRa controller -LoRaHandler* lora; +LoRaHandler* lora_handler; mDot* dot; // GPS @@ -100,7 +100,7 @@ int main() { main_id = Thread::gettid(); buttons = new ButtonHandler(main_id); dot = mDot::getInstance(); - lora = new LoRaHandler(main_id); + lora_handler = new LoRaHandler(main_id); gps = new GPSPARSER(&gps_serial, led_cont); sensors = new SensorHandler(); @@ -108,12 +108,12 @@ 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); - modeGps = new ModeGps(lcd, buttons, dot, lora, gps, sensors, modeJoin); + modeJoin = new ModeJoin(lcd, buttons, dot, lora_handler, gps, sensors); + modeSingle = new ModeSingle(lcd, buttons, dot, lora_handler, gps, sensors); + modeSweep = new ModeSweep(lcd, buttons, dot, lora_handler, gps, sensors); + modeDemo = new ModeDemo(lcd, buttons, dot, lora_handler, gps, sensors); + modeConfig = new ModeConfig(lcd, buttons, dot, lora_handler, gps, sensors); + modeGps = new ModeGps(lcd, buttons, dot, lora_handler, gps, sensors, modeJoin); osDelay(1000); logInfo("%sGPS detected", gps->gpsDetected() ? "" : "no "); @@ -164,7 +164,7 @@ void mainMenu() { // reset session between modes dot->resetNetworkSession(); - lora->resetActivityLed(); + lora_handler->resetActivityLed(); LayoutScrollSelect menu(lcd, items, product, menu_strings[0]); menu.display(); -- cgit v1.2.3 From d15988a5fc22ea3b106ddd87b4457f378a6580fd Mon Sep 17 00:00:00 2001 From: Ryan Klaassen Date: Thu, 18 Aug 2016 12:20:41 -0500 Subject: Update LayoutSurveyGps.cpp --- Layout/LayoutSurveyGps.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Layout/LayoutSurveyGps.cpp b/Layout/LayoutSurveyGps.cpp index 9974cac..2630566 100644 --- a/Layout/LayoutSurveyGps.cpp +++ b/Layout/LayoutSurveyGps.cpp @@ -37,7 +37,7 @@ LayoutSurveyGps::LayoutSurveyGps(DOGS102* lcd, uint8_t band) _fGpsTime(0,5,17), _fDownSnr(12,2,5), _fPadding(4,6,3), - _fDownRssi(0,2,11) + _fDownRssi(0,2,12) {} LayoutSurveyGps::~LayoutSurveyGps() {} -- cgit v1.2.3