# Unmanned Aerial Vehicle Based Wireless Sensor Network for Marine-Coastal Environment Monitoring
## 3 SIMMA System Architecture
### Control Node  
The hardware for this device was based on the BeagleBone Black (BBB) board [46], which has an AM335x 1 GHz ARM(r) Cortex-A8 microprocessor, 512 MB of DDR3 RAM and 4 GB of 8-bit eMMC on-board flash storage. The BBB was selected, given that the control node is meant to function as a network gateway in an IoT scenario. Its communication capabilities have been augmented by integrating a custom designed cape (IoT cape), which has a built in RN4020 Bluetooth module [47], an ETRX357 Zigbee module [48], and a LoRa SX1276 transceiver [49]. With the inclusion of the IoT cape to the BBB design, an intelligent device that could manage various WSNs and link them to the IP world was created (Figure 6).  
Its programming has been implemented following a modular approach based on the Open Services Gateway initiative (OSGi) [50] (Figure 7). OSGi defines a framework where pieces of code are organized into bundles that can be managed separately (e.g., installed, updated, removed, etc.). These bundles are agents which might be dedicated to specialized tasks, such as handling a serial port  
Figure 6: Control node: BeagleBone Black and IoT cape.  
or providing a command line interface. Moreover, they communicate and interact with each other by means of services which are published within the framework, which are available to each bundle.  
Although several bundles are implemented in this application, to better understand the functionality of this device, the following must be described:  
* Peripheral and device bundles: Enable the usage of the diverse communication transceivers present in the IoT cape, publishing them in the framework. They are composed by two layers: the peripheral and the device layer. The former gives access to the ports and communication interfaces--such as GPIOs, UARTs, SPI and I2C--so that they may be accessible from the framework. The former provides the methods to configure and manage each of the transceivers;
* LoRaNET bundle: Implements the LoRaNET network layer, providing the methods to manage or connect to an existing network;
* SIMMA bundle: Defines the application layer and the main functionality of the device;
* Context Manager (CM) bundle: Manages and stores the data originating from the sensor nodes, guaranteeing its allocation in the data base, as well as its access from external systems through a Representational State Transfer (RESTful) API or the direct data processing in the platform. This same API has been enhanced to enable control, configuration and notification of events from a remote interface (external to the OSGi framework).  
Additionally, this device also functions as a UI which accesses the historical data of the sensor nodes, through the CM, to convey commands or configure the system.  
Depending on their role, the control nodes can be configured either as masters or monitors. A master node is responsible for creating and maintaining the network, assigning network addresses to the other nodes and centralizing the message traffic. The master node functionality can be summed up in two types of tasks, one for configuring the system and another for retrieving data. In the former, the master node is able to change the LoRa RF settings of the network it will create, configure the sensor nodes with these same settings and modify the sensor nodes operating configuration, mentioned in the previous section. In the latter task, the master node is able to retrieve relevant data from the sensor nodes and store it in its memory. The monitor nodes, on the contrary, may only function as information providers to the users, with the single task of reporting the activities of a master node when it is onboard the UAV without any interactions (Figure 8).  
Figure 7: Control node software architecture.