Bleeding edge development version of the mDot library for mbed 5. This version of the library is not guaranteed to be stable or well tested and should not be used in production or deployment scenarios.

Dependents:   mDot-IKS01A1 mDot-IKS01A1 mDot-Examples mDot-IKS01A1-Explora ... more

Fork of libmDot-dev-mbed2-deprecated by MultiTech

The Dot library provides a LoRaWan certified stack for LoRa communication using MultiTech mDot and xDot devices. The stack is compatible with mbed 5.

Dot Library Version 3 Updates

Dot Library versions 3.x.x require a channel plan to be injected into the stack. Channel plans are included with the 3.x.x Dot Library releases. The following code snippet demonstrates how to create a channel plan and inject it into the stack.

#include "mDot.h"
#include "channel_plans.h"

int main() {
    ChannelPlan* plan = new lora::ChannelPlan_US915();
    assert(plan);
    mDot* dot = mDot::getInstance(plan);
    assert(dot);

    // ...
}

Dot devices must not be deployed with software using a different channel plan than the Dot's default plan! This functionality is for development and testing only!

Multicast Sessions

Multicast sessions and packet rx events in library. When in Class C mode Multicast downlinks can be received. Recieved packets should be filtered on address, counter value will be maintained in the session or can be set explicitly depending on Application support to share Multicast Address, Keys and Counters.

mDot.h

        /**
         * Add a multicast session address and keys
         * Downlink counter is set to 0
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastSession(uint8_t index, uint32_t addr, const uint8_t* nsk, const uint8_t* dsk);
 
        /**
         * Set a multicast session counter
         * Up to 3 MULTICAST_SESSIONS can be set
         */
        int32_t setMulticastDownlinkCounter(uint8_t index, uint32_t count);

mDotEvent.h

The address field was added to PacketRx event.

        virtual void PacketRx(uint8_t port, uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr, lora::DownlinkControl ctrl, uint8_t slot, uint8_t retries, uint32_t address);

The name of the repository can be used to determine which device the stack was compiled for and if it's a development or production-ready build:

A changelog for the Dot library can be found here.

The Dot library version and the version of mbed-os it was compiled against can both be found in the commit message for that revision of the Dot library. Building your application with the same version of mbed-os as what was used to build the Dot library is highly recommended!

The Dot-Examples repository demonstrates how to use the Dot library in a custom application.

The mDot and xDot platform pages have lots of platform specific information and document potential issues, gotchas, etc, and provide instructions for getting started with development. Please take a look at the platform page before starting development as they should answer many questions you will have.

Committer:
Jenkins@KEILDM1.dc.multitech.prv
Date:
Thu Dec 28 13:50:17 2017 -0600
Revision:
115:bcd44682ac1e
Parent:
104:9662b62f1977
Child:
134:e5ad4bd55ce5
mdot-library revision 3.0.2-18-gc1ba0dc and mbed-os revision mbed-os-5.5.7

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 1 /**********************************************************************
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 2 * COPYRIGHT 2016 MULTI-TECH SYSTEMS, INC.
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 3 *
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 4 * ALL RIGHTS RESERVED BY AND FOR THE EXCLUSIVE BENEFIT OF
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 5 * MULTI-TECH SYSTEMS, INC.
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 6 *
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 7 * MULTI-TECH SYSTEMS, INC. - CONFIDENTIAL AND PROPRIETARY
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 8 * INFORMATION AND/OR TRADE SECRET.
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 9 *
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 10 * NOTICE: ALL CODE, PROGRAM, INFORMATION, SCRIPT, INSTRUCTION,
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 11 * DATA, AND COMMENT HEREIN IS AND SHALL REMAIN THE CONFIDENTIAL
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 12 * INFORMATION AND PROPERTY OF MULTI-TECH SYSTEMS, INC.
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 13 * USE AND DISCLOSURE THEREOF, EXCEPT AS STRICTLY AUTHORIZED IN A
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 14 * WRITTEN AGREEMENT SIGNED BY MULTI-TECH SYSTEMS, INC. IS PROHIBITED.
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 15 *
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 16 ***********************************************************************/
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 17
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 18 #include "ChannelPlan_AU915.h"
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 19 #include "limits.h"
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 20
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 21 using namespace lora;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 22
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 23 const uint8_t ChannelPlan_AU915::AU915_TX_POWERS[] = { 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10 };
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 24 const uint8_t ChannelPlan_AU915::AU915_RADIO_POWERS[] = { 3, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 19 };
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 25 const uint8_t ChannelPlan_AU915::AU915_MAX_PAYLOAD_SIZE[] = { 51, 51, 51, 115, 242, 242, 242, 0, 53, 129, 242, 242, 242, 242, 0, 0 };
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 26 const uint8_t ChannelPlan_AU915::AU915_MAX_PAYLOAD_SIZE_REPEATER[] = { 51, 51, 51, 115, 222, 222, 222, 0, 33, 109, 222, 222, 222, 222, 0, 0 };
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 27
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 28 ChannelPlan_AU915::ChannelPlan_AU915()
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 29 :
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 30 ChannelPlan(NULL, NULL)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 31 {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 32
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 33 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 34
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 35 ChannelPlan_AU915::ChannelPlan_AU915(Settings* settings)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 36 :
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 37 ChannelPlan(NULL, settings)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 38 {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 39
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 40 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 41
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 42 ChannelPlan_AU915::ChannelPlan_AU915(SxRadio* radio, Settings* settings)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 43 :
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 44 ChannelPlan(radio, settings)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 45 {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 46
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 47 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 48
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 49 ChannelPlan_AU915::~ChannelPlan_AU915() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 50
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 51 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 52
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 53 void ChannelPlan_AU915::Init() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 54 _plan = AU915;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 55 _planName = "AU915";
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 56
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 57 _datarates.clear();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 58 _channels.clear();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 59 _dutyBands.clear();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 60
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 61 DutyBand band;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 62
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 63 band.Index = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 64 band.DutyCycle = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 65
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 66 Datarate dr;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 67
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 68 _maxTxPower = 30;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 69 _minTxPower = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 70
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 71 _minFrequency = AU915_FREQ_MIN;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 72 _maxFrequency = AU915_FREQ_MAX;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 73
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 74 TX_POWERS = AU915_TX_POWERS;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 75 RADIO_POWERS = AU915_RADIO_POWERS;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 76 MAX_PAYLOAD_SIZE = AU915_MAX_PAYLOAD_SIZE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 77 MAX_PAYLOAD_SIZE_REPEATER = AU915_MAX_PAYLOAD_SIZE_REPEATER;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 78
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 79 band.FrequencyMin = AU915_FREQ_MIN;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 80 band.FrequencyMax = AU915_FREQ_MAX;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 81
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 82 _freqUBase125k = AU915_125K_FREQ_BASE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 83 _freqUStep125k = AU915_125K_FREQ_STEP;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 84 _freqUBase500k = AU915_500K_FREQ_BASE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 85 _freqUStep500k = AU915_500K_FREQ_STEP;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 86 _freqDBase500k = AU915_500K_DBASE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 87 _freqDStep500k = AU915_500K_DSTEP;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 88 GetSettings()->Session.Rx2Frequency = AU915_500K_DBASE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 89
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 90 _minDatarate = AU915_MIN_DATARATE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 91 _maxDatarate = AU915_MAX_DATARATE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 92 _minRx2Datarate = DR_8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 93 _maxRx2Datarate = DR_13;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 94 _minDatarateOffset = AU915_MIN_DATARATE_OFFSET;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 95 _maxDatarateOffset = AU915_MAX_DATARATE_OFFSET;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 96
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 97 _numChans125k = AU915_125K_NUM_CHANS;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 98 _numChans500k = AU915_500K_NUM_CHANS;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 99
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 100 logInfo("Initialize channels...");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 101
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 102 SetNumberOfChannels(AU915_125K_NUM_CHANS + AU915_500K_NUM_CHANS, false);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 103
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 104 dr.SpreadingFactor = SF_12;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 105
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 106 logInfo("Initialize datarates...");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 107
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 108 // Add DR0-5
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 109 while (dr.SpreadingFactor >= SF_7) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 110 AddDatarate(-1, dr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 111 dr.SpreadingFactor--;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 112 dr.Index++;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 113 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 114
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 115 // Add DR6
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 116 dr.SpreadingFactor = SF_8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 117 dr.Bandwidth = BW_500;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 118 AddDatarate(-1, dr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 119 dr.Index++;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 120
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 121 // Skip DR7 RFU
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 122 dr.SpreadingFactor = SF_INVALID;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 123 AddDatarate(-1, dr), dr.Index++;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 124
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 125 if (GetSettings()->Network.FrequencySubBand == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 126 band.PowerMax = 30;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 127 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 128 band.PowerMax = 21;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 129 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 130
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 131 band.TimeOffEnd = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 132
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 133 AddDutyBand(-1, band);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 134
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 135 GetSettings()->Session.Rx2DatarateIndex = DR_8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 136
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 137 // Add DR8-13
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 138 dr.SpreadingFactor = SF_12;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 139 while (dr.SpreadingFactor >= SF_7) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 140 AddDatarate(-1, dr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 141 dr.SpreadingFactor--;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 142 dr.Index++;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 143 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 144
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 145 // Skip DR14-15 RFU
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 146 dr.SpreadingFactor = SF_INVALID;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 147 AddDatarate(-1, dr), AddDatarate(-1, dr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 148
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 149 GetSettings()->Session.TxDatarate = DR_0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 150 GetSettings()->Session.TxPower = GetSettings()->Network.TxPower;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 151
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 152 SetFrequencySubBand(GetSettings()->Network.FrequencySubBand);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 153
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 154 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 155
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 156 uint8_t ChannelPlan_AU915::HandleJoinAccept(const uint8_t* buffer, uint8_t size) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 157 if (size > 17) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 158 // TODO: Handle future channel mask settings
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 159 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 160
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 161 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 162 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 163
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 164 void ChannelPlan_AU915::SetNumberOfChannels(uint8_t channels, bool resize) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 165 uint8_t newsize = ((channels - 1) / CHAN_MASK_SIZE) + 1;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 166
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 167 if (resize) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 168 _channels.resize(channels);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 169 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 170
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 171 _channelMask.resize(newsize, 0x0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 172 _numChans = channels;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 173
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 174 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 175
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 176 uint8_t ChannelPlan_AU915::GetMinDatarate() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 177 if (GetSettings()->Network.Mode == lora::PEER_TO_PEER)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 178 return 8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 179 else
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 180 return _minDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 181 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 182
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 183 uint8_t ChannelPlan_AU915::GetMaxDatarate() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 184 if (GetSettings()->Network.Mode == lora::PEER_TO_PEER)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 185 return 13;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 186 else
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 187 return _maxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 188 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 189
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 190 bool ChannelPlan_AU915::IsChannelEnabled(uint8_t channel) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 191 uint8_t index = channel / CHAN_MASK_SIZE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 192 uint8_t shift = channel % CHAN_MASK_SIZE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 193
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 194 assert(index < _channelMask.size() * CHAN_MASK_SIZE);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 195
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 196 // cannot shift over 32 bits
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 197 assert(shift < 32);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 198
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 199 // logDebug("index: %d shift %d cm: %04x bit: %04x enabled: %d", index, shift, _channelMask[index], (1 << shift), (_channelMask[index] & (1 << shift)) == (1 << shift));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 200
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 201 return (_channelMask[index] & (1 << shift)) == (1 << shift);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 202 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 203
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 204 uint8_t ChannelPlan_AU915::SetRx1Offset(uint8_t offset) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 205 GetSettings()->Session.Rx1DatarateOffset = offset;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 206 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 207 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 208
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 209 uint8_t ChannelPlan_AU915::SetRx2Frequency(uint32_t freq) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 210 GetSettings()->Session.Rx2Frequency = freq;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 211 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 212 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 213
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 214 uint8_t ChannelPlan_AU915::SetRx2DatarateIndex(uint8_t index) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 215 GetSettings()->Session.Rx2DatarateIndex = index;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 216 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 217 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 218
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 219 uint8_t ChannelPlan_AU915::SetTxConfig() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 220
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 221 logInfo("Configure radio for TX");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 222
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 223 uint8_t band = GetDutyBand(GetChannel(_txChannel).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 224 Datarate txDr = GetDatarate(GetSettings()->Session.TxDatarate);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 225 int8_t max_pwr = _dutyBands[band].PowerMax;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 226
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 227 int8_t pwr = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 228
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 229 pwr = std::min < int8_t > (GetSettings()->Session.TxPower, max_pwr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 230 if (pwr + GetSettings()->Network.AntennaGain >= max_pwr + 6 && GetSettings()->Network.AntennaGain > 6) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 231 pwr -= (GetSettings()->Network.AntennaGain - 6);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 232 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 233
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 234 for (int i = 20; i >= 0; i--) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 235 if (RADIO_POWERS[i] <= pwr) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 236 pwr = i;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 237 break;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 238 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 239 if (i == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 240 pwr = i;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 241 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 242 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 243
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 244 logDebug("Session pwr: %d ant: %d max: %d", GetSettings()->Session.TxPower, GetSettings()->Network.AntennaGain, max_pwr);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 245 logDebug("Radio Power index: %d output: %d total: %d", pwr, RADIO_POWERS[pwr], RADIO_POWERS[pwr] + GetSettings()->Network.AntennaGain);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 246
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 247 uint32_t bw = txDr.Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 248 uint32_t sf = txDr.SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 249 uint8_t cr = txDr.Coderate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 250 uint8_t pl = txDr.PreambleLength;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 251 uint16_t fdev = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 252 bool crc = txDr.Crc;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 253 bool iq = txDr.TxIQ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 254
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 255 if (GetSettings()->Network.DisableCRC == true)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 256 crc = false;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 257
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 258 SxRadio::RadioModems_t modem = SxRadio::MODEM_LORA;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 259
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 260 if (sf == SF_FSK) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 261 modem = SxRadio::MODEM_FSK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 262 sf = 50e3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 263 fdev = 25e3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 264 bw = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 265 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 266
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 267 GetRadio()->SetTxConfig(modem, pwr, fdev, bw, sf, cr, pl, false, crc, false, 0, iq, 3e3);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 268
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 269 logDebug("TX PWR: %u DR: %u SF: %u BW: %u CR: %u PL: %u CRC: %d IQ: %d", pwr, txDr.Index, sf, bw, cr, pl, crc, iq);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 270
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 271 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 272 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 273
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 274 uint8_t ChannelPlan_AU915::SetRxConfig(uint8_t window, bool continuous) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 275
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 276 RxWindow rxw = GetRxWindow(window);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 277 GetRadio()->SetChannel(rxw.Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 278
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 279 Datarate rxDr = GetDatarate(rxw.DatarateIndex);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 280 uint32_t bw = rxDr.Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 281 uint32_t sf = rxDr.SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 282 uint8_t cr = rxDr.Coderate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 283 uint8_t pl = rxDr.PreambleLength;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 284 uint16_t sto = rxDr.SymbolTimeout();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 285 uint32_t afc = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 286 bool crc = false; // downlink does not use CRC according to LORAWAN
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 287
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 288 if (GetSettings()->Network.DisableCRC == true)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 289 crc = false;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 290
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 291 Datarate txDr = GetDatarate(GetSettings()->Session.TxDatarate);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 292 bool iq = txDr.RxIQ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 293
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 294 if (P2PEnabled()) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 295 iq = txDr.TxIQ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 296 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 297
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 298 SxRadio::RadioModems_t modem = SxRadio::MODEM_LORA;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 299
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 300 if (sf == SF_FSK) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 301 modem = SxRadio::MODEM_FSK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 302 sf = 50e3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 303 cr = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 304 bw = 50e3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 305 afc = 83333;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 306 iq = false;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 307 crc = true; // FSK must use CRC
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 308 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 309
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 310 // Disable printf's to actually receive packets, printing to debug may mess up the timing
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 311 // logTrace("Configure radio for RX%d on freq: %lu", window, rxw.Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 312 // logTrace("RX SF: %u BW: %u CR: %u PL: %u STO: %u CRC: %d IQ: %d", sf, bw, cr, pl, sto, crc, iq);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 313
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 314 GetRadio()->SetRxConfig(modem, bw, sf, cr, afc, pl, sto, false, 0, crc, false, 0, iq, continuous);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 315
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 316 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 317 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 318
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 319 uint8_t ChannelPlan_AU915::AddChannel(int8_t index, Channel channel) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 320 logTrace("Add Channel %d : %lu : %02x %d", index, channel.Frequency, channel.DrRange.Value, _channels.size());
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 321
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 322 assert(index < (int) _channels.size());
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 323
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 324 if (index >= 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 325 _channels[index] = channel;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 326 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 327 _channels.push_back(channel);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 328 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 329
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 330 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 331 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 332
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 333 Channel ChannelPlan_AU915::GetChannel(int8_t index) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 334 Channel chan;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 335 memset(&chan, 0, sizeof(Channel));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 336
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 337 if (_channels.size() > 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 338 chan = _channels[index];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 339 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 340 if (index < 64) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 341 chan.Index = index;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 342 chan.DrRange.Fields.Min = _minDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 343 chan.DrRange.Fields.Max = _maxDatarate - 1;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 344 chan.Frequency = _freqUBase125k + (_freqUStep125k * index);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 345 } else if (index < 72) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 346 chan.Index = index;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 347 chan.DrRange.Fields.Min = _maxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 348 chan.DrRange.Fields.Max = _maxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 349 chan.Frequency = _freqUBase500k + (_freqUStep500k * (index - 64));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 350 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 351 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 352
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 353 return chan;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 354 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 355
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 356 uint8_t ChannelPlan_AU915::SetFrequencySubBand(uint8_t sub_band) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 357
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 358 _txFrequencySubBand = sub_band;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 359
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 360 if (sub_band > 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 361 SetChannelMask(0, 0x0000);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 362 SetChannelMask(1, 0x0000);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 363 SetChannelMask(2, 0x0000);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 364 SetChannelMask(3, 0x0000);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 365 SetChannelMask(4, 0x0000);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 366 SetChannelMask((sub_band - 1) / 2, (sub_band % 2) ? 0x00FF : 0xFF00);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 367 SetChannelMask(4, 1 << (sub_band - 1));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 368 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 369 SetChannelMask(0, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 370 SetChannelMask(1, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 371 SetChannelMask(2, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 372 SetChannelMask(3, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 373 SetChannelMask(4, 0x00FF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 374 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 375
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 376 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 377 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 378
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 379
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 380 void ChannelPlan_AU915::LogRxWindow(uint8_t wnd) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 381
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 382 RxWindow rxw = GetRxWindow(wnd);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 383 Datarate rxDr = GetDatarate(rxw.DatarateIndex);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 384 uint8_t bw = rxDr.Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 385 uint8_t sf = rxDr.SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 386 uint8_t cr = rxDr.Coderate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 387 uint8_t pl = rxDr.PreambleLength;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 388 uint16_t sto = rxDr.SymbolTimeout();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 389 bool crc = false; // downlink does not use CRC according to LORAWAN
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 390 bool iq = GetTxDatarate().RxIQ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 391
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 392 logTrace("RX%d on freq: %lu", wnd, rxw.Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 393 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);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 394 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 395
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 396 RxWindow ChannelPlan_AU915::GetRxWindow(uint8_t window) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 397 RxWindow rxw;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 398 int index = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 399
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 400 if (P2PEnabled()) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 401 rxw.Frequency = GetSettings()->Network.TxFrequency;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 402 index = GetSettings()->Session.TxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 403 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 404 if (window == 1) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 405 if (_txChannel < _numChans125k) {
Jenkins@KEILDM1.dc.multitech.prv 115:bcd44682ac1e 406 rxw.Frequency = _freqDBase500k + (_txChannel % 8) * _freqDStep500k;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 407 } else
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 408 rxw.Frequency = _freqDBase500k + (_txChannel - _numChans125k) * _freqDStep500k;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 409
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 410 if (GetSettings()->Session.TxDatarate <= DR_6) {
Jenkins@KEILDM1.dc.multitech.prv 104:9662b62f1977 411 index = GetSettings()->Session.TxDatarate + 8 - GetSettings()->Session.Rx1DatarateOffset;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 412
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 413 if (index < DR_8)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 414 index = DR_8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 415 if (index > DR_13)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 416 index = DR_13;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 417 } else if (GetSettings()->Session.TxDatarate >= DR_8) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 418 index = GetSettings()->Session.TxDatarate - GetSettings()->Session.Rx1DatarateOffset;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 419 if (index < DR_8)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 420 index = DR_8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 421 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 422 } else {
Jenkins@KEILDM1.dc.multitech.prv 115:bcd44682ac1e 423 rxw.Frequency = GetSettings()->Session.Rx2Frequency;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 424 index = GetSettings()->Session.Rx2DatarateIndex;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 425 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 426 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 427
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 428 rxw.DatarateIndex = index;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 429
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 430 return rxw;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 431 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 432
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 433 uint8_t ChannelPlan_AU915::HandleRxParamSetup(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 434 status = 0x07;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 435 int8_t datarate = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 436 int8_t drOffset = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 437 uint32_t freq = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 438
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 439 drOffset = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 440 datarate = drOffset & 0x0F;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 441 drOffset = (drOffset >> 4) & 0x07;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 442
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 443 freq = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 444 freq |= payload[index++] << 8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 445 freq |= payload[index++] << 16;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 446 freq *= 100;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 447
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 448 if (!CheckRfFrequency(freq)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 449 logInfo("Freq KO");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 450 status &= 0xFE; // Channel frequency KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 451 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 452
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 453 if (datarate < _minRx2Datarate || datarate > _maxRx2Datarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 454 logInfo("DR KO");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 455 status &= 0xFD; // Datarate KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 456 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 457
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 458 if (drOffset < 0 || drOffset > _maxDatarateOffset) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 459 logInfo("DR Offset KO");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 460 status &= 0xFB; // Rx1DrOffset range KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 461 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 462
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 463 if ((status & 0x07) == 0x07) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 464 logInfo("RxParamSetup accepted Rx2DR: %d Rx2Freq: %d Rx1Offset: %d", datarate, freq, drOffset);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 465 SetRx2DatarateIndex(datarate);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 466 SetRx2Frequency(freq);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 467 SetRx1Offset(drOffset);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 468 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 469 logInfo("RxParamSetup rejected Rx2DR: %d Rx2Freq: %d Rx1Offset: %d", datarate, freq, drOffset);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 470 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 471
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 472 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 473 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 474
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 475 uint8_t ChannelPlan_AU915::HandleNewChannel(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 476
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 477 // Not Supported in AU915
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 478 status = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 479 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 480 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 481
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 482 uint8_t ChannelPlan_AU915::HandlePingSlotChannelReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 483
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 484 lora::CopyFreqtoInt(payload + index, _beaconRxChannel.Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 485 index += 3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 486
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 487 if (_beaconRxChannel.Frequency != 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 488 _beaconRxChannel.DrRange.Value = payload[index];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 489 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 490 // TODO: set to default beacon rx channel
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 491 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 492
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 493 status = 0x03;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 494 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 495 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 496
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 497 uint8_t ChannelPlan_AU915::HandleBeaconFrequencyReq(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 498
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 499 status = 0x03;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 500 Channel chParam;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 501
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 502 // Skip channel index
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 503 index++;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 504
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 505 lora::CopyFreqtoInt(payload + index, chParam.Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 506 index += 3;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 507 chParam.DrRange.Value = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 508
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 509 if (!GetRadio()->CheckRfFrequency(chParam.Frequency)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 510 status &= 0xFE; // Channel frequency KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 511 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 512
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 513 if (chParam.DrRange.Fields.Min < chParam.DrRange.Fields.Max) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 514 status &= 0xFD; // Datarate range KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 515 } else if (chParam.DrRange.Fields.Min < _minDatarate || chParam.DrRange.Fields.Min > _maxDatarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 516 status &= 0xFD; // Datarate range KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 517 } else if (chParam.DrRange.Fields.Max < _minDatarate || chParam.DrRange.Fields.Max > _maxDatarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 518 status &= 0xFD; // Datarate range KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 519 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 520
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 521 if ((status & 0x03) == 0x03) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 522 _beaconChannel = chParam;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 523 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 524
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 525 if (_beaconChannel.Frequency == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 526 // TODO: Set to default
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 527 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 528
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 529 status = 0x01;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 530
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 531 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 532 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 533
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 534
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 535 uint8_t ChannelPlan_AU915::HandleAdrCommand(const uint8_t* payload, uint8_t index, uint8_t size, uint8_t& status) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 536
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 537 uint8_t power = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 538 uint8_t datarate = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 539 uint16_t mask = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 540 uint8_t ctrl = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 541 uint8_t nbRep = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 542
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 543 status = 0x07;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 544 datarate = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 545 power = datarate & 0x0F;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 546 datarate = (datarate >> 4) & 0x0F;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 547
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 548 mask = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 549 mask |= payload[index++] << 8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 550
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 551 nbRep = payload[index++];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 552 ctrl = (nbRep >> 4) & 0x07;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 553 nbRep &= 0x0F;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 554
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 555 if (nbRep == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 556 nbRep = 1;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 557 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 558
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 559 if (datarate > _maxDatarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 560 status &= 0xFD; // Datarate KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 561 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 562 //
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 563 // Remark MaxTxPower = 0 and MinTxPower = 10
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 564 //
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 565 if (power < 0 || power > 10) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 566 status &= 0xFB; // TxPower KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 567 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 568
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 569 switch (ctrl) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 570 case 0:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 571 case 1:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 572 case 2:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 573 case 3:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 574 case 4:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 575 SetChannelMask(ctrl, mask);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 576 break;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 577
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 578 case 6:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 579 // enable all 125 kHz channels
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 580 SetChannelMask(0, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 581 SetChannelMask(1, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 582 SetChannelMask(2, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 583 SetChannelMask(3, 0xFFFF);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 584 SetChannelMask(4, mask);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 585 break;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 586
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 587 case 7:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 588 // disable all 125 kHz channels
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 589 SetChannelMask(0, 0x0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 590 SetChannelMask(1, 0x0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 591 SetChannelMask(2, 0x0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 592 SetChannelMask(3, 0x0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 593 SetChannelMask(4, mask);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 594 break;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 595
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 596 default:
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 597 logWarning("rejecting RFU or unknown control value %d", ctrl);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 598 status &= 0xFE; // ChannelMask KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 599 return LORA_ERROR;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 600 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 601
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 602 if (GetSettings()->Network.ADREnabled) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 603 GetSettings()->Session.TxDatarate = datarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 604 GetSettings()->Session.TxPower = TX_POWERS[power];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 605 GetSettings()->Session.Redundancy = nbRep;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 606 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 607 logDebug("ADR is disabled, DR and Power not changed.");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 608 status &= 0xFB; // TxPower KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 609 status &= 0xFD; // Datarate KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 610 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 611
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 612 logDebug("ADR DR: %u PWR: %u Ctrl: %02x Mask: %04x NbRep: %u Stat: %02x", datarate, power, ctrl, mask, nbRep, status);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 613
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 614 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 615 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 616
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 617 uint8_t ChannelPlan_AU915::ValidateAdrConfiguration() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 618 uint8_t status = 0x07;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 619 uint8_t chans_enabled = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 620 uint8_t datarate = GetSettings()->Session.TxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 621 uint8_t power = GetSettings()->Session.TxPower;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 622
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 623 if (!GetSettings()->Network.ADREnabled) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 624 logDebug("ADR disabled - no applied changes to validate");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 625 return status;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 626 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 627
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 628 if (datarate > _maxDatarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 629 logWarning("ADR Datarate KO - outside allowed range");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 630 status &= 0xFD; // Datarate KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 631 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 632 if (power < _minTxPower || power > _maxTxPower) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 633 logWarning("ADR TX Power KO - outside allowed range");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 634 status &= 0xFB; // TxPower KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 635 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 636
Jenkins@KEILDM1.dc.multitech.prv 84:29648b580369 637 // at least 2 125kHz channels must be enabled
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 638 chans_enabled += CountBits(_channelMask[0]);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 639 chans_enabled += CountBits(_channelMask[1]);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 640 chans_enabled += CountBits(_channelMask[2]);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 641 chans_enabled += CountBits(_channelMask[3]);
Jenkins@KEILDM1.dc.multitech.prv 84:29648b580369 642 // Semtech reference (LoRaMac-node) enforces at least 2 channels
Jenkins@KEILDM1.dc.multitech.prv 84:29648b580369 643 if (chans_enabled < 2) {
Jenkins@KEILDM1.dc.multitech.prv 84:29648b580369 644 logWarning("ADR Channel Mask KO - at least 2 125kHz channels must be enabled");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 645 status &= 0xFE; // ChannelMask KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 646 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 647
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 648 // if TXDR == 4 (SF8@500kHz) at least 1 500kHz channel must be enabled
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 649 if (datarate == DR_4 && (CountBits(_channelMask[4] & 0xFF) == 0)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 650 logWarning("ADR Datarate KO - DR4 requires at least 1 500kHz channel enabled");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 651 status &= 0xFD; // Datarate KO
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 652 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 653
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 654 return status;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 655 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 656
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 657 uint32_t ChannelPlan_AU915::GetTimeOffAir()
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 658 {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 659 if (GetSettings()->Test.DisableDutyCycle == lora::ON)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 660 return 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 661
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 662 uint32_t min = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 663 uint32_t now = _dutyCycleTimer.read_ms();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 664
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 665 if (GetSettings()->Session.AggregatedTimeOffEnd > 0 && GetSettings()->Session.AggregatedTimeOffEnd > now) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 666 min = std::max < uint32_t > (min, GetSettings()->Session.AggregatedTimeOffEnd - now);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 667 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 668
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 669 now = time(NULL);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 670 uint32_t join_time = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 671
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 672 if (GetSettings()->Session.JoinFirstAttempt != 0 && now < GetSettings()->Session.JoinTimeOffEnd) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 673 join_time = (GetSettings()->Session.JoinTimeOffEnd - now) * 1000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 674 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 675
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 676 min = std::max < uint32_t > (join_time, min);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 677
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 678 return min;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 679 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 680
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 681 std::vector<uint32_t> lora::ChannelPlan_AU915::GetChannels() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 682 std::vector < uint32_t > chans;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 683
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 684 if (GetSettings()->Network.FrequencySubBand > 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 685 uint8_t chans_per_group = 8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 686 size_t start = (GetSettings()->Network.FrequencySubBand - 1) * chans_per_group;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 687 for (int8_t i = start; i < int8_t(start + chans_per_group); i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 688 chans.push_back(GetChannel(i).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 689 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 690 chans.push_back(GetChannel(_numChans125k + (GetSettings()->Network.FrequencySubBand - 1)).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 691 chans.push_back(GetRxWindow(2).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 692 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 693 for (int8_t i = 0; i < _numChans; i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 694 chans.push_back(GetChannel(i).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 695 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 696 chans.push_back(GetRxWindow(2).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 697 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 698
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 699 return chans;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 700 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 701
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 702 std::vector<uint8_t> lora::ChannelPlan_AU915::GetChannelRanges() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 703 std::vector < uint8_t > ranges;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 704
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 705 if (GetSettings()->Network.FrequencySubBand > 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 706 uint8_t chans_per_group = 8;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 707 size_t start = (GetSettings()->Network.FrequencySubBand - 1) * chans_per_group;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 708 for (int8_t i = start; i < int8_t(start + chans_per_group); i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 709 ranges.push_back(GetChannel(i).DrRange.Value);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 710 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 711 ranges.push_back(GetChannel(_numChans125k + (GetSettings()->Network.FrequencySubBand - 1)).DrRange.Value);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 712 ranges.push_back(GetRxWindow(2).DatarateIndex);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 713 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 714 for (int8_t i = 0; i < _numChans; i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 715 ranges.push_back(GetChannel(i).DrRange.Value);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 716 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 717 ranges.push_back(GetRxWindow(2).DatarateIndex);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 718 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 719
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 720 ranges.push_back(GetRxWindow(2).DatarateIndex);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 721
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 722 return ranges;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 723
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 724 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 725
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 726 void lora::ChannelPlan_AU915::EnableDefaultChannels() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 727 SetFrequencySubBand(GetFrequencySubBand());
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 728 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 729
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 730 uint8_t ChannelPlan_AU915::GetNextChannel()
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 731 {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 732 if (GetSettings()->Session.AggregatedTimeOffEnd != 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 733 return LORA_AGGREGATED_DUTY_CYCLE;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 734 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 735
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 736 if (P2PEnabled() || GetSettings()->Network.TxFrequency != 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 737 logDebug("Using frequency %d", GetSettings()->Network.TxFrequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 738
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 739 if (GetSettings()->Test.DisableDutyCycle != lora::ON) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 740 int8_t band = GetDutyBand(GetSettings()->Network.TxFrequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 741 logDebug("band: %d freq: %d", band, GetSettings()->Network.TxFrequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 742 if (band != -1 && _dutyBands[band].TimeOffEnd != 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 743 return LORA_NO_CHANS_ENABLED;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 744 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 745 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 746
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 747 GetRadio()->SetChannel(GetSettings()->Network.TxFrequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 748 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 749 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 750
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 751 uint8_t start = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 752 uint8_t maxChannels = _numChans125k;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 753 uint8_t nbEnabledChannels = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 754 uint8_t *enabledChannels = new uint8_t[maxChannels];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 755
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 756 if (GetTxDatarate().Bandwidth == BW_500) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 757 maxChannels = _numChans500k;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 758 start = _numChans125k;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 759 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 760
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 761 // Search how many channels are enabled
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 762 DatarateRange range;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 763 uint8_t dr_index = GetSettings()->Session.TxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 764 uint32_t now = _dutyCycleTimer.read_ms();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 765
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 766 for (size_t i = 0; i < _dutyBands.size(); i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 767 if (_dutyBands[i].TimeOffEnd < now || GetSettings()->Test.DisableDutyCycle == lora::ON) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 768 _dutyBands[i].TimeOffEnd = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 769 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 770 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 771
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 772 for (uint8_t i = start; i < start + maxChannels; i++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 773 range = GetChannel(i).DrRange;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 774 // logDebug("chan: %d freq: %d range:%02x", i, GetChannel(i).Frequency, range.Value);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 775
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 776 if (IsChannelEnabled(i) && (dr_index >= range.Fields.Min && dr_index <= range.Fields.Max)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 777 int8_t band = GetDutyBand(GetChannel(i).Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 778 // logDebug("band: %d freq: %d", band, _channels[i].Frequency);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 779 if (band != -1 && _dutyBands[band].TimeOffEnd == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 780 enabledChannels[nbEnabledChannels++] = i;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 781 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 782 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 783 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 784
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 785 if (GetTxDatarate().Bandwidth == BW_500) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 786 _dutyBands[0].PowerMax = 26;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 787 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 788 if (nbEnabledChannels < 50)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 789 _dutyBands[0].PowerMax = 21;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 790 else
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 791 _dutyBands[0].PowerMax = 30;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 792 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 793
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 794 logTrace("Number of available channels: %d", nbEnabledChannels);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 795
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 796 uint32_t freq = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 797 uint8_t sf = GetTxDatarate().SpreadingFactor;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 798 uint8_t bw = GetTxDatarate().Bandwidth;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 799 int16_t thres = DEFAULT_FREE_CHAN_RSSI_THRESHOLD;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 800
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 801 if (nbEnabledChannels == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 802 delete [] enabledChannels;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 803 return LORA_NO_CHANS_ENABLED;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 804 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 805
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 806 if (GetSettings()->Network.CADEnabled) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 807 // Search for free channel with ms timeout
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 808 int16_t timeout = 10000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 809 Timer tmr;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 810 tmr.start();
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 811
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 812 for (uint8_t j = rand_r(0, nbEnabledChannels - 1); tmr.read_ms() < timeout; j++) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 813 freq = GetChannel(enabledChannels[j]).Frequency;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 814
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 815 if (GetRadio()->IsChannelFree(SxRadio::MODEM_LORA, freq, sf, thres, bw)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 816 _txChannel = enabledChannels[j];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 817 break;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 818 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 819 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 820 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 821 uint8_t j = rand_r(0, nbEnabledChannels - 1);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 822 _txChannel = enabledChannels[j];
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 823 freq = GetChannel(_txChannel).Frequency;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 824 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 825
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 826 assert(freq != 0);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 827
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 828 logDebug("Using channel %d : %d", _txChannel, freq);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 829 GetRadio()->SetChannel(freq);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 830
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 831 delete [] enabledChannels;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 832 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 833 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 834
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 835 uint8_t lora::ChannelPlan_AU915::GetJoinDatarate() {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 836 uint8_t dr = GetSettings()->Session.TxDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 837
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 838 if (GetSettings()->Test.DisableRandomJoinDatarate == lora::OFF) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 839 static bool altDatarate = false;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 840
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 841 if (GetSettings()->Network.FrequencySubBand == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 842 static uint16_t used_bands_125k = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 843 static uint16_t used_bands_500k = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 844 uint8_t frequency_sub_band = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 845
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 846 if (altDatarate) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 847 // 500k channel
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 848 if (CountBits(used_bands_500k) == 8) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 849 used_bands_500k = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 850 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 851 while ((frequency_sub_band = rand_r(1, 8)) && (used_bands_500k & (1 << (frequency_sub_band - 1))) != 0)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 852 ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 853 used_bands_500k |= (1 << (frequency_sub_band - 1));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 854 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 855 // 125k channel
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 856 if (CountBits(used_bands_125k) == 8) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 857 used_bands_125k = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 858 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 859 while ((frequency_sub_band = rand_r(1, 8)) && (used_bands_125k & (1 << (frequency_sub_band - 1))) != 0)
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 860 ;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 861 used_bands_125k |= (1 << (frequency_sub_band - 1));
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 862 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 863
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 864 logWarning("JoinDatarate setting frequency sub band to %d 125k: %04x 500k: %04x", frequency_sub_band, used_bands_125k, used_bands_500k);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 865 SetFrequencySubBand(frequency_sub_band);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 866 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 867
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 868 if (altDatarate && CountBits(_channelMask[4] > 0)) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 869 dr = lora::DR_4;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 870 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 871 dr = lora::DR_0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 872 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 873 altDatarate = !altDatarate;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 874 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 875
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 876 return dr;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 877 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 878
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 879 uint8_t lora::ChannelPlan_AU915::CalculateJoinBackoff(uint8_t size) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 880
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 881 time_t now = time(NULL);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 882 uint32_t time_on_max = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 883 static uint32_t time_off_max = 15;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 884 uint32_t rand_time_off = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 885 static uint16_t join_cnt = 0;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 886
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 887 // TODO: calc time-off-max based on RTC time from JoinFirstAttempt, time-off-max is lost over sleep
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 888
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 889 if ((time_t)GetSettings()->Session.JoinTimeOffEnd > now) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 890 return LORA_JOIN_BACKOFF;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 891 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 892
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 893 uint32_t secs_since_first_attempt = (now - GetSettings()->Session.JoinFirstAttempt);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 894 uint16_t hours_since_first_attempt = secs_since_first_attempt / (60 * 60);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 895
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 896 join_cnt = (join_cnt+1) % 16;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 897
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 898 if (GetSettings()->Session.JoinFirstAttempt == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 899 /* 1 % duty-cycle for first hour
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 900 * 0.1 % next 10 hours
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 901 * 0.01 % upto 24 hours */
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 902 GetSettings()->Session.JoinFirstAttempt = now;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 903 GetSettings()->Session.JoinTimeOnAir += GetTimeOnAir(size);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 904 GetSettings()->Session.JoinTimeOffEnd = now + rand_r(GetSettings()->Network.JoinDelay + 2, GetSettings()->Network.JoinDelay + 3);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 905 } else if (join_cnt == 0) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 906 if (hours_since_first_attempt < 1) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 907 time_on_max = 36000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 908 rand_time_off = rand_r(time_off_max - 1, time_off_max + 1);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 909 // time off max 1 hour
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 910 time_off_max = std::min < uint32_t > (time_off_max * 2, 60 * 60);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 911
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 912 if (GetSettings()->Session.JoinTimeOnAir < time_on_max) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 913 GetSettings()->Session.JoinTimeOnAir += GetTimeOnAir(size);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 914 GetSettings()->Session.JoinTimeOffEnd = now + rand_time_off;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 915 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 916 logWarning("Max time-on-air limit met for current join backoff period");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 917 GetSettings()->Session.JoinTimeOffEnd = GetSettings()->Session.JoinFirstAttempt + 60 * 60;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 918 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 919 } else if (hours_since_first_attempt < 11) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 920 if (GetSettings()->Session.JoinTimeOnAir < 36000) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 921 GetSettings()->Session.JoinTimeOnAir = 36000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 922 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 923 time_on_max = 72000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 924 rand_time_off = rand_r(time_off_max - 1, time_off_max + 1);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 925 // time off max 1 hour
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 926 time_off_max = std::min < uint32_t > (time_off_max * 2, 60 * 60);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 927
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 928 if (GetSettings()->Session.JoinTimeOnAir < time_on_max) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 929 GetSettings()->Session.JoinTimeOnAir += GetTimeOnAir(size);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 930 GetSettings()->Session.JoinTimeOffEnd = now + rand_time_off;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 931 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 932 logWarning("Max time-on-air limit met for current join backoff period");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 933 GetSettings()->Session.JoinTimeOffEnd = GetSettings()->Session.JoinFirstAttempt + 11 * 60 * 60;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 934 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 935 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 936 if (GetSettings()->Session.JoinTimeOnAir < 72000) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 937 GetSettings()->Session.JoinTimeOnAir = 72000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 938 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 939 uint32_t join_time = 2500;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 940
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 941 // 16 join attempts is ~2754 ms, check if this is the third of the 24 hour period
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 942
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 943 time_on_max = 80700;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 944 time_off_max = 1 * 60 * 60; // 1 hour
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 945 rand_time_off = rand_r(time_off_max - 1, time_off_max + 1);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 946
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 947 if (GetSettings()->Session.JoinTimeOnAir < time_on_max - join_time) {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 948 GetSettings()->Session.JoinTimeOnAir += GetTimeOnAir(size);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 949 GetSettings()->Session.JoinTimeOffEnd = now + rand_time_off;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 950 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 951 logWarning("Max time-on-air limit met for current join backoff period");
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 952 // Reset the join time on air and set end of restriction to the next 24 hour period
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 953 GetSettings()->Session.JoinTimeOnAir = 72000;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 954 uint16_t days = (now - GetSettings()->Session.JoinFirstAttempt) / (24 * 60 * 60) + 1;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 955 logWarning("days : %d", days);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 956 GetSettings()->Session.JoinTimeOffEnd = GetSettings()->Session.JoinFirstAttempt + ((days * 24) + 11) * 60 * 60;
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 957 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 958 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 959
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 960 logWarning("JoinBackoff: %lu seconds Time On Air: %lu / %lu", GetSettings()->Session.JoinTimeOffEnd - now, GetSettings()->Session.JoinTimeOnAir, time_on_max);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 961 } else {
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 962 GetSettings()->Session.JoinTimeOnAir += GetTimeOnAir(size);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 963 GetSettings()->Session.JoinTimeOffEnd = now + rand_r(GetSettings()->Network.JoinDelay + 2, GetSettings()->Network.JoinDelay + 3);
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 964 }
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 965
Jenkins@KEILDM1.dc.multitech.prv 82:0f5a742a08cd 966 return LORA_OK;
Jenkins@KEILDM1.dc.multitech.prv 115:bcd44682ac1e 967 }