日本語

TUTORIAL - STEP2: Publish Sensor readout values

Table of contents

1. Introduction
2. System configuration
3. The flow of work
3.1 Works on the back-end side (part 1)
3.2 Works on the Android side
3.3 Works on the observing PC side
3.4 Works on the back-end side (part 2)
4. Restrictions
5. If something goes wrong
5.1 Want to reset the Android application settings
5.2 The Android application cannot connect to the `Broker`
5.3 An error dialog is shown while the Android application is running
5.4 Graph cannot be displayed on the web interface

1. Introduction

As the second step of a sample program which uses the Android SINETStream library, we demonstrate a little bit complex system configuration.

Android device normally equips sensor devices such like accelerometer or illuminometer, and also has means to connect to the network. Therefore, we build a system in which an Android device collects sensor readout values and periodically send them to the cloud for data visualization.

2. System configuration

In this scenario, we do not use Reader functionality. As shown in the figure below, we use an Android application “Sensor”, which works as a Writer. Along with a Broker, application server functions are used on the back-end side.

The application collects sensor readout values on the Android device, and send them as a message to the Broker via SINETStream. Then the message is processed in the back-end side for data visualization.

System model

For better readability of this tutorial, we describe details per functional elements as follows in the latter part of this document.

Please proceed along with those descriptions.

Once you went through the running environment installations, you need to fill-in the connection settings between the Android and the Broker, before actually run the Android Application. Please set parameters to fit with your network configurations.

3. The flow of work

3.1 Works on the back-end side (part 1)

We start from how to build a virtual running environment on a host machine, which can be either commercial cloud service or on your desktop computer. Then we also describe how to install, setup and operate of the server programs.

On the host machine, install the Docker Engine at first. Then execute docker run to install the container image for STEP2. Finally, start all required server programs.

Go through the companion document TUTORIAL - DOCKER-CONTAINER for the actual procedure details.

     % sudo docker run -d --name broker -p 1883:1883 -p 80:80 harbor.vcloud.nii.ac.jp/sinetstream/android-tutorial:latest

With this docker run command, installation of the back-end system and starting of server processes are automatically executed.

As for the system details on the back-end side, see the companion document The container image for the SINETStream Android tutorial.

3.2 Works on the Android side

We describe procedures such like installation, settings and operations of the Android application “Sensor”.

See the companion document TUTORIAL - Android:STEP2 for details.

3.3 Works on the observing PC side

Once the back-end system has started as mentioned above, a web server for the data visualization listens for the incoming connection. From a web browser on an observing PC, connect to the following URL.

    http://<server_address>/chart.html

For the server_address of the URL, specify the host machine which runs the container image for the back-end system. As for the port number of the web server, 80 is used as default. If you need to change it, adjust by the argument “-p” of the docker run command.

As for the topics on the web interface, such like graph layout or preferences of those elements, see the companion document TUTORIAL - A web interface for the sensor data visualization for details.

3.4 Works on the back-end side (part 2)

Once you have done this tutorial, computational resources for it must be freed. Please stop and remove the container image with the following commands.

If the Android application is still running, you will see an error dialog “EOF exception”, because the connection is closed by Broker shutdown.

     % sudo docker stop broker
     % sudo docker rm broker

Please see the companion document TUTORIAL-DOCKER-CONTAINER for details.

4. Restrictions

Because of the nature of tutorial which aims to experience the system behavior, this tutorial does not fully cover the Android SINETStream library functionalities.

If you use the Broker shown in this tutorial, beware that there are some functional restrictions as follows.

Note:
There are 3 types in vector norm calculation.

In this tutorial, we take euclidean (2-dimension) norm.

5. If something goes wrong

5.1 Want to reset the Android application settings

    Settings
    --> Apps & notifications
      --> App info
        --> Sensor
          [FORCE STOP]
          --> Storage & cache
            --> Clear storage (or CLEAR DATA)

5.2 The Android application cannot connect to the Broker

5.3 An error dialog is shown while the Android application is running

5.4 Graph cannot be displayed on the web interface