Mobile App Development for the Semantic Web of Things with Punya ? Giuseppe Loseto1 , Evan W. Patton2 , Oshani Seneviratne3 , William Van Woensel4 , Floriano Scioscia1 , and Lalana Kagal2 1 Polytechnic University of Bari, 70126 Bari BA, Italy giuseppe.loseto@poliba.it, floriano.scioscia@poliba.it 2 Massachusetts Institute of Technology, Cambridge MA 02143, USA ewpatton@mit.edu, lkagal@mit.edu 3 Rensselaer Polytechnic Institute, Troy NY 12180, USA senevo@rpi.edu 4 Dalhousie University, Halifax NS B3H 4R2, Canada william.van.woensel@dal.ca Abstract. The paper presents a demo based on the Punya framework, described in the Resource Track paper titled “The Punya Platform: Build- ing Mobile Research Apps with Linked Data and Semantic Features.” Punya components have been used to develop a mobile application mon- itoring different activities of elderly people. Data are consumed and pro- duced according to the LDP-CoAP specification in order to support in- teractions in Semantic Web of Things scenarios. Submission Type: Demo | Link: http://punya.appinventor.mit.edu/ ?repo=LdpCoapTutorial Keywords: Mobile App Development · Research Apps · LDP-CoAP · Linked Data · Remote monitoring · Semantic Web of Things 1 Introduction and Motivation The United Nations estimate the worldwide prevalence of elderly people (≥ 65 years old) will increase from nearly 10% to 18% in the next 40 years, corre- sponding to over 1.8 billion units in 2060 [8]. Healthy, active aging has been acknowledged as a global healthcare, policy, social and technological challenge. A growing number of research projects focus on ambient-assisted living (AAL) to support this goal [5]. As the name suggests, in AAL automated activity recog- nition and well-being monitoring rely on a coordinated array of information and communication technologies deployed in regular life environments, including home automation networks, camera systems, and mobile and wearable sensors. Multiple data sources must be collected and analyzed continuously to assess the subject’s conditions and detect events as soon as possible, in order to activate ? Copyright ©2021 for this paper by its authors. Use permitted under Creative Com- mons License Attribution 4.0 International (CC BY 4.0). Loseto et al. timely assistance requests to caregivers in case of emergency, as well as to provide biofeedback and context-aware support to facilitate the subject’s empowerment. In AAL system architectures, smartphones act as cluster heads with respect to wearable sensors –in typical Body Area Network (BAN) configurations [3]– and devices deployed in the room, communicating through short-range low- throughput wireless links, like Bluetooth Low Energy. Processing capabilities, embedded sensors and personal information in the smartphone are exploited to integrate and enrich collected data, as well as to run data pre-processing and lightweight mining. Leveraging the Edge Computing paradigm, the mobile phone doubles as a gateway towards a back-end infrastructure, where larger volumes of information can be stored and analyzed. Research and development in the AAL sector has significant costs: custom mobile app development integrating heterogeneous Internet of Things (IoT) de- vices still requires specialized skills and non-negligible effort. Punya is a Semantic Web friendly mobile app development framework built on top of the MIT App Inventor [9], aiming to facilitate rapid prototyping and development of mobile apps. The component-based user interface composer and block-based program- ming approach grant a fully visual workflow, allowing even non-programmers to create Android mobile apps quickly and easily. Punya adds advanced capabilities to MIT App Inventor, including Linked Data (LD) reading and writing, reason- ing, and Semantic Web of Things (SWoT) [6] protocols like the Linked Data Platform over the Constrained Application Protocol (LDP-CoAP) [4]. Interop- erability both in information representation and communication enables devel- opers to leverage LD resources in mobile and ubiquitous Web scenarios. The proposed demo showcases such capabilities in a remote monitoring for healthy aging use case. 2 LDP-CoAP for remote monitoring with Punya Punya includes components to read data from several smartphone sensors, such as accelerometer, gyroscope, orientation, temperature, pressure, and light level sensors, if appropriate hardware is embedded in the phone. The platform also supports LDP-CoAP for lightweight, LD-based resource dissemination and dis- covery in SWoT dynamic ad-hoc contexts. LDP-CoAP is grounded on the LDP World Web Consortium Recommendation [7] for managing collections of Linked Data resources on the Web. However, LDP only defines resource management primitives for HTTP, leaving out Web of Things (WoT) scenarios where more lightweight application protocols are required. CoAP [1] is an IETF (Internet Engineering Task Force) application-level protocol for machine-to-machine com- munications, based on a loosely coupled stateless client/server model. LDP- CoAP [4] defines an adaptation of the LDP specification to CoAP, which allows publishing Linked Data on the WoT while preserving all LDP features. Using the LdpCoapClient Punya component, a mobile app can expose data, collected via embedded sensors or peripheral devices, as RDF resources to other parties through an LDP-CoAP server. Mobile App Development for the Semantic Web of Things with Punya Fig. 1. Remote monitoring app user interface with LD generation. As a reference example, a Punya AAL app has been developed for publishing timestamped records of Alice’s activity level as LDP resources expressed using the SAREF for eHealth Ageing Well domain ontology [2]. Figure 1 shows the application interface: the main visible component is a text box showing the latest activity level value measured by the non-visible ActivityProbeSensor component. The latter uses a simple algorithm for activity estimation based on the variance of accelerometer data. The Linked Data panel of Punya interface is filled to specify the ontology property (hasValue) and datatype (xsd:string) the text in the textbox will be automatically associated with. The textbox is nested inside a LinkedDataForm Punya component, which specifies the class the object inside the form belongs to (Measurement) and the property (relatesToMeasurement) used to link it to its parent LinkedDataForm, which represent the whole instance constructed by the app and belongs to the Motion class. Overall, for a “medium” activity level the generated RDF model looks like: @prefix saref: . @prefix ex: . ex:activity_timestamp rdf:type saref:Motion ; saref:relatesToMeasurement ex:measurement_123 . ex:measurement_123 rdf:type s4ehaw:Measurement ; saref:hasValue "medium"^^xsd:string . The application logic is in Figure 2. At screen initialization time, the base URI is set for the LDP-CoAP server collecting data. When a measurement event is triggered by the ActivityProbeSensor, the value is extracted as a string from the textbox. Then the non-visible LdpCoapClient Punya component performs a Loseto et al. Fig. 2. Remote monitoring app logic with LDP-CoAP resource upload. POST request to the server to add the new RDF Resource into the alice LDP Basic Container. The content type of the body of the request is set to Turtle, and the body itself is taken from the most external LinkedDataForm above. Finally, the unique title of the new resource consists in a keyword and a timestamp. The app can check the outcome of the request by means of methods provided by the LdpCoapClient component to get the response code, status and other fields. 3 Conclusion This paper demonstrates how mobile applications for data dissemination in Se- mantic Web of Things scenarios can be easily implemented in Punya exploiting the LDP-CoAP component. Further features in Punya, such as the LDP-CoAP resource discovery and the reasoning components, can be used to implement full-fledged applications for AAL, remote monitoring and many other domains. Punya includes comprehensive documentation, sample apps and built-in tuto- rials for getting started on rapid app development with LD and Semantic Web technologies. Punya apps can be valuable both as research tools for domain ex- perts and for end user assinstance, like in the reference healthy aging scenario. While the demo focuses on SWoT features appealing to the former target group, Punya supports graphical interface customization and task automation, enabling to improve app acceptability and user experience. Acknowledgements This work is partially supported by Italian Ministry of Economic Development R&D project BARIUM5G (Blockchain and ARtificial Intelligence for Ubiquitous coMputing via 5G). Mobile App Development for the Semantic Web of Things with Punya References 1. Bormann, C., Castellani, A.P., Shelby, Z.: CoAP: An Application Protocol for Bil- lions of Tiny Internet Nodes. IEEE Internet Computing 16(2), 62–67 (2012) 2. Girod-Genet, M.: SAREF4EHAW: an extension of SAREF for eHealth Ageing Well domain. Tech. rep., ETSI (2020), https://saref.etsi.org/saref4ehaw/v1.1.1/ 3. Hasan, K., Biswas, K., Ahmed, K., Nafi, N.S., Islam, M.S.: A comprehensive review of wireless body area network. J. Netw. and Comput. Appl. 143, 178–198 (2019) 4. Loseto, G., Ieva, S., Gramegna, F., Ruta, M., Scioscia, F., Di Sciascio, E.: Linked Data (in low-resource) Platforms: a mapping for Constrained Application Protocol. In: International Semantic Web Conference. pp. 131–139. Springer (2016) 5. Nilsson, M.Y., Andersson, S., Magnusson, L., Hanson, E.: Ambient assisted living technology-mediated interventions for older people and their informal carers in the context of healthy ageing: A scoping review. Health science reports 4(1) (2021) 6. Ruta, M., Scioscia, F., Di Sciascio, E.: Enabling the Semantic Web of Things: frame- work and architecture. In: 2012 IEEE Sixth International Conference on Semantic Computing. pp. 345–347. IEEE (2012) 7. Steve Speicher and John Arwe and Ashok Malhotra: Linked Data Platform 1.0, https://www.w3.org/TR/ldp 8. United Nations Department of Economic and Social Affairs: World Population Prospects 2019, https://population.un.org/wpp/ 9. Wolber, D., Abelson, H., Friedman, M.: Democratizing computing with app inven- tor. GetMobile: Mobile Computing and Communications 18(4), 53–58 (2015)