# Adaptive Parameters for LoRa-Based Networks Physical-Layer
## 3 Proposal
### SlidingChange: A Proposal of a Sliding Window for Automatic Parameter Changing
Window elements were relocated, and another was added at the beginning of the window. (**c**) Stage 3: Window state with element drop, displacement, and sample inclusion occurring again. ```
1 Function\(\texttt{slidingWindow}(W_{n},window)\):
2 for\(i\gets 1\)to\(W_{n}\)do
3\(window[i]\leftarrow+window[i-1]\);
4 endfor
5\(window[0]\gets sur.packet[f]\);
6 return\(window\);
```
**Algorithm 3**Sliding window of length equals to \(W_{n}\). Algorithm 4 describes the logic behind the computation of the average values. An accumulator is created and then values from all sliding window samples are added to it. This sum is then divided by the number of values added, and then the algorithm returns the result. Since the Algorithm 4 only computes the average of a set of values, the combined use of Algorithms 3 and 4 provide the computation of a moving average. Hence, Algorithm 2 uses those two algorithms and runs the tests to provide a decision regarding the change or not of the carrier frequency, according to the environmental conditions. ```
1 Function\(\texttt{moving}\texttt{average}(W_{n},window)\):
2\(arg\gets 0\)for\(i\gets 0\)to\(W_{n}\)do
4\(arg\gets arg+window[i]\)
5 endfor
6 return\(arg/W_{n}\);
```

**Algorithm 4**Moving average values for windows' length equals to \(W_{n}\). ## 4 Evaluation

During the development of this work, we deployed a small LoRa network. The network illustrated in Figure 5 comprises one primary node together with other nodes, and they form a graph with a star topology. We developed two algorithms for operating the primary (gateway) and secondary devices. Figure 6 shows the scenario under our university campus where the test was deployed. The distance between the nodes was nearly 500-700 m.

Figure 5: An example of LoRa’s network topology setup used in the tests. Figure 6: Testbed scenario. From Computer Science Department to CRITT (Technological and Innovation Center). ### Prototype

As mentioned, a testbed was created to conduct the evaluation. It is composed of LoRa nodes client/gateway prototypes and a mobile application to configure the nodes, responsible for running the experiments and collecting the measures. Figures 7 and 8 show the client and gateway node connections with details. ### Mobile App for Command and Control

To collect data from our experiments, a mobile app was built. This solution was responsible for connecting to LoRa nodes and sending and receiving data about settings and measures. Figures 9 and 10 show the main screen about sending configuration settings to the nodes. To connect to the nodes, a Wi-Fi interface from ESP32 was used. ### Results

To conduct our experiment, we created a realistic scenario comprising an ESP32 client and a gateway equipped with SEMTECH SX1276 and SX1278 modules implementing a LoRa physical layer. We established communication between the client and gateway nodes under 433 MHz and 915 MHz frequencies (as described in [14]) using two different antennas. We considered 10, 11, and 12 (we ignored 7, 8, and 9 SF values due to previous measurements and the correlation between lower SF values had implied in worse transmitter sensitivities [30]) SF values in this evaluation. Concerning bandwidth (BW), we considered the following values defined in LoRaWAN specification. We decided to use a fixed value of \(4/5\) ratio for the coding rate (CR) throughout all experiments in order to simplify the execution of the tests. Figure 6 illustrates the evaluation scenario involving communication from the Computer Science Department to the CRITT Innovation Center on the Federal University of Juiz de Fora campus. The obtained results are summarized in Table 3. Since there are correlations between SNR values for distances from 1 and 800 m, we can conclude that in the evaluated outdoor environment, measures of approximately 10 m of distance between the nodes are enough to demonstrate the need for node-aware parameter changes to improve SNR.