*3.2. Sensor Network*

The Sensor Network component is responsible for the connections between the different sensors used to monitor the users of the system and the PERGAMON framework. The Sensor Network is running on an Android device (smartphone or tablet) and turns it into a sensor hub to which different devices can be connected.

Devices are made compatible with the PERGAMON Sensor Network via a plugin system. Each device must be categorized into a device type, such as "Pedometer", and all devices of that type must use a plugin to provide data to the server to store in the Ground Layer database in a common format. Each plugin written for the Sensor Network can have its own behaviour for obtaining the data from a device. Plugins simply operate via a common request and reply system where the custom behaviour required to interface with each device is contained purely within the plugin and hidden from other PERGAMON components. It is through this plugin architecture that the Sensor Network allows the PERGAMON framework to work with a large range of devices, as well as allowing devices to be easily supported in future. Once data is gathered from the devices connected to the Sensor Network, the data must be pushed up to the cloud once a network connection is available. Data will be held on the device and synchronised with the Ground Layer via a connection to the servers when possible, in order to allow the PERGAMON app to gather data while offline. Once the data is confirmed to be stored in the Ground Layer, the Sensor Network's role in the PERGAMON framework is complete until more data is gathered. Figure 2 presents a schematic overview of the data flow of the Sensor Network.

**Figure 2.** The data flow of the Sensor Network.

The architecture of the Sensor Network will follow a classic object oriented approach (see Figure 3). Every device will be a "PERGAMON Device" in the system, and as such all devices will have the common functionality associated with it. PERGAMON Devices will implement the very basic behaviour of request and reply handling, as well as containing the identifier for which device this class represents. On the next level in the architecture, different types of devices can be found. The three initial types are "Pedometer", "Glucometer" and "Insulin Pen". These classes define in which data format the devices will be expected to return data. Every device will fit one of these categories and more categories can be added if needed.

**Figure 3.** The architecture of the Sensor Network.

The lowest levels in the class hierarchy will be the individual device plugins. They represent actual physical devices instead of categories into which they should fit. They will define the actual behaviour that is executed when the functions defined by parent classes are called.

The architecture of the Sensor Network makes it possible to add new devices and services in an easy and modular way. Compatible sensors and services (currently the Google Fit service, Mi Fit band and Mi Fit band 2 and Menarini blood glucose sensors are supported) connected to the Sensor Network will automatically record data. The Sensor Network will gather the recorded data, process the data and push it to the Ground Layer component. The Sensor Network also provides the possibility for users to enter data manually, such as food intake, mood or sleep.
