WoT Agent - Nestore Use Case

27 views 0

The Mobile wotAgent will run on the mobile device inside a standalone mobile App composed of these layers:

  • UI Layer: not strictly part of the wotAgent will be the human interface for the NESTORE User, a thin simple interface allowing the user to login to the NESTORE Cloud, register sensors and manage the synchronization preferences (how often, when etc.).
  • Cloud Sync and Authentication Layer: the core of the wotAgent will be responsible of writing sensors data to the NESTORE Cloud and authenticate with it to register each sensors; this layer will also operate the Sensors Interface.
  • Sensors Interface Layer: or sensors driver, will be responsible for establishing the Bluetooth communication with sensors and fetching the data.

The UI Layer will be a thin layer allowing the user to operate the wotAgent and it will not be described in this document.

Due to the requirements of the hardware communications this App and all its layers will be developed in the native code of the platform.

Sensors Interface Layer

The sensors will be collecting data inside an internal, limited memory that will have to be regularly collected through Bluetooth by the wotAgent.

The Sensors Interface Layer will manage this communication with sensors devices abstracting the process to the upper layer through a Sensor Driver SDK. This will be a passive layer: it will expose a set of operations and wait for the upper layer to trigger them:

  • Scan: search for sensors devices in range and obtain some basic information on them (ex. the device identifier).
  • Status: obtain status information from the device (ex. battery levels, current setup, etc…).
  • Setup: send configuration information to a sensor (ex. gender, weight, height of the user).
  • Fetch: obtain the data currently hold by a sensor and convert it into a native data structure.
  • Purge: free up the internal memory of the device, usually performed after a successful fetch.

Cloud Sync

The NESTORE Cloud REST services will be used by the Cloud layer to push sensors data to the Cloud and to get Authorization tokens to associate each sensor data to a NESTORE User. There are, in fact, two process performed by this layer: a classical auth/login flow, and the data synchronization.

This layer will be an active one with scheduled background processes that, after a proper initial setup, will operate even without the user interaction: the user will have to login to the NESTORE Cloud, a token will be generated and will be used for all successive HTTPS requests allowing the Cloud  to correctly associate each to the user.

A sensor registration process will be the next step of the setup: involving a SCAN for sensors and Bluetooth pairing with them for the user, eventually associating a name to it. Each sensors will then have to be configured (SETUP) with the needed information that could be provided by the user directly through the UI or obtained from the Cloud User Details as needed.

The final step of the setup for the wotAgent will be scheduling the synchronization interval with the sensors: these will require to define how often or when to wake up the device and collect it’s data. It will also be possible to trigger the synchronization manually.

During the synchronization the Sensors Layer will be operated, the data collected and pushed / written to the cloud using REST Services API: during this phase a conversion between the native data structure produced by each sensor will be converted into JSON format understood by the NESTORE Cloud and sent through a secure HTTPS connection.

Real time vs Batch synchronization

The optimal solution from the NESTORE perspective would be to receive all the sensors data in real-time and immediately push it to the cloud.

However, all the operations performed by this layer are constrained by the device limit in battery power and network resources and a real time synchronization would quickly drain the mobile device battery causing a bad user experience for the user and ultimately completely stop sending data to the Cloud.

Moreover, sensor devices may go offline unexpectedly for various reasons: out of battery, out of range, device malfunction. All these conditions, calls for a tolerance in the process of collecting and synchronizing data to the cloud.

It is imperative for the wotAgent to look and find for a compromise in battery consumption and data freshness along with reliability and fault tolerance. For this reason, all the data will be synchronized in batches from the sensors instead of continuously.

To allow the NESTORE user to monitor the situation the wotAgent will expose to the UI Layer the state of the synchronization, roughly exposing these states:

  • IDLE: no synchronization is going on
  • READING: collecting data from the sensor
  • WAITING_NETWORK: device is ready locally, waiting for network to sync it in the cloud
  • SYNCING: writing data to the cloud
  • ERROR_DEVICE: communication with device failed
  • ERROR_CLOUD: communication with the cloud failed

Other states or more precise information that we can’t anticipate right now may be also exposed to the UI.

Was this helpful?

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.