diff options
Diffstat (limited to 'Mode')
-rw-r--r-- | Mode/Mode.cpp | 2 | ||||
-rw-r--r-- | Mode/ModeData.cpp | 187 | ||||
-rw-r--r-- | Mode/ModeData.h | 58 | ||||
-rw-r--r-- | Mode/ModeGps.cpp | 356 | ||||
-rw-r--r-- | Mode/ModeGps.h | 77 | ||||
-rw-r--r-- | Mode/ModeJoin.cpp | 3 | ||||
-rw-r--r-- | Mode/ModeSemtech.cpp | 12 | ||||
-rw-r--r-- | Mode/ModeSingle.cpp | 4 |
8 files changed, 690 insertions, 9 deletions
diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp index bed78ec..462e145 100644 --- a/Mode/Mode.cpp +++ b/Mode/Mode.cpp @@ -279,7 +279,7 @@ std::vector<uint8_t> Mode::formatSurveyData(DataItem& data) { send_data.push_back((data.link.down.snr/10) & 0xFF); // collect GPS data if GPS device detected - if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_868))){ + if (_gps->gpsDetected() && ((_data_rate != mDot::SF_10) || (_band == mDot::FB_EU868))){ send_data.push_back(0x19); // key for GPS Lock Status satfix = (_gps->getNumSatellites() << 4 ) | (_gps->getFixStatus() & 0x0F ); send_data.push_back(satfix); diff --git a/Mode/ModeData.cpp b/Mode/ModeData.cpp new file mode 100644 index 0000000..401277e --- /dev/null +++ b/Mode/ModeData.cpp @@ -0,0 +1,187 @@ +/* Copyright (c) <2016> <MultiTech Systems>, 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 "ModeData.h" +#include "MTSText.h" +#define ONELINEMAX 93 + +ModeData::ModeData(DOGS102* lcd, ButtonHandler* _buttons, mDot* _dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors) + :Mode(lcd,_buttons,_dot,lora,gps,sensors), + _data(lcd), + _help(lcd), + _buf_size(ONELINEMAX) +{} + +ModeData::~ModeData() {} + +bool ModeData::checkFile(){ + bool exists = false; + //get all files and see if file exists + vector<mDot::mdot_file> files = _dot->listUserFiles(); + for (vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) { + if (strcmp(file_name,it->name)==0) { + exists = true; + break; + } + } + //if file doesnt exist exit to main menu + if(!exists) { + _data.noData(); + osDelay(3000); + return true; + } + _file = _dot->openUserFile(file_name, mDot::FM_RDONLY); + //if nothing is in file exit to main menu + if (_file.fd < 0) { + _data.errorData(); + osDelay(3000); + _dot->closeUserFile(_file); + return true; + } + return false; +} + +bool ModeData::start(){ + if(checkFile()) + return true; + _help.display(); + osDelay(3000); + readFile(); +} + +void ModeData::displayData(){ + std::vector<std::string> data = mts::Text::split(_str, ','); + _line.id = data.at(0); + _line.status = data.at(1); + _line.lock = data.at(2); + _line.lat = data.at(3); + _line.lng = data.at(4); + _line.alt = data.at(5); + _line.time = data.at(6); + _line.gateways = data.at(7); + _line.margin = data.at(8); + _line.rssiD = data.at(9); + _line.snrD = data.at(10); + _line.dataRate = data.at(11); + _line.power = data.at(12); + _data.updateAll(_line); +} + +//get the current line out of the buffer into str +void ModeData::getLine(){ + _prev = 0; + _indexUpdate = 0; + _str = ""; + _dot->readUserFile(_file, (void*)_buf, _buf_size); + //only gets called when going back + if(_last) { + //-3 puts it back to one before new line + _indexUpdate = _buf_size - 3; + //check from back of buffer for new line + while(_buf[_indexUpdate] != '\n' && _indexUpdate >= 0){ + _indexUpdate--; + } + _indexUpdate++; + } + //go from indexUpdate to new line to ge the line + //prev keeps track of how long line read was + while(_buf[_indexUpdate]!='\n') { + _str += _buf[_indexUpdate]; + _indexUpdate++; + _prev++; + } + //push index past newline + _index += _indexUpdate + 1; + displayData(); +} + +void ModeData::back(){ + if(_index >= (_buf_size + _prev)) { + _index -= (_prev + _buf_size); + } else { + //special case for beginning of file + if(_index > 0){ + _buf_size = _index-1; + } + _buf_size -= _prev; + _index = 0; + } + _last = true; + _dot->seekUserFile(_file, _index, SEEK_SET); + getLine(); +} + +void ModeData::forward(){ + _last = false; + if(_index < _file.size) { + _buf_size = ONELINEMAX; + _dot->seekUserFile(_file, _index, SEEK_SET); + getLine(); + } +} + +//update switch labels +void ModeData::configSw(){ + if(_index - (_prev+1) <= 0){ + _data.updateSw2(""); + } else { + _data.updateSw2("Back"); + } + if(_index<_file.size){ + _data.updateSw1("Next"); + } else { + _data.updateSw1(""); + } +} + +bool ModeData::readFile(){ + _index = 0; + _last = false; + _prev = 0; + _indexUpdate = 0; + //called to start on page one + forward(); + configSw(); + ButtonHandler::ButtonEvent be; + while (true) { + be = _buttons->getButtonEvent(); + switch(be) { + case ButtonHandler::sw1_press: + if(_index!=_file.size) { + forward(); + configSw(); + } + break; + + case ButtonHandler::sw2_press: + if(_index - (_prev+1) > 0) { + back(); + configSw(); + } + break; + + case ButtonHandler::sw1_hold: + _dot->closeUserFile(_file); + return true; + + default: + break; + } + } +} + diff --git a/Mode/ModeData.h b/Mode/ModeData.h new file mode 100644 index 0000000..f9da741 --- /dev/null +++ b/Mode/ModeData.h @@ -0,0 +1,58 @@ +/* Copyright (c) <2016> <MultiTech Systems>, 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 __MODEDATA_H__ +#define __MODEDATA_H__ + +#include "Mode.h" +#include "LayoutData.h" +#include "LayoutHelp.h" + +class ModeData : public Mode{ + +public: + ModeData(DOGS102* lcd, ButtonHandler* buttons, mDot* dot, LoRaHandler* lora, GPSPARSER* gps, SensorHandler* sensors); + ~ModeData(); + + bool start(); + +private: + bool _last; + string _str; + + int32_t _pos, _buf_size, _indexUpdate, _prev; + uint32_t _index; + + char _buf[93]; + + mDot::mdot_file _file; + + LayoutData _data; + LayoutHelp _help; + LayoutData::singleLine _line; + + bool checkFile(); + bool readFile(); + string parse(); + void getLine(); + void displayData(); + void forward(); + void back(); + void configSw(); +}; +#endif
\ No newline at end of file diff --git a/Mode/ModeGps.cpp b/Mode/ModeGps.cpp new file mode 100644 index 0000000..47053cb --- /dev/null +++ b/Mode/ModeGps.cpp @@ -0,0 +1,356 @@ +/* Copyright (c) <2016> <MultiTech Systems>, 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" +#include "limits.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::DR0; + _max_padding = _dot->getMaxPacketLength() - PACKETSIZE; + _Sw2 = "Power"; + _Sw1 = intToString(_power); + _help.display(); + osDelay(2000); + + if(_band == mDot::FB_EU868){ + _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(_data_rate, _power, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + } +} + +void ModeGps::drIncrement(){ + _data_rate++; + if (_data_rate > mDot::DR3 && _band == mDot::FB_915 || _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) { + _data_rate = -1; + _drAll = false; + } + drIncrement(); +} + +void ModeGps::changeParameter(){ + _parameter++; + if(_band == mDot::FB_EU868 && _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(mDot::DR0, 20, _sub_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); + _sem.updateSw2(_Sw2); +} + +void ModeGps::send(){ + _state = SENDING; + _send_timer.stop(); + if(_band == mDot::FB_EU868) { + 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.displayEditFsb(mDot::DR0, 20, _sub_band, _dot->getNetworkName(), _dot->getNetworkPassphrase()); + 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(); + } + } +} diff --git a/Mode/ModeGps.h b/Mode/ModeGps.h new file mode 100644 index 0000000..39b64ff --- /dev/null +++ b/Mode/ModeGps.h @@ -0,0 +1,77 @@ +/* Copyright (c) <2016> <MultiTech Systems>, 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<uint8_t> _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 diff --git a/Mode/ModeJoin.cpp b/Mode/ModeJoin.cpp index 4bdc6cd..3a86dd9 100644 --- a/Mode/ModeJoin.cpp +++ b/Mode/ModeJoin.cpp @@ -123,8 +123,7 @@ void ModeJoin::display() { _sub_band = _dot->getFrequencySubBand(); _join.updateFsb(_sub_band); } - _join.updateRate(_dot->DataRateStr(_data_rate).substr(2)); + _join.updateRate(_dot->getTxDataRate()); _join.updatePower(_power); _join.updateAttempt(_lora->getJoinAttempts()); } - diff --git a/Mode/ModeSemtech.cpp b/Mode/ModeSemtech.cpp index 9de48ad..5c2d180 100644 --- a/Mode/ModeSemtech.cpp +++ b/Mode/ModeSemtech.cpp @@ -58,7 +58,7 @@ void ModeSemtech::init() _Sw1 = intToString(_power); _help.display(); osDelay(2000); - if(_band==mDot::FB_868){ + if(_band==mDot::FB_EU868){ _sem.display(_link_check, _snr, _rssi, _power, _sub_band, _padding, _data_rate); _sem.initial(); _state = PARAMETERS; @@ -84,7 +84,7 @@ void ModeSemtech::drIncrement() void ModeSemtech::changeDataRate() { if(_drAll) { - if(_band == mDot::FB_868) _data_rate = -1; + if(_band == mDot::FB_EU868) _data_rate = -1; else _data_rate = mDot::DR1; _drAll = false; } @@ -94,7 +94,7 @@ void ModeSemtech::changeDataRate() void ModeSemtech::changeParameter() { _parameter++; - if(_band==mDot::FB_868&&_parameter==FSB)_parameter++; + if(_band==mDot::FB_EU868&&_parameter==FSB)_parameter++; if(_parameter>INTERVAL)_parameter=0; switch(_parameter) { case DATA_RATE: @@ -219,7 +219,7 @@ void ModeSemtech::send() { _state = SENDING; _send_timer.stop(); - if(_band==mDot::FB_868) { + if(_band==mDot::FB_EU868) { while(_dot->getNextTxMs()>0) { _sem.updateNextCh((int)(_dot->getNextTxMs()/1000)); osDelay(250); @@ -239,7 +239,9 @@ bool ModeSemtech::start() _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); + + if(_band == mDot::FB_US915 || _band == mDot::FB_AU915) + _join = new ModeJoin(_lcd, _buttons, _dot, _lora, _gps, _sensors); while (true) { if(_state==PARAMETERS)updateScreen(); diff --git a/Mode/ModeSingle.cpp b/Mode/ModeSingle.cpp index 982d8b9..6cc3f4b 100644 --- a/Mode/ModeSingle.cpp +++ b/Mode/ModeSingle.cpp @@ -324,7 +324,9 @@ void ModeSingle::incrementRatePower() { if (_power == 20) { _power = 2; _data_rate++; - if (_band == mDot::FB_915 && _data_rate > mDot::DR4 || _band == mDot::FB_868 && _data_rate > mDot::DR7) { + if ((_band == mDot::FB_US915 && _data_rate > mDot::DR4) || + (_band == mDot::FB_AU915 && _data_rate > mDot::DR4) || + (_band == mDot::FB_EU868 && _data_rate > mDot::DR7)) { _data_rate = mDot::DR0; } } else { |