# Secure LoRa Firmware Update with Adaptive Data Rate Techniques +
## 2 Materials and Methods
### ADR Techniques  
After defining the firmware update parameters, the next step is to identify the maximum data rate that provides reliable communications. The communications setting has a substantial impact on the total time to transfer data, as shown in Table 1. We leverage the results of prior work on optimizing ADR transfers [19] by applying it to the firmware update process. The parameter search space is limited to the 13 options shown in Table 2. Note that we use all seven LoRa SF in combination with the six FSK bit rates shown in column 3. The extension here over previous ADR work to include the FSK parameters is beneficial because it enables significantly higher data rates when the devices are in close proximity. Moreover, there is no additional hardware required to enable FSK since every LoRa integrated circuit (IC) has FSK capabilities. Figure 3: The packet structures for exchanging data during the initialization phase. This work evaluates two techniques, called incremental search and binary search, which identify the optimal data rate setting using an iterative process, and a third technique that uses the received signal strength indication (RSSI) to intelligently locate the optimal communication setting. The incremental search starts by establishing communications at setting 12, and then the base station commands the device to go to setting 11. The base station listens for the device to acknowledge on setting 11, and then iterates this process decrementing the setting. It continues until the base station fails to receive an acknowledgement because the device signal strength is not sufficient at the base station. Note that the device and base station can only listen on a single setting. This type of setting discovery process adds complexity because when communications fail, the device and base station must revert back to a previous setting to re-establish communications. The base station and the device both have timeouts, as shown in Table 2, that allow them to re-synchronize if communications fail. Note that the magnitude of the timeout values are dependent on the communication setting. This is referred to as the error recovery process which initiates communications at \(S_{current}\) and \(S_{next}\) in an attempt to re-establish communications with the device. Binary search uses a methodology similar to incremental search except the next search setting is defined according to Equation (2). Here, \(S_{current}\) refers to the setting the devices last successfully communicated on and \(S_{highest,failed}\) is the highest setting that failed. \[S_{next}=S_{current}-ceil(\frac{S_{current}-S_{highest,failed}}{2}). \tag{2}\]  
The RSSI optimal search method establishes communications at the worst-case setting (setting 12) and then uses the RSSI level to intelligently select the best \(S_{next}\). The RSSI is automatically measured by LoRa ICs when they receive a valid packet so this process does not require special hardware. \(S_{next}\) is computed by Equation (3) and is derived from sensitivity specifications of FSK and LoRa (with BW=125 kHz). RSSI is measured in dBm and should be padded by reducing the measured value by the error tolerance. The hardware measurement error tolerance is 2 to 6 dBm depending on the amount of averaging used. This technique avoids the iterations needed by the other search methods but requires more communications at setting 12 to achieve a reliable RSSI value. Simulations were performed using the search algorithms associated with each technique and the convergence times are shown in Figure 4. The simulation models were configured with the following parameters: (1) bandwidth set to 125 kHz, (2) 12-symbol preamble, (3) CRC enabled, (4) implicit header enabled, and (5) error coding rate set to 5/4. The transmitted commands used to find the optimal ADR settings posses a 4-byte payload. The commands utilized to change settings are given as follows: (1) Go to ADR