## 7 Related Work
### Middleware Solutions for Context-Awareness in WSNs  
_Context Toolkit_[10, 11] is one of the first developed context-aware frameworks, and it aims at facilitating the development and deployment of context-aware applications. The Context Toolkit consists of context widgets and a distributed infrastructure that hosts the widgets. Context widgets provide developers the benefits of encapsulating the complexity of the sensors, abstracting context information and providing reusable and customizable building blocks of context sensing. Applications can access context information from context widgets using two methods: (i) a widget provides a set of attributes that can be queried by applications; and (ii) applications can register to be notified of context changes detected by the widget, and the widget trigger callbacks to the application when changes in the environment are detected. FamiWare follows this latter method where applications use monitoring services that subscribe to context-awareness services to reconfigure the system. The main advantage of our approach is that FamiWare implements the context related services for real devices, and especially we proof the feasibility in specific sensors with very limited capabilities as the MICAz sensors. Context-Awareness Sub-Structure (_CASS_) [12] is server-based middleware intended to support context-aware applications on hand-held and other small mobile computers. A key feature of CASS is its support for high-level context data abstraction and the separation of context based inferences and behaviors form application code. As in our approach, this separation opens the way to make context-aware applications configurable by developers. In CASS, the analysis of the context data is always done in a centralized server. Taking into account that most costly operations in WSNs are the communication tasks, this is not a good solution for systems with a high number of sensors. Then, we propose a mixed solution where the simplest contexts could be analyzed in a distributed way in small sensors, and other more complex contexts could be analyzed in higher capacity devices such as smartphones that punctually could act as a centralized node. The purpose of FamiWare is always to reduce the number of communications for detecting context changes. _C-CAST_[13] is a context management system based on a consumer-provider broker model, where providers employ a common context representation format, decoupling various entities involved in the production and consumption of context information. All communication in the system is based by exchange of Hypertext Transfer Protocol (HTTP) messages [31] using a Representational State Transfer (REST) interface [32], which allows components to be ported onto almost any networked device. Context providers are responsible for accessing and gathering context information from any kind of sensor. Context consumers may be any kind of application utilizing the context information. The context broker will forward any context changes from the context provider to the subscribed context consumer. This context broker is centralized, and then it has the same limitation as CASS. Furthermore, the system does not provide any simple way to process context information before it reaches context consumers. Instead, FamiWare provides a context-awareness service that analyzes the context information and react when a context change is detected. _MidSen_[14] is an architecture that bridges the gap between multiple applications running at application level and deployed sensor networks. MidSen has adopted a rule based engine to handle system dynamics, and makes applications flexible by allowing them to update their rules against knowledge base. MidSen middleware makes it easy to design new applications the at application layer without worrying about the details of the underlying deployed sensor network. The goal of this middleware is similar to ours. However, the authors only provide a common architecture and any particular real implementation in device sensors is given.