# Adaptive Parameters for LoRa-Based Networks Physical-Layer
## 3 Proposal
### InstantChange: A Simple Instant Automatic Parameter Changing  
The decision to choose the wireless spectrum concerns several metrics. For example, decisions can be taken considering the SNR and received signal power, regarding handover and QoS (Quality of Service) [15]. In IEEE 802.11 and LTE networks, the SNR and RSSI (Received Signal Strength Indication) are the main parameters supported for decision-making concerning proceeding with a handover, the bandwidth selected, and the channel configuration to be used [33]. In the context of long-range networks, there exist several sources of signal that can generate interference, deteriorate quality, and harm communication between two points. In this work, we investigate the signals collected in a real LoRa network. We used the collected data to improve an existing cognitive protocol to support the identification of the best configuration and frequency range in a given moment (scenario). Since SNR is a good physical-layer metric to evaluate the quality of the received signal, we considered  
Figure 3: Relation between BER and SNR for a LoRaTM modulation on an AWGN channel considering different SF values. the SNR metric in our proposal to make configuration changes in LoRa nodes. To achieve this goal, we present our implementation of Cognitive LoRa named InstantChange (see Algorithm 1). ```
/* Range of frequencies evaluated. */ \(F=\{433,915\}\); // Range of spread spectrum evaluated. \(SF=\{10,11,12\}\); // Range of bandwidth evaluated. 125/250 kHz for EU433 or 125/500 kHz for AU915 [31]. \(BW=\{125,250,500\}\); /* Number of control packets to send. It is responsible for sending the data to correlate parameters' values. */ \(\gamma\longleftarrow\) 9; // This variable serves to maintain the loop control. \(control\longleftarrow\) 0; /* Function responsible for obtaining the best configuration parameters based on listened SNR packets'. */ FunctionSNR_Packet(\(f,sf,bw\)): \(SNR\longleftarrow\)\(surr.packet[f][sf][bw]\); if\(SNR>\Phi\)then \(\Phi\longleftarrow\{f,sf,bw\}\);  end if return\(\Phi\); // Function responsible to receive the parameters combination FunctionRequest_SNR(\(F,SF,BW\)): foreach\(f\) in \(F\)do foreach\(s\) in \(SF\)do foreach\(bw\) in \(BW\)do \(\Phi\longleftarrow\)\(SNR\_Packet(f,sf,bw)\);  end foreach end foreach end foreach return\(\Phi\); // The main code. // First request of the best configuration \(\alpha\longleftarrow\)\(Request\_SNR(F,SF,BW)\); /* Send data packets \(gamma\) times and verify again the best parameters configuration */ whileexist packet to be senddo Send one packet using \(\alpha\) values; if\(control\leq\gamma\)then \(control=control+1\); else // Update the best configuration \(\alpha\longleftarrow\)\(Request\_SNR(F,SF,BW)\);  end if endwhile
```  
**Algorithm 1**Cognitive LoRa for two (or more) frequencies. Proposed by [14]. Algorithm 1 shows the behavior of the InstantChange core. This algorithm is responsible for performing the configuration based on network-awareness, changing the parameters of frequency, spread spectrum, and bandwidth. It is important to highlight that this algorithm considers only the current instant to perform (or not to perform) a change of configurations in the nodes. The main objective of this proposal is to maximize the SNR. Considering the intelligence behind the algorithm's logic, the variables and steps can be presented as follows: a node is responsible for sending LoRa data packets/datagrams \(\gamma\) times using the frequency, spread spectrum, and bandwidth (\(F,SF,BW\)) settings determined as the best configuration, represented for \(\alpha\). Once the number of data packets to be sent is reached, a new evaluation is carried out. To keep the parameters' values synchronized by all nodes, a control packet is generated to inform that it is necessary to change to another configuration. So, the control packet about the request is generated for each configuration of \(F,SF,BW\), using the function \(Request\_SNR\).