The Mobile Hub

The Mobile Hub is an extension of the Scalable Layer Data Distribution that acts as a middleware to allow personal mobile devices to become IoT propagator nodes

The Mobile Hub (M-Hub) is a general-purpose middleware that enables mobile personal devices (Android smartphones and tablets) to become the propagator nodes (i.e. gateways to the Internet) for the simpler IoT objects or Mobile Objects (M-OBJ) (sensors/actuators) with only short-range WPAN interfaces. It provides context information such as current local time and/or the (approximate) location to the data obtained from the M-OBJs to which it is connected. The M-Hub is the natural extension of the Scalable Data Distribution Layer (SDDL).

Basics

The M-Hub consists of four services and one manager, all executing in background. The S2PA Service is responsible of discovering and monitoring nearby M-OBJs that use the supported WPAN technologies. This service keeps a record of the current provided sensors/actuators (e.g. temperature, accelerometer, etc.). The Connection Service handles the messages that are sent to/from the Cloud in a JSON format through an Internet connection. Messages are enriched with context information, like a timestamp and the approximate location. The location is obtained by the Location Service, responsible for sampling the M-Hub’s current position.

The periodicity and duration of all of these three service’s actions, is influenced by the device’s current energy level (LOW, MEDIUM, HIGH), and is set by the Energy Manager, which from time to time sample’s the device battery level and checks if it is connected to a power source. The communication among all the services is done using an EventBus , which is a Publish-Subscribe (PubSub) event bus optimized for Android that helps to decouple the components, and allows the inclusion of different services without many code modifications.

The Mobile Event Processing Agent (MEPA) Service includes local processing of the data received from the M-OBJs. It keeps a record of the running CEP rules to be able to start and stop them. As shown in the figure below, the MEPA Service is subscribed to all the messages that are sent from the S2PA and Connection services, the former collects the data from the M-OBJs, and the latter receives commands from the cloud to modify the behavior of the MEPA Service. Every time a complex event is detected, it will be published for any interested component (e.g. connection service, or another rule in the MEPA Service).

arch.png

Usage

The M-Hub application (Android application package) requires Android >=4.3 and a Gateway. The current implementation has support for Bluetooth Low Energy as a WPAN technology, so it is also required unless you intend to include a different technology. On the settings activity of the M-Hub, you can uncheck some services/manager to disable them, also you can set the M-Hub to start at boot, the minimum allowed signal to connect or to auto-connect with any M-OBJ that it could find. Moreover, you can set some parameters specific from the different services than are going to be explained later on.

- Start the gateway with the public IP, port and DDS product (e.g. $ gateway 127.0.0.1 5500 OpenSplice)
- Instantiate a processing node
- Configure the M-Hub parameters that are shown in the images below
- Start the M-Hub with the play button, or remove previous configurations with the delete button

mhub1.png

Once the M-Hub is started, it will start scanning for devices under the supported technologies, and connect to them if auto-connect is enabled. The information obtained from the devices can be visualized in the viewer and events activity that are shown below. The application can be stopped at any moment by pressing the stop button.

Receiving Messages from the M-Hub

Once the M-Hub is connected with a gateway, it will start sending some information that can be used for further processing. Such information is in JSON format and are of three types: LocationData that samples the current location of the M-Hub, SensorData which is the raw sensor values obtained from the M-OBJs, EventData that describes events obtained from doing some processing over the sensor data, and ErrorData/ReplyData that came from a component with a message. Some examples are:

{
  "tag": "LocationData", 
  "uuid": "b06de58d-6a20-44f9-8cd4-83f074c2edd6", // M-Hub UUID
  "latitude": -22.98137128,
  "longitude": -43.23421961,
  "battery": 50,
  "charging": false,
  "timestamp": 1442169467 
}

{
  "tag": "SensorData", 
  "uuid": "b06de58d-6a20-44f9-8cd4-83f074c2edd6",  // M-Hub UUID
  "source": "00000000-0000-0000-0001-bc6a29aecef5", // M-OBJ UUID
  "action": "found|connected|disconnected|read", 
  "signal": -48,
  "sensor_name": "Temperature",
  "sensor_value": [21.70,23.42],
  "latitude": -22.98137128,
  "longitude": -43.23421961,
  "timestamp": 1442169467 
}

{
  "tag": "EventData", 
  "uuid": "b06de58d-6a20-44f9-8cd4-83f074c2edd6", // M-Hub UUID
  "label": "AVGTemp",
  "data": {"value": 22.30},
  "latitude": -22.98137128,
  "longitude": -43.23421961,
  "timestamp": 1442169467 
}

{
  "tag": "ErrorData|ReplyData", 
  "uuid": "b06de58d-6a20-44f9-8cd4-83f074c2edd6", // M-Hub UUID
  "component": "MEPAService|S2PAService",
  "message": "Action not supported.",
  "latitude": -22.98137128,
  "longitude": -43.23421961,
  "timestamp": 1442169467 
}


An implementation example of a processing node receiving information from the M-Hub can be found in: Simple Server

Authors

* MSc. Luis Talavera Ríos
* Prof. Dr. Francisco José da Silva e Silva
* Prof. Dr. rer. nat. Markus Endler

License

The Mobile Hub

Copyright (C) 2016 PUC-Rio/Laboratory for Advanced Collaboration

The Mobile Hub is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

The Mobile Hub is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with the Mobile Hub. If not, see http://www.gnu.org/licenses/.