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 (limited to 'Mode') 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 (limited to 'Mode') 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 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 (limited to 'Mode') 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 (limited to 'Mode') 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 (limited to 'Mode') 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 (limited to 'Mode') 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(-) (limited to 'Mode') 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 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(-) (limited to 'Mode') 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 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(-) (limited to 'Mode') 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 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(-) (limited to 'Mode') 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(-) (limited to 'Mode') 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(-) (limited to 'Mode') 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 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(-) (limited to 'Mode') 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