# A Testbed to Evaluate the FIWARE-Based IoT Platform in the Domain of Precision Agriculture
## 4 Testbed
### IoT Use Case Scenario
The most important is the Context Broker which makes things and resources accessible to applications and is the reference implementation for the system's other brokers. The Context Broker subscribes to the context information of the IoT Broker which mediates between the Context Broker and different Data Handling associated with different areas or management zones of the crop field. The IoT Broker uses the _discoverContextAvailability_ service of IoT Discovery in order to discover the resources associated with the things with which the Context Broker works. For our case study, all subscriptions are _onChange_: only events are generated and therefore notifications are sent to subscribers when changes occur in entity attributes. **Information Notification**  
7. Crop data is acquired by IoT devices and resources that transmit this information to the IoT Gateway where they are received by the Protocol Adapter. In Figure 3 devices use the IEEE 802.15.4/ ZigBee protocol but could use others (CoAP or RFID [35]). In fact, ProtocolAdapters hide communication protocols with physical devices from the rest of the components. The Protocol Adapter transmits the information received to Data Handling through an _updateContext_. Data Handling then notifies (_notifyContext_) the IoT Broker which, in turn, notifies the Context Broker which, in turn, passes it on to its subscribers, in our case the FMS and Cygnus-NGSI application. 8. The case of the IoT Broker is special because it must interact with the IoT Discovery component to translate notifications at resource level to the corresponding notifications at thing level sent to the Context Broker. The Cygnus-NGSI injector is another special case which is explained below. 9. Finally, the FMS application implements two Web services from the information it is supplied by the Context Broker and Cosmos. In the first service, information is published in real time as are specialised reports on the environment and status of vineyards (e.g., pest prediction) thus facilitating the taking of decision concerning irrigation, fertilisation and pest control. The second Web service is a human machine interface (HMI) enabling the remote activation of the control elements installed in crop irrigation systems. In this case, information travels in the opposite direction, the first step being the sending of control commands to the Context Broker. In short, the FMS is context aware: the information gathered from the sensors is acquired, modelled and compiled for processing following analysis and _knowledge_ extraction. This _knowledge_ facilitates decision-making and the consequent sending of activation commands to the actuators. This is possible thanks to the orchestration of IoT services provided by FIWARE allowing _resources_ associated with _devices_ to become _searchable_, _accessible_ and _usable_ thus maximising their interaction with the application of FMS. Thus, in the architecture (Figure 3) the Context Broker interoperates with the IoT broker and the IoT Data Handling that implement Publish/Subscribe components with characteristics similar to the former. Thus, a network of _brokers_ is created that allows uncoupled interaction between services that produce and consume contextual information. This is an example of the federation concept adopted by FIWARE from the IoT-A architecture (see Section 2.5). This scenario could be more complex if the physical devices used communication protocols not supported by the Protocol Adapter (e.g., MQTT). In this case the deployment of a Backend Device Management instance (GE labelled with a star in Figure 3) would be needed to address this interoperability. It can therefore be concluded that the Context Broker handles all the system's contextual information, mediating between the elements that produce that information (IoT Broker, Backend Device Management and implementation of the FMS) and the elements that consume it (IoT Broker, Backend Device Management, implementation of the FMS and Cosmos through Cygnus-NGSI).