Publishing GPS
Data to the Cloud

Overview

In this example, you will use Eclipse to create a
stand-alone MQTT client in Java that simulates an actual device publishing data
to the Everyware Cloud. It builds on the example described in Connecting to the Cloud in Java by illustrating
how to publish GPS data using the Everyware™ Cloud Communication Data Model. This
example uses a GPS simulator to create a changing GPS position.

Import Java Client GPS Project

In Eclipse select File | Import, if you have not already
imported the “edc-java-client-gps” project. Select “General | Existing
Projects into Workspace,” then click Next. Click Browse for the
root directory, and browse to the workspace location of the cloud examples that
were downloaded and installed previously. Select the “edc-java-client-gps”
project folder, but do not enable the checkbox “Copy projects into
workspace” (the projects are already in the workspace location). (If you wish,
you may import all projects, but this tutorial will only discuss the Java
client GPS project.) You may add the project to a working set if desired.
Then click Finish.

You should now have the “edc-java-client-gps” project in
your workspace.

NOTE: If you delete the project out of the workspace later,
you should not “Delete project contents on disk.” This is because we
have used the Maven install procedures to setup the projects directly into your
Eclipse workspace location. If you do delete the contents on disk, you would
need to create a new workspace and re-download the source code from Eurotech’s
software repository, as described in Setting up
Eclipse Environment for Java.

Set Publisher Variables

Toward the top of the code example, there are several
variables noted with comments that are specific to your Cloud user account.
These variables need to be modified according to your Cloud account
credentials, so the Java client can connect properly. See the section Accessing your Cloud Account to set up an
account in Everyware Cloud.

In the sample code, set the following variables with the
proper settings of your Cloud broker account, and save changes:

Using Java Client GPS Application

The following sections describe the Java Client GPS application
and give portions of the relevant code. See the full Java source code for more
details on the program operation.

Starting
Cloud Connection

After the client variables have been modified, make a
connection to the Cloud by selecting the Run menu, and the option “Run” or “Run
as...Java Application”. You can also select the green Run button in the Launch toolbar.

If you have the proper credentials and have entered them
correctly in the code, you should see the debug statements in the Java Console
that indicate you have made a successful connection.

Viewing the Data

You can view the data published by this example in real-time
using a sample dashboard built with Google Chart Tools and the EDC Comet API. You
should have already downloaded the edc-comet-gps
example available on the GitHub repository at https://github.com/eurotech/edc-examples/.

In your workspace under edc-comet-gps/src/main/webapp, open
the file index.html using
the Firefox or Safari Web browser. Enter the Cloud account credentials used earlier
in Set Publisher Variables.

The following screen capture shows the dashboard.

For additional details about using your Everyware Cloud
account as a data source for Google Charts, see the section on Google Chart Tools Support. For
additional details about the EDC Comet API, see the section on Asynchronous REST/Comet API. You are encouraged
to explore these powerful capabilities for use in your application.