A demo app that uses Internet of Things Platform, Context Mapping and Driver Behavior services.
With IoT for Automotive Starter app, you will experience a simulation of how Tom, an automobile owner and driver, can use a mobile app to rent a car provided by an automotive company. This new type of service will help the automotive company attract and retain customers. The design of future cars and services can be based on this new source of customer and vehicle data. You will use a mobile app on an iOS phone and experience how Tom can find an available car located near him and reserve the car. You will experience how Tom can review his driving behavior, which is analyzed by Driver Behavior service on Bluemix.
This app demonstrates how quickly you can build an app on Bluemix using Internet of Things Platform, Context Mapping and Driver Behavior services. You can follow the steps below to set up the IoT for Automotive Starter app.
You need to install a mobile app on an iOS phone to experience the simulation.
You can deploy your own instance of IoT Automotive Starter app to Bluemix. To do this, you can either use the Deploy to Bluemix button for an automated deployment or follow the steps below to create and deploy your app manually.
- Create a Bluemix Account.
Sign up for Bluemix, or use an existing account.
-
Download and install the Cloud-foundry CLI tool.
-
Clone the app to your local environment from your terminal using the following command:
git clone https://github.com/ibm-watson-iot/iota-starter-server.git
-
cdinto this newly created directory. -
Edit the
manifest.ymlfile and change the<name>and<host>to something unique.
applications:
:
disk_quota: 1024M
host: iot-automotive-starter
name: IoT-Automotive-Starter
path: .
instances: 1
memory: 640M
:
The host you use will determinate your application URL initially, for example, <host>.mybluemix.net.
- Connect to Bluemix in the command line tool and follow the prompts to log in:
$ cf api https://api.ng.bluemix.net
$ cf login
- Create Internet of Things Platform, Context Mapping and Driver Behavior service in Bluemix.
$ cf create-service iotf-service iotf-service-free IoTPlatform
$ cf create-service mapinsights free ContextMapping
$ cf create-service driverinsights free DriverBehavior
- This app uses Cloudant NoSQL DB service as well. Create the services in Bluemix.
$ cf create-service cloudantNoSQLDB Shared MobilityDB
- Push the app to Bluemix. You need to perform additional steps when it is deployed, so you must add the option --no-start argument.
$ cf push --no-start
You now have your very own instance of the IoT for Automotive Starter app on Bluemix.
Before using the IoT for Automotive Starter app, you need to set up services and install a mobile app.
Follow the steps below to make the Context Mapping and Driver Behavior services ready for use.
-
Make sure that the app is not running on Bluemix.
-
Open the Bluemix dashboard in your browser.
-
Open the Context Mapping service and wait for a few seconds until credentials show up.
-
Likewise, open the Driver Behavior service from the dashboard.
If you have not installed a mobile app on you iOS phone, follow the instructions.
-
Open the Bluemix dashboard in your browser.
-
Start the app.
Congratulations! You are ready to use your own instance of IoT for Automotive Starter app now. Open http://<host>.mybluemix.net in your browser and follow the instructions in the top page to connect your mobile app to the IoT for Automotive Starter app.
When you start your mobile app, you might see some cars around the current location in the map. They are simulated cars generated automatically by a simulation engine of the app. Instead of them, you can try with your own sensor device that can send location data by registering it to the Internet of Things Platform service.
-
In your Bluemix dashboard, open the app.
-
Stop the app.
-
Click the Environment Variables in the left bar.
-
Open USER_DEFINED.
-
Add the following variable and save it.
DISABLE_DEMO_CAR_DEVICES=true
-
In your Bluemix dashboard, open the Internet of Things Platform service.
-
Click the Launch dashboard button under Connect your devices.
-
Open the DEVICES page.
-
Delete all devices if they exist.
-
See the following IBM Watson IoT Platform pages and add your own device.
A device type for your device can be anything. If you have run the app with a simulation engine enabled, ConnectedCarDevice is already registered as a device type for simulated cars. You can either use it or create new one for your device.
-
In your Bluemix dashboard, open the Cloudant NoSQL DB service.
-
Click the LAUNCH icon.
-
Open mobilitystarterappdb database or create it if it does not exist.
-
Delete all documents in the database if they exist.
-
Create new document with the following format.
{
"_id": "<device id string>",
"deviceDetails": {
"name": "<name in string>",
"model": {
"makeModel": "<your car model in string>",
"year": <model year in number>,
"mileage": <mileage in number>,
"stars": <score in number(0-5)>,
"hourlyRate": <hourly rate in number>,
"dailyRate": <daily rate in number>,
"thumbnailURL": "<secure URL to your car image>"
}
}
}
The _id must be the device id that you have specified in the Internet of Things Platform. The other values are optional.
Now, go to your Bluemix dashboard and restart the app.
Your device is expected to publish the following event to the Internet of Things Platform.
{
"d": {
"lat": <latitude in double>,
"lng": <longitude in double>,
"trip_id": "<trip id in string>",
"speed": <vehicle speed in double (km/h)>
}
}
The lat and lng are required to show your car on a map on your mobile app. Set the location of your device as values of the lat and lng. When you record your trip route after you reserve the car, the trip_id and speed are also required. The same trip_id must be set during the reservation.
If you find a bug, please report it using the Issues section.
The primary source of debugging information for your Bluemix app is the logs. To see them, run the following command using the Cloud Foundry CLI:
$ cf logs <application-name> --recent
For more detailed information on troubleshooting your application, see the Troubleshooting section in the Bluemix documentation.
The IoT for Automotive Starter app includes code to track deployments to IBM Bluemix and other Cloud Foundry platforms. The following information is sent to a Deployment Tracker service on each deployment:
- 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
This data is collected from the VCAP_APPLICATION and VCAP_SERVICES environment variables in IBM Bluemix and other Cloud Foundry platforms. This data is used by IBM 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 we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.
Deployment tracking can be disabled by removing require("cf-deployment-tracker-client").track(); from the beginning of the app.js main server file.
IBM Bluemix
IBM Bluemix Documentation
IBM Bluemix Developers Community
IBM Watson Internet of Things
IBM Watson IoT Platform
IBM Watson IoT Platform Developers Community
