## 3 The Proposed Semantic Internet of Things Middleware  
The proposed Semantic IoT Middleware (SIM) seamlessly integrates semantic annotation capabilities, blockchain technology, and AI-powered feedback mechanisms. The middleware harnesses the security and decentralised advantages of blockchain to manage and store semantic annotations, ensuring data integrity and protection from unauthorised modifications. Additionally, the embedded AI Feedback and Analysis Module employs advanced artificial intelligence techniques, focusing on refining the quality and usability of semantic annotations through user feedback and system events. As a result, end users, applications, and third parties, such as health monitoring apps, emergency response teams, and healthcare data analytics providers, benefit from secure, transparent, and meaningful access to users' IoT devices. The architecture of the middleware is depicted in Figure 1 and detailed below:  
1. **IoT Data and Event Generation Module**: Constitutes the data and event sources in the IoT system, which may be varied, i.e., diverse types, capabilities, protocols, formats, locations, and domains. 2. **Semantic Annotation Component**: Processes and attributes common vocabulary and structure to data and events sourced from the IoT module. It leverages a semantic annotation model for defining concepts, properties, and relationships pertinent to the IoT domain, with an annotation tool that either automatically or semi-automatically assigns semantic annotations. 3. **Data Security and Encryption Module**: This component, placed after the Semantic Annotation Component, ensures the secure transition of data to the blockchain network. It handles encryption and decryption of data and events, authentication and authorisation of users and applications, and digital signing and verification of semantic operations. It interacts with the Blockchain Component to secure the storage and retrieval of semantic annotations. It also optimises lightweight and efficient security protocols and algorithms compatible with the IoT environment. * **Blockchain Component**: Stores and manages semantic annotations in a distributed, decentralised manner. It incorporates a blockchain network comprising multiple nodes that maintain a shared ledger of transactions, with each transaction containing a verified and validated semantic annotation. It ensures the security, integrity, and trustworthiness of the semantic annotations, mitigating unauthorised access and modification. * **Semantic Query Module**: Enables discovery and access of blockchain-stored semantic annotations, utilising a semantic query language for expressing user and application information needs based on concepts, properties, and relations defined in the semantic annotation model. It uses a semantic query engine to process and execute semantic queries over the blockchain network and return relevant results. * **Semantic Analysis and Inference Engine**: Analyses and infers from semantic annotations stored on the blockchain network, utilising logical rules and algorithms to derive new knowledge and insights from the semantic annotations. It employs AI and deep learning techniques to enhance reasoning capabilities and tackle complex and uncertain scenarios. * **Service Integration and Composition Module**: Facilitates integration and composition of IoT services and applications based on the semantic annotations in the blockchain network. It uses a semantic service model to define functionalities, inputs, outputs, and parameters of various IoT services and applications. It also uses a semantic service discovery and composition tool to automatically or semi-automatically find and combine suitable IoT services and applications according to their semantic descriptions and user requirements. * **Semantic Visualisation Component**: Provides graphical and interactive representations of semantic annotations, queries, reasoning, and services.