## 4 Discussion
### Mobile Application for Routing Acquired Data to the Cloud Platform  
A mobile application was developed to manage the communication between the wearable device and the IBM Cloud platform. As described above, the smartphone acts as an IoT gateway, collecting data from the smart garment, formatting them into a JSON packet, and sharing them using the MQTT protocol with the IBM Watson IoT cloud platform (Figure 19). In particular, the application is connected to the smart garment by the BLE protocol and receives data streams (Figure 16), parsing them to extract single parameters. The application arranges the data into a JSON packet and publishes it on the topic related to the smart garment using the credentials of the cloud service.  
Figure 19: Screenshots of the developed Android application: screen with the data transmitted by the developed smart garment and sent to the cloud platform with the different sections highlighted (**a**) and screen during the BLE connection phase (**b**).  
The custom application, created using the MIT App Inventor, is constituted by a single screen composed of four sections, as highlighted in Figure 19a:  
* The first section is devoted to communication with the cloud platform (yellow box);
* The second section manages the connection with the Bluetooth device (red box);
* The third section displays the data received in the last valid measurement, even storing them during the 15 min system sleep interval (purple box). Then, the formatted JSON packet containing the received data is published on the cloud;
* The last section shows the trends of the acquired parameters (blue box).  
In particular, the IBM Watson IoT platform was employed to receive the data from IoT devices; regarding the communication with the cloud, the first step consists in configuring and setting up the platform appropriately (Figure 20).  
Firstly, the credentials were set for authentication: a new device of \"smart_jacket\" typology was created and characterized by a given authentication token. To allow the device's connection with the IBM Watson platform, it is necessary to provide the user ID  
Figure 20: Views of the IBM Cloud platform: event section of the IBM Watson IoT cloud platform, where the incoming JSON packets are displayed (**a**); dashboard used to visualize the data received by the wearable device (**b**); dashboard of the IBM Cloudant database with the stored packet transmitted by the wearable device (**c**).  
(organization ID) during the creation of the user profile. By adding these parameters to the code of the developed Android app, it is possible to enable communication with the cloud platform via the MQTT protocol. Once these parameters have been set, by restarting the communication with the smart garment, it is possible to check that the developed Android application is correctly sharing data with the cloud platform through the status code at the top screen. At this point, the event section can be accessed after logging into the created user profile and selecting the registered device. The events section is shown in Figure 20a; this figure presents the data received from the device associated with the transmissions carried out by the application on the topic user, called \"sensor1\". Then, a custom dashboard for displaying the incoming data is created (Figure 20b). Lastly, the IBM Cloudant service is connected to the IBM Watson IoT platform via Historian Connector to securely store the acquired parameters (Figure 20c). As introduced above, the collected data are processed by the IBM Cloud Functions service for triggering actions based on their values. This service is based on a trigger and action mechanism, executing code sections when given events occur. In particular, the system detects the exceedance of a set of thresholds set for physiological reasons (biophysical data), regulations (gas concentrations), and significant events (falls).