# Fast Deployment of a UWB-Based IPS for Emergency Response Operations
## 4 Implementation
### Software  
The software environment used to program the communication module of both the tag and the anchors is based on the _Apache Mynewt_ operating system [71], a modular real-time operating system (RTOS) for connected IoT devices. In particular, a distribution of the manufacturer itself has been employed to manage the core UWB functions, such as those belonging to the medium access control (MAC) layer or the ranging computation process itself [72].  
The processing module relies on the ESP-IDF development framework [73] as the basis of its main operations. In addition, FreeRTOS [74] is used to provide the processing module with multitasking capabilities, which are especially useful here to manage two continuous and simultaneous processes: (1) the ranging reception from the communication module and (2) the computation of positions by means of the multilateration algorithm.  
The continuous flow of rangings is first introduced into a pre-filtering process that discards erroneous or out-of-bound values. While the former are easy to detect due to a special code stamped by the communication module, the latter are identified if they surpass a threshold based on the maximum possible distance inside the outer polygon created by the deployed anchors.  
As for the multilateration process, an adaptation of the Gauss-Newton method implementation proposed in [75] has been employed. In short, the optimization function of this implementation receives a matrix with the positions of the anchors, a pointer to the distances to each anchor (i.e., the rangings), another pointer to the initial positioning values (which will be finally filled with the new position estimations), and lastly, the number of equations to solve.  
There are two parameters with a great impact on the Gauss-Newton method behaviour and performance: the maximum number of expected iterations (\(i_{\max}\)) and the targeted precision in meters (\(\hat{p}\)). More specifically, the greater the \(i_{\max}\) value and the lower the \(\hat{p}\) value, the higher the accuracy of the positioning that will be obtained. In that case, though, more computing power and/or time will be needed to estimate a new position.  
A cloud platform was also deployed to enable the visualization and facilitate the performance evaluation of the UWB-based IPS in real time. Its main elements are a webserver providing a REST API to receive the positioning information coming from the tag and an _InfluxDB_ database to store that information. Communication between the tag and the  
Figure 8: GNSS-RTK module.  
cloud platform was established by means of a websocket accessed by the tag through its WiFi module.  
For its part, the GNSS-RTK module processing unit (i.e., the Raspberry Pi) implements an automatic Python service that initiates at bootstrap. It detects each time an anchor is connected to the Raspberry Pi and then starts the self-location routine. It also communicates with the processing module of the anchor through the serial communication interface. Once the receiving time of the GNSS-RTK information has finished, it processes the positioning data, averages the received GNSS-RTK samples to obtain the final position, and sends it to the cloud via WiFi.