ver1
Diff: plans/ChannelPlan_EU868.cpp
- Revision:
- 151:2242ecfd733a
- Parent:
- 147:f21064722534
- Child:
- 157:8e9b1e84ffac
--- a/plans/ChannelPlan_EU868.cpp Fri May 04 15:33:24 2018 -0500 +++ b/plans/ChannelPlan_EU868.cpp Fri May 04 15:44:58 2018 -0500 @@ -312,7 +312,11 @@ uint8_t ChannelPlan_EU868::SetRxConfig(uint8_t window, bool continuous) { RxWindow rxw = GetRxWindow(window); - GetRadio()->SetChannel(rxw.Frequency); + + if (_dlChannels[_txChannel].Frequency != 0) + GetRadio()->SetChannel(_dlChannels[_txChannel].Frequency); + else + GetRadio()->SetChannel(rxw.Frequency); Datarate rxDr = GetDatarate(rxw.DatarateIndex); uint32_t bw = rxDr.Bandwidth; @@ -378,8 +382,12 @@ uint16_t sto = rxDr.SymbolTimeout(); bool crc = false; // downlink does not use CRC according to LORAWAN bool iq = GetTxDatarate().RxIQ; + uint32_t freq = rxw.Frequency; - logTrace("RX%d on freq: %lu", wnd, rxw.Frequency); + if (wnd == 1 && _dlChannels[_txChannel].Frequency != 0) + freq = _dlChannels[_txChannel].Frequency; + + logTrace("RX%d on freq: %lu", wnd, freq); logTrace("RX DR: %u SF: %u BW: %u CR: %u PL: %u STO: %u CRC: %d IQ: %d", rxDr.Index, sf, bw, cr, pl, sto, crc, iq); } @@ -468,18 +476,22 @@ status &= 0xFE; // Channel index KO } - if (!GetRadio()->CheckRfFrequency(chParam.Frequency)) { + if (chParam.Frequency == 0) { + chParam.DrRange.Value = 0; + } else if (chParam.Frequency < _minFrequency || chParam.Frequency > _maxFrequency) { logError("New Channel frequency KO"); status &= 0xFE; // Channel frequency KO } - if (chParam.DrRange.Fields.Min > chParam.DrRange.Fields.Max) { + if (chParam.DrRange.Fields.Min > chParam.DrRange.Fields.Max && chParam.Frequency != 0) { logError("New Channel datarate min/max KO"); status &= 0xFD; // Datarate range KO - } else if (chParam.DrRange.Fields.Min < _minDatarate || chParam.DrRange.Fields.Min > _maxDatarate) { + } else if ((chParam.DrRange.Fields.Min < _minDatarate || chParam.DrRange.Fields.Min > _maxDatarate) && + chParam.Frequency != 0) { logError("New Channel datarate min KO"); status &= 0xFD; // Datarate range KO - } else if (chParam.DrRange.Fields.Max < _minDatarate || chParam.DrRange.Fields.Max > _maxDatarate) { + } else if ((chParam.DrRange.Fields.Max < _minDatarate || chParam.DrRange.Fields.Max > _maxDatarate) && + chParam.Frequency != 0) { logError("New Channel datarate max KO"); status &= 0xFD; // Datarate range KO } @@ -577,7 +589,7 @@ // // Remark MaxTxPower = 0 and MinTxPower = 7 // - if (power < 0 || power > 7) { + if (power > 7) { status &= 0xFB; // TxPower KO }