The Fleet Management Starter Application for the IBM IoT for Automotive SaaS offering demonstrates how quickly you can build an app on IBM Bluemix to manage and monitor a fleet of vehicles in real time.
The Fleet Management Starter Application uses the IBM IoT for Automotive SaaS offering together with IBM Bluemix services to provide a sample solution for fleet operation management and personnel. By using the application, you can easily track and view the following information:
- Availability of a fleet of cars on a map
- Location of vehicles
- Overall health of the entire fleet
- Health diagnostics and conditions of a specific vehicle in the fleet
- Condition of vehicles by order of severity or risk
- Event history for the entire fleet
- Event history for a specific vehicle in the fleet
The Fleet Management Starter Application uses the following IBM Bluemix services:
To deploy and use the Fleet Management Starter Application, you need an instance of IBM IoT for Automotive that is deployed and running on either IBM SaaS or IBM Bluemix. To use the app with an instance of IBM IoT for Automotive on IBM Bluemix, see the following instructions: IBM for Automotive (Bluemix) - Fleet Management Starter Application.
Deploy the Fleet Management Starter Application on IBM Bluemix either automatically or manually, as outlined in the following instructions.
To automatically deploy the Fleet Management Starter Application on Bluemix, click .
The automatic deployment option creates an instance of the app and the required Bluemix services, and also binds the services to the starter app automatically. After the automated deployment, complete the following steps to configure the app to manually to connect to your IBM IoT for Automotive SaaS service.
- Open the Bluemix dashboard in your browser.
- To stop the app, click ACTIONS > Stop App.
Next: Go to Connecting to IoT for Automotive service.
To manually deploy the Fleet Management Starter Application on IBM Bluemix, complete all of the following steps:
- Log in to IBM Bluemix. If you do not have an existing Bluemix account, click Register and follow the instructions to create an account.
- Download and install the Cloud-foundry CLI tool.
- Clone the Fleet Management Starter Application to your local environment by using the following console command:
git clone https://github.com/ibm-watson-iot/iota-starter-server-fm-saas.git
- Change to the directory that you created.
- Edit the
manifest.yml
file and change the values of<name>
and<host>
to something unique.<host>
must be same withpostUrl
in gateway.properties.
applications:
:
host: iota-starter-server-fleetmanagement
name: iota-starter-server-fleetmanagement
memory: 512M
path: .
instances: 1
:
Note: The host value is used to generate your application URL, which is in the following syntax:
<host>.mybluemix.net
.
- Install the NPM package by using the following command. The installer observes the dependencies that are specified in your
package.json
file.
$ cd ./webclient
$ npm install
- Convert TypeScript to JavaScript:
$ npm run tsc
$ npm run gulp
$ cd ..
- By using the command line tool, connect to Bluemix and log in when prompted:
$ cf api https://api.ng.bluemix.net
$ cf login
- Create an instance of the Cloudant NoSQL DB service in Bluemix:
$ cf create-service cloudantNoSQLDB Lite FleetCloudantDB
- Push the starter app to Bluemix by using the following command:
$ cf push --no-start
Important: When you run the push
command, you must include the --no-start
option as you must complete further steps manually before you start the app.
Result: Your very own instance of the IBM IoT for Automotive - Fleet Management Starter Application is now deployed on Bluemix.
To run the Fleet Management Starter Application with your IoT for Automotive instance, the following two custom plugins must be deployed to your IoT for Automotive instance. The source code of the plugins is contained in plugins
folder under the Fleet Management Starter Application repository.
Plugin | Component | Description |
---|---|---|
HttpActionNotifyClient | Vehicle Data Hub (VDH) | A VDH plugin that accepts sendCarProbe requests from simulated vehicles and POSTs affected events and notified messages to the Fleet Management Starter Application. |
FleetAlert | Agent | A rule plugin that calculates fuel level from fuel tank capacity of a vehicle and remaining fuel in received probe. A fuel alert rule estimates the value to generate a fuel warning to be notified to the Fleet Management Starter Application. |
To build and deploy the plugins, complete the following steps:
- IoT for Automotive Plugin Deployment Tool has been installed on your IoT for Automotive SaaS instance. Ask an administrator of the IoT for Automotive SaaS offering if it has not been done.
- IoT for Automotive Plugin Development Tool has been installed on your eclipse IDE according to IoT for Automotive Plug-In Programmer's Guide. Ask an administrator of your IoT for Automotive SaaS offering to get the guide and tool.
- The Fleet Management Starter Application Git repository exists on your local environment. If you don't have, clone it by using the following console command.
git clone https://github.com/ibm-watson-iot/iota-starter-server-fm-saas.git
- Launch the eclipse that contains IoT for Automotive Plugin Development Tool
- Open Git perspective (Window > Perspective > Open Perspective > Other...)
- Click Add an existing local Git repository link on Git Repositories view (You can also clone the repository by selecting Clone a Git repository)
- Specify a directory that contains the Fleet Management Starter Application Git repository
- Select the Fleet Management Starter Application Git repository and click Finish
- Right click the added repository on Git Repositories view and select Import Projects...
- Select Import existing Eclipse projects and click Next
- Select
FleetAlert
andHttpActionNotifyClient
and click Finish
- Open Java perspective (WIndow > Perspective > Open Perspective > Other...) in your eclipse
- Right click the
HttpActionNotifyClient
project in Package Explorer view and select Export... - Select Java > JAR file and click Next
- Input a file name in the JAR file field and click Finish
- In the same manner, export the
FleetAlert
project as a jar file
- Download a copy of gateway.properties that has been deployed on VDH server using IoT for Automotive Plugin Deploy Tool
- Open the gateway.properties file with a text editor
- Increment
client.num
in the gateway.properties - Insert the following two lines before the DefaultHTTPClient client definition.
client.client1=com.ibm.mobility.sample.http.HttpActionNotifyClient client.client1.protocol=http
- Renumber all the existing client definition keys so as not to conflict with each other. For instance:
client.client2=com.ibm.mobility.autodrive.client.def.DefaultHTTPClient client.client2.protocol=http client.client2.agent=SM_API
- Insert the following client unique properties
Replace
HttpActionNotifyClient.postUrl=https://<your-iota-starter-fleetmanagement>.mybluemix.net HttpActionNotifyClient.postUser=starter HttpActionNotifyClient.postPassword=Starter4Iot
postUrl
with your Fleet Management app URL, and replace postUser and postPassword with the right credentials if you have changed them. - Save the changes and close the editor
A fragment of the gateway.properties file exists under conf
folder of the HttpActionNotifyClient
project. You can copy contents from the file.
- Deploy exported
HttpActionNotifyClient
jar and updated gateway.properties to a VDH server using IoT for Automotive Plugin Deploy Tool - Deploy export the
FleetAlert
jar to an Agent server - Restart IoT for Automotive components using IoT for Automotive Plugin Deploy Tool as needed
After deploying the app on Bluemix, you must configure the app to connect to your IBM IoT for Automotive SaaS service instance.
{: #config_endpoints} To connect to your IBM IoT for Automotive service instance, the starter app reads the REST API endpoints and credentials from an environment variable on Bluemix. Configure the environment variables as follows:
- Open the Bluemix dashboard in your browser.
- Open the IBM IoT for Automotive service.
- Select Runtime tab at the left navigation bar.
- Click Environment variables.
- Add the following environment variable:
USER_PROVIDED_VCAP_SERVICES = <endpoint definition in JSON format>
Define the endpoints in the following JSON format. Note that you must remove any line breaks at the end of each line to set to the environment value on Bluemix.
{
"iotforautomotive": [
{
"credentials": {
"api": <IoT for Automotive endpoint>,
"username": <user name>,
"password": <passsword>,
"maximo": {
"orgid": <organization for IoT for Automotive>
"classificationid": <classification for Vehicle Data>
"username": <user name for Maximo API >,
"password": <passsword for Maximo API >
}
}
}
]
}
To obtain the correct values, contact your system administrator.
Key | Description of Value |
---|---|
api | A URL to call the REST API for IoT for Automotive, which must end with a forward slash character (/) |
username | User name for accessing the Vehicle Data Hub (VDH) and other IoT for Automotive endpoints |
password | Password for accessing the VDH and other IoT for Automotive endpoints |
maximo/orgid | IBM IoT for Automotive Organization specified in Maximo |
maximo/classificationid | Classification for vehicle data defined in Maximo |
maximo/username | User name for accessing the Maximo API |
maximo/password | Password for accessing the Maximo API |
The IBM Secure Gateway service provides secure connectivity and establishes a tunnel between your Bluemix organization and the remote location that you want to connect to. Before you use the Secure Gateway service, contact your IBM IoT for Automotive system administrator. For more information, see Secure Gateway.
To secure the app, authentication is enabled by default for the IoT for Automotive - Fleet Management Starter Application. The default user credentials are as follows:
User name | Password |
---|---|
starter | Starter4Iot |
-
To change the user name or password that is used by the app, edit the values that are specified for the
APP_USER
and theAPP_PASSWORD
environment variables. -
To remove authentication, set both the
APP_USER
andAPP_PASSWORD
environment variables to 'none'.
- To start the Fleet Management Starter Application, open the Bluemix dashboard and start the app.
Congratulations! You are now ready to use your own instance of the IBM IoT for Automotive - Fleet Management Starter Application. To connect to the app, enter the following URL in your browser:
http://<host>.mybluemix.net
in your browser.
The starter app also provides a mobile app to connect to an OBDII dongle plugged in to your car. The mobile app sends data from an OBDII dongle to the Fleet Management Starter Application through the Watson IoT Platform service and you can see the data in the app. Complete the steps below to enable this optional feature.
- Open the Bluemix dashboard in your browser.
- Open the IBM IoT for Automotive service.
- Select Connections tab at the left navigation bar.
- Click Connect New.
- Select IBM Watson IoT Platform service, and then click Create to bind the service.
When you start the OBDII Fleet Management App for the first time, your device is automatically registered to the Watson IoT Platform service with the default device type, which is OBDII. Create a device type for your device by completing the following steps:
- Open the Watson IoT Platform dashboard on Bluemix.
- Click Device.
- Click Device Types.
- Click +Create Type.
- Click Create device type.
- In the Name field, enter 'OBDII'.
- Leave the other fields as default and click Next at the bottom right until a device type is created.
To build and install the OBDII Fleet Management App on an Android phone, see the following repository.
- For Android phone : IBM IoT for Automotive - OBDII Fleet Management App for Android.
- For iOS phone : IBM IoT for Automotive - OBDII Fleet Management App for iOS.
After deploying the Fleet Management Starter Application, start OBDII Fleet Management App on your phone.
When you start the OBDII Fleet Management App for the first time, your device is registered automatically to the IoT Platform service that you have specified in the mobile app, and a corresponding vehicle is created automatically when you connect your device to the IoT Platform.
Now that your device is connected to the Watson IoT Platform, go to the Map or Car Status page in the app and see the status.
If you no longer need a device, go to the Watson IoT Platform dashboard and delete your device manually. After you delete a device, update the vehicles in the IBM IoT for Automotive service, as follows:
- Open the Fleet Management Starter Application on your browser.
- On the left navigation bar, click Vehicle.
- On the top right side of the page, click Sync with IoT Platform.
A vehicle corresponding to deleted device must be removed from a table. Also, if you have added a device to the Watson IoT Platform manually, the vehicle is added to the table.
To report a defect with the IoT for Automotive - Fleet Management Starter Application, go to the Issues section section.
To debug problems, check the Bluemix app logs. To view the logs, run the following command from the Cloud Foundry CLI:
$ cf logs <application-name> --recent
For more information about how to troubleshoot your application, see the Troubleshooting section in the Bluemix documentation.
The IoT for Automotive - Fleet Management Starter Application includes code to track deployments to IBM Bluemix and other Cloud Foundry platforms.
For each instance that you deploy, the following information is sent to a Deployment Tracker service:
- Application name (
application_name
) - Space ID (
space_id
) - Application version (
application_version
) - Application URIs (
application_uris
) - Labels of bound services
- Number of instances for each bound service
The tracked data is collected from the VCAP_APPLICATION
and VCAP_SERVICES
environment variables in IBM Bluemix and other Cloud Foundry platforms. We use the data to track metrics around deployments of sample applications to IBM Bluemix to measure the usefulness of our examples so that we can continuously improve the content that we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service are tracked.
You can disable the Deployment Tracker service by removing require("cf-deployment-tracker-client").track();
from the beginning of the app.js
server file.