# Firmware Updates over the Air via LoRa: Unicast and Broadcast Combination for Boosting Update Speed
## 2 Related Work
### LoRa Protocols: MiWi and LoRaWAN  
LoRa is a proprietary radio communication technique for the physical layer (Phy), which expresses each symbol as a cyclic shifted chirp over a predefined frequency interval. Several protocols have been defined as the upper layers of LoRa, such as LoRaWAN, developed by the LoRa Alliance [6; 7], which is the most widely used one.  
LoRaWAN is a MAC layer protocol which comprises end devices, gateways, and servers, using a star topology. End devices send and receive wireless messages to/from gateways, which, in turn, communicate with the server in both directions. The gateway serves as a translator between LoRa and UDP. The server handles the entire network, processing messages and application data.  
There are different types of LoRaWAN uplink and downlink messages, such as _Joint request_, _Joint-accept_, and others [6; 7]. All messages are encrypted with AES-128. The peer's handshake and activation can be OTAA (Over The Air Activation) or ABP (Activation ByPersonalization). OTAA is the most secure and recommended method, due to its dynamic address and security key exchange. In contrast, ABP requires hardcoding a device's address and security keys in its firmware.  
The authors of [24] explored the use of wireless mesh networks based on LoRa Phy as an alternative to LoRaWAN. The paper also included an experiment with sensors across a university campus, covered by a single LoRa gateway, cooperating with a set of LoRa devices acting as routers.  
An alternative to LoRaWAN was proposed in [25], introducing several enhancements, such as synchronization capabilities in the nodes for self-initialization and self-maintenance. It also ensures reliable message delivery within scheduled time windows, employs a multi-hop routing protocol to extend communication beyond the transmission range, and dynamically adjusts the spreading factor based on the network conditions.  
MiWi, developed by Microchip, is another MAC protocol which works on top of LoRa. Its architecture includes: (a) PAN (Personal Area Network) coordinator/s, elements that start and handle the network, and (b) end devices that connect, send, and receive messages to/from coordinators, building a star, a mesh, or a P2P topology [4, 5].  
MiWi defines some fixed frames (also encrypted by AES-128), such as _Connection request_, _Connection response_, _Connection removal request_, and _Data request_, etc. The peer's handshake is easier to perform than in LoRaWAN, but it is less secure: it uses two messages, exchanged between devices with a fixed PAN Coordinator Address (usually hardcoded in the firmware).  
In the present paper, MiWi was mainly chosen for architectural reasons. The role of a LoRaWAN gateway is limited to relaying messages between the server and the end devices, but our use case required a smarter gateway able to run the logic of the OTA update, thus allowing a better comparison between the different algorithms. There is also a robustness-related reason: the gateway can coordinate the local devices, even if the connection to the server (or the server itself) fails. It is important to note that the gateway is typically linked to the same electrical circuit as the end devices, implying that both components are likely to experience failure and recovery simultaneously. Finally, the communication latency between the end devices and the gateway is lower than the delay in communicating with the server, thus allowing a slightly faster control.