Integration: IBM Bluemix
Learn how to configure IoTIFY's network simulator to connect virtual devices to IBM Bluemix via IBM's MQTT broker.
IBM Bluemix is a cloud service that offers, among other things, an IoT platform that lets IoT devices connect and send data that can later be analyzed using IBM cloud services. This IoT platform offers a REST API as well as an MQTT broker interface. In this tutorial we will learn how to set up IBM Bluemix and connect to it using our network simulator.
Before starting, sign up for a free Bluemix account at https://www.ibm.com/cloud-computing/bluemix/, and then log in to your account. You will be asked to create an organization and a space: follow the instructions and then you will be taken to your account’s dashboard. Click Catalog in the top menu, then Internet of Things under the Services section in the left menu, and then Internet of Things Platform:
Now you have to create a service: insert a name for the service (for example: IoTIFY) and then click Create; then, on the welcome page click Launch.
Once the service is launched, the next step is to create e-device: on the left menu, click Devices and then click the Add Device button.
Every device has a type, so the first time you create a device you need to create a type of that device, and then associate the device to that type: click on Create device type, then enter a name for your type and click Next.
You can optionally define template data or add metadata to the device type, but this is not mandatory, and you can simply skip these steps when creating the device type.
After you created a device type, it appears in the drop-down menu in the device creation page, so it can be selected as the type associated with the device you are creating. The only mandatory data to insert a new device is the device ID: choose an ID for your device, then go through the following steps and finally click Add.
The next screen shows all the info for your device, including an authentication token: take note of this token now, since it will be needed when setting up the IoTIFY network simulator:
The setup phase in IBM Bluemix is completed: now it’s time to send data to it from our network simulator.
First, create a new template, give it a name of your choice (for example, IBMbluemix) and select MQTT as network connection type; then, in the MQTT parameters section select MQTT (TCP) as protocol, and a URL with the format <org-id>.messaging.internetofthings.ibmcloud.com as Endpoint, where <org-id> is the identifier of your organization in your IBM Bluemix account: you can find this information on the top left of your IoT Platform dashboard, right next to your account info.
Then, as ClientID you have to insert a string with the format d:<org-id>:<device_type>:<device_id>, where <org-id> is the same as above, <device_type> is the name of the device type associated to your device in IBM IoT Platform, and <device_id> is the identifier of your device. Finally, you have to supply authentication credentials: insert “use-token-auth” as username, and the authentication token assigned when you created your device as password:
The topic of the MQTT messages sent by the devices must be of the form iot-2/evt/<event_id>/fmt/json , where <event_id> is a name of your choice that identifies the events published by a device. As for the message contents, they must be formatted in JSON and must contain a single top-level property called d. For example:
Save your template, then you are all set up to send data to IBM Bluemix.
Launch a new simulation, and as your virtual devices start sending MQTT messages you will be able to see your generated data in the IBM IoT Platform dashboard: click on your device in the dashboard, and you will see events as they come in from our simulator:
Clicking on an event will show you the corresponding message contents, generated by the simulator according to your template:
That’s it! Enjoy using our network simulator with IBM Bluemix!