MTDOT-BOX-EVB-Factory-Firmware
Dependencies: NCP5623B GpsParser ISL29011 libmDot-mbed5 MTS-Serial MMA845x DOGS102 MPL3115A2
Diff: Mode/ModeSingle.cpp
- Revision:
- 12:05435282f899
- Parent:
- 7:a31236c2e75c
--- a/Mode/ModeSingle.cpp Thu Nov 10 22:10:58 2016 +0000 +++ b/Mode/ModeSingle.cpp Tue Oct 09 13:49:30 2018 -0500 @@ -41,8 +41,10 @@ // clear any stale signals osSignalClear(_main_id, buttonSignal | loraSignal); - _initial_data_rate = _dot->getTxDataRate(); + _initial_data_rate = _dot->getTxDataRate() < _dot->getMinDatarate() ? _dot->getMinDatarate() : _dot->getTxDataRate(); _initial_power = _dot->getTxPower(); + _data_rate = _dot->getMinDatarate(); + // see if we're supposed to send the data packet after success // that item is stored in the mDot::StartUpMode config field @@ -321,16 +323,14 @@ } void ModeSingle::incrementRatePower() { - if (_power == 20) { - _power = 2; + if (_power <= 2) { + _power = 20; _data_rate++; - if ((_band == mDot::FB_US915 && _data_rate > mDot::DR4) || - (_band == mDot::FB_AU915 && _data_rate > mDot::DR4) || - (_band == mDot::FB_EU868 && _data_rate > mDot::DR6)) { - _data_rate = mDot::DR0; + if (_data_rate > _dot->getMaxDatarate()) { + _data_rate = _dot->getMinDatarate(); } } else { - _power += 3; + _power -= 3; } logInfo("new data rate %s, power %lu", mDot::DataRateStr(_data_rate).c_str(), _power);