## 4 Related Work  
Programming wireless sensor networks has garnered a lot of attention due to its complexity, since it requires knowledge in multiple fields, such as distributed computing, embedded devices and wireless networks. Multiple abstractions have been released to reduce this gap, such as service-oriented, data-driven and group-based programming. The idea behind device-decoupled applications can be related to the macro-programming paradigm in wireless sensor networks [14; 15]. Macro-programming allows sensor networks to be programmed as a whole, rather than programming low-level software for individual nodes. This was a great advance in the development of sensor networks, and greatly reduced the programming efforts in large sensor networks. However, most approaches like EcoCast [16] do not focus on open standards, making their implantation in the continuous-growing IoT difficult. Our approach in Appdaptivity follows a similar philosophy to macro-programming, adapting it to current standards in the field, such as CoAP. The dependency between devices and applications could be carried to its maximum by directly moving the application logic inside the sensor networks. This approach considerably reduces the latency and the number of packets, since communications are carried out inside the Low power and Lossy Networks (LLNs) and there is no need for communications with external components. In addition, the dependency on other factors such as routing and network reliability in cloud-based applications is reduced. This paradigm is known as in-network processing. Bindings and RESTlets [17] are extensions of CoAP designed by the IDLab research group, which introduce flexible bindings between sensors and actuators and application building blocks respectively. RESTlets configure the inputs, output and some processing tasks just using CoAP on the devices enabling in-network applications which use direct binding between sensors and actuators. T-Res [18] also proposes an extension of CoAP to enable in-network applications. T-Res improves the application logic, which enables scripts for defining custom algorithms to be programmed. However, it requires the use of an embedded Python virtual machine and stores URLs of input sources and destination outputs, which can affect the performance of resource-constrained devices. These solutions optimise the device interactions and reduce the latency in its communications, nevertheless they do not leverage the changes on the environment to adapt the applications. A Distributed Data Flow (DDF) programming model to develop IoT applications for fog computing is proposed in [19]. In data flow programming, the application logic is expressed through a directed graph of nodes. Nodes define a set of inputs and outputs and an independent function which does not affect to the rest of the nodes. Thus, nodes are highly portable and reusable for the creation of user applications. DDF addresses the interconnection of cloud, edges, IO and compute nodes which comprise fog computing applications. These interconnections enable different interactions such as things-to-things, fog-to-cloud and cloud-to-fog. Thing functionality is provided through specialized nodes by domain experts. Application developers only need to focus on data flow applications. Glue.things [20] presents an IoT mashup resulting from the COMPOSE European project. Glue.things brings three tools for the application development: the device manager, the composer and the deployment manager. Device manager provides a web-based application to connect IoT devices using different protocols (HTTP, STOMP, MQTT and CoAP). Once the IoT device has been connected to the system, it is available for the composer component to create application logic using a web-based data flow model. Lastly, the deployment manager controls and deploys the mashup applications resulting from the composer component.