# Firmware Updates over the Air via LoRa: Unicast and Broadcast Combination for Boosting Update Speed
## 6 Implementation and Tests with Real Hardware
### System Architecture and Hardware Implementation of the System Elements  
The system architecture corresponds to a typical one employed in this kind of scenario. In contrast to LoRaWAN, in our case, the gateway implements some of the functions: for example, it can receive commands from the nodes and forward them to other ones, without requiring communication with the server. It has three main blocks (see Figure 20):  
1. Node layer. The main element of the node is the Microchip WLR089U0 module, based on the ATSAMR34J18 LoRa integrated circuit. The PCB also includes a 32-bit ARM Cortex-M0+ processor with 256 KB of Flash and 40 KB of SRAM. It runs a firmware (roughly 150 KB) able to communicate with the gateway, and also with some sensors able to measure different magnitudes. An external flash non-volatile memory of 512 KB (SST25 PF040C) is also added to the PCB via SPI protocol, which is the place where the new firmware is allocated. They can be considered as _Low-end Class_ 2 devices [1]. No Operating System is used.
2. Network layer. The gateway is an SOM (System On Module) based on Microchip ATSAMA5d27-wlsm1, which runs an embedded Linux as Operating System. It includes a WLR089U0 module connected via UART, working as the PAN Coordinator of the LoRa network. In addition, the SOM platform has an Ethernet and a Wi-Fi card, which provide connectivity to the server. A Mosquito MQTT broker provides connectivity between the gateway and the server.
3. Server layer. It integrates different elements: a back-end server which interacts with a database and a web application where the user can control the gateway and the nodes to launch the OTA updates.  
The nodes are associated to the gateway following a star topology. In normal conditions, the gateway periodically requests new samples from them. These samples may include the data measured by the DALI driver (temperature and power consumption, etc.) or by other sensors attached to the ATEX luminaire. The format of the LoRa frames is detailed in Appendix A. When an OTA update is to be performed, this process can be interrupted to leave all the available airtime for the update.  
Two photographs of the node, inside an ATEX enclosure, are presented in Figure 21: the PCB, the DALI driver, the emergency module, and the backup batteries can be seen in Figure 21a. A detail of the other side is presented in Figure 21b, where the LED stripe can be observed, in addition to the enclosure of a presence node and the LoRa antenna.  
Figure 20: Architecture of the system.  
Two photographs of the gateway are presented in Figure 22. As can be observed, it includes the SOM at the bottom and two PCBs (for simultaneously operating in two channels).  
Figure 21: Images of the node: (**a**) the side where the PCB, the DALI driver, and other elements are placed; and (**b**) detail of the opposite side: LED stripe, LoRa antenna, and presence sensor enclosure.  
Figure 22: Images of the gateway: (**a**) the side where two PCBs are placed; and (**b**) opposite side: two LoRa antennas.