## 6 Application  
Once a complete model for the characterization of radiowave propagation has been developed, a real test scenario in terms of end users and potential application layer is the next goal to provide a holistic view. With this aim in mind, an Android-based application has been implemented, devoted to monitor certain environmental conditions of the campus, although the system is scalable in order to include more variables, such as social based applications or perimetral security. The system consists on a WSN of ZigBee motes and a Meshlium device. This device is a Linux based micro-PC with an \(\times\)86,500 MHz processor and 256 MB RAM memory. It also includes four wireless communication interfaces, including in our case WiFi (2.4 and 5 GHz), ZigBee and GPS. This device has been designed to operate outdoor and can be easily emplaced in many locations since its power supply may also be provided by a solar panel and a battery. Figure 19 illustrates the scenario (left top), some components of the WSN (right side) and the application interface (bottom left). Motes, in charge of ambient intelligence collection, are embedded on the trees ride of the campus and also on lampposts. They gather environmental information (temperature, atmospheric pressure, contamination levels -CO, CO\({}_{2}\), NO\({}_{2}\), O\({}_{3}\)-...) and also noise information in order to build noise maps. The information is collected periodically, following a programmable frequency, and transferred to the Meshlium, which includes a MySQL database and a web server in charge of data storing and information publishing respectively. The service oriented application developed has two main services: a PUSH alert service, and an on-demand (PULL) monitoring service. The alert service allows the definition of certain parameters to be continuously monitored so that when thresholds previously defined are reached, the system notifies this contingency to the user interested in that alert. Each of the users subscribed to this service can define as many alert profiles as deemed appropriate. If an alert is triggered, the user is immediately alerted, thanks to the PUSH conception of the service, on his/her mobile device (smartphone or tablet). The monitoring service allows users to observe environmental conditions in real time and also to analyze  
Figure 18: ZigBee wireless channel quality measurements in the considered scenario (**a**) Receiver placed at the trunk of the tree (**b**) Receiver placed within the foliage of the tree. previously happened events. Users have access to noise and contamination maps, statistics, graphical charts, periodical reports and twilight data. In its current version, the application is only available in Spanish but, thanks to its multilingual design, it is easily adaptable to other languages. In order to grant scalability, data aggregation is performed in two stages. A local stage, which is performed at each mode, concerns data gathering from all the sensors of the mode following a predetermined sequential order fixed in advance to minimize the number of sensing operations. Once each mode has collected its information, the second stage is initiated. The second stage concerns data aggregation from all the modes of the WSN, something done by means of a chain aggregation algorithm which follows a space filling curve and ensures the exchanging of a minimum number of messages. The aggregation chain is initially built at the deployment stage and remains unchanged until the one of the nodes present some kind of persistent malfunction or run out of battery. Then, a chain reconstruction algorithm is triggered, and normal operation of the network is restored. Reconstruction is a somewhat complex process that is rarely triggered. Normal operation implies that each mode only receives a message from its predecessor in the chain and only sends a message to its successor.