Ibm Internet of Things
Ibm Internet of Things
Ibm Internet of Things
Release 1.0
David Parker
Getting Started
Concepts
Feature Overview
Quickstart
Register
13
23
25
31
47
Application
49
57
65
69
71
75
87
97
101
105
111
113
117
123
23 MQTT
127
24 Device Model
131
137
139
27 Contribute
143
ii
Welcome to the documentation/reference material for IBMs IoT Platform service. If you are looking for tutorials you
can find them on developerWorks Recipes.
Getting Started
Getting Started
CHAPTER 1
Concepts
1.1 Organizations
When you register with the Watson IoT platform you are given an organization ID, this is a unique 6 character identifier
for your account.
Organizations ensure your data is only accessible from your devices and applications. Once registered, devices and
API keys are bound to a single organization. When an application connects to the service using an API key it registers
with the organization that owns the API key.
For your security it is impossible for cross-organization communication within the Watson IoT platform eco-system,
intentional or otherwise. The only way to transmit data between two organizations it to explicitly create two applications, one within each organization, that communicate with each other to act as a relay between the organizations.
1.2 Devices
A device can be anything that has a connection to the internet and has data it wants to get into the cloud.
A device is not able to directly interact with other devices.
Devices are able to accept commands from applications.
Devices uniquely identify themselves to the Watson IoT platform with an authentication token that will only be
accepted for that device.
Devices must be registered before they can connect to the Watson IoT platform.
1.3 Applications
An application is anything that has a connection to the internet and wants to interact with data from devices
and/or control the behaviour of those devices in some manner.
Applications identify themselves to the Watson IoT platform with an API key and a unique application ID.
Applications do not need to be registered before they can connect to the Watson IoT platform, however they
must present a valid API key that has previously been registered.
1.5 Events
Events are the mechanism by which devices publish data to the Watson IoT platform. The device controls the content
of the event and assigns a name for each event it sends.
When an event is received by the Watson IoT platform from a device the credentials of the connection on which the
event was received are used to determine from which device the event was sent. With this architecture it is impossible
for a device to impersonate another device.
Devices are unable to receive events, regardless of whether they are its own events or those of another device.
Applications are able to process events from devices in real time. When an application receives an event it
has visibility of the source of the event and the data contained in that event. Applications can be configured to
subscribe to all events from all devices, a subset of events, a subset of devices or a combination of these events.
Chapter 1. Concepts
Warning: Historical event storage uses an MQTT Quality of Service level of 0 (delivery at most once), so some
data may be lost.
1.6 Commands
Commands are the mechanism by which applications can communicate with devices. Only applications can send
commands, which must be issued to specific devices.
The device must determine which action to take on receipt of any given command, and even controls which commands
it will subscribe to in the first place. It is possible to design your device to listen for any command, or to simply
subscribe to a set of specific commands.
1.6. Commands
Chapter 1. Concepts
CHAPTER 2
Feature Overview
2.2 Connectivity
Securely connect your devices, gateways and applications directly to the Watson IoT platform via MQTT. See the
section on MQTT in the reference material to learn more about the advantages of using this protocol. Model the data
from your device as events and control the flow of events into your applications.
services without ever leaving the comfort of the Watson IoT platform APIs.
Important: This feature is currently available as part of a limited beta. Future updates may include changes incompatible with the current version of this feature. Try it out and let us know what you think
2.6 Historian
Configure the Watson IoT platform to store a record of the events your devices generate.
Warning: Message format restrictions apply to the Historian
The historian feature only supports JSON messages meeting specific critera:
The message must be a valid JSON object (not an array) with only two top level elements: d and ts
The message must be UTF-8 encoded
Data
The d element is where you include all data for the event (or command) being transmitted in the message.
This element is required for your message to meet the Watson IoT platform message specification.
This must always be a JSON object (not an array)
In the case where you wish to send no data the d element should still be present, but contain an empty object.
Timestamp
The ts element allows you to associate a timestamp with the event (or command). This is an optional element, if
included its value should be a valid ISO8601 timestamp.
Example
{
"d": {
"host": "IBM700-R9E683D",
"mem": 54.9,
"network": {
"up": 1.22,
"down": 0.55
},
"cpu": 1.3,
},
"ts": "2014-12-30T14:47:36+00:00"
}
CHAPTER 3
Quickstart
Quickstart is an open sandbox allowing developers to quickly and easily get devices connected to the Watson IoT
platform with registration required. Any device that can run an MQTT client can be connected to Quickstart within
mimimum fuss, DeveloperWorks Recipes features dozens of community produced tutorials for connecting different
devices to the service, including but not limited to:
OpenBlocks IoT BX1G
Reactive Blocks
10
Chapter 3. Quickstart
Now, as you adjust the sensor values in your simulated device you will be able to see the data from your device
visualized in real time in the Quickstart application.
11
Leave that process running, it is now time to turn your attention towards creating your device. We will connect a
device of type mosquitto and send two events to the service using mosquitto_pub:
Returning to your application terminal you should see the two events that you published almost instantly:
Thats all there is to it. You have successfully connected a device and an application to the Watson IoT platform over
MQTT, sent an event from the device to the service and recieved that event in your application.
12
Chapter 3. Quickstart
CHAPTER 4
Register
Registering for an account on the Watson IoT platform and connecting your first device is simple and will take less
than 10 minutes to complete.
13
Note: Data sovereignty is the concept that information which has been converted and stored in binary digital form is
subject to the laws of the country in which it is located.
The region your Watson IoT platform instance will be provisioned in will be determined by the Bluemix region you
are using. You can switch Bluemix regions via the controls in the top right corner of the Bluemix dashboard. You can
also determine which region are currently have selected by the URL in your browser:
United Kingdom: console.eu-gb.bluemix.net
United States: console.ng.bluemix.net
14
Chapter 4. Register
After a short delay you will find yourself the proud owner of an organization on the IBM Watson IoT platform.
15
can all agree its preferable not to have to do this, so lets promote you to a permanent member of the organization.
In the navigation menu select Access and then Guests, you should see the e-mail address you signed up to Bluemix
with in there and the expiration date for your session. Click the Promote button to set yourself up as a permanent
member of the organization, your ID will disappear from the list, and can now be found under Access > Members.
Now we have an API key we want to run an application, the simpler the better.
Note: The Watson IoT platform has client library support for multiple languages, but for the purpose of this getting
16
Chapter 4. Register
started tutorial were going to stick with Python. If you dont already have Python installed now is the time to do so.
Install the latest version of the Watson IoT platform python client library using pip
[root@host ~]# pip install ibmiotf
Now, create a really simple application that will connect using the API key you just created:
import
import
import
import
import
signal
time
sys
json
ibmiotf.application
def myEventCallback(myEvent):
print("%-33s%-32s%s: %s" % (myEvent.timestamp.isoformat(), myEvent.device, myEvent.event, json.dump
def interruptHandler(signal, frame):
client.disconnect()
sys.exit(0)
options = {
"org": "<INSERT_ORGANIZATION_ID>",
"id": "MyFirstApplication",
"auth-method": "apikey",
"auth-key": "<INSERT_API_KEY>",
"auth-token": "<INSERT_AUTH_TOKEN>"
}
try:
client = ibmiotf.application.Client(options)
client.connect()
except Exception as e:
print(str(e))
sys.exit()
print("(Press Ctrl+C to disconnect)")
client.deviceEventCallback = myEventCallback
client.subscribeToDeviceEvents()
while True:
time.sleep(1)
When you launch the application you will see nothing overly exciting
[user@host ~]$ python test.py
(Press Ctrl+C to disconnect)
2015-12-19 00:04:28,827
ibmiotf.application.Client
INFO
17
Now its time to register a device of this type, navigate to Devices > Browse and click Add Device, select
the python-sample device type that we just created and click Next. On the second panel enter a device ID of
MyFirstDevice and click Next to continue through the guided creation process until you reach the Add button.
Once you click Add your device is registered and you will be presented with a generated authentication token
for that device.
18
Chapter 4. Register
Were now going to take that authentication token and write a totally minimal device client in python.
import
import
import
import
time
sys
ibmiotf.application
ibmiotf.device
deviceOptions = {
"org": "<INSERT_ORG_ID>",
"type": "python-sample",
"id": "MyFirstDevice",
"auth-method": "token",
"auth-token": "<INSERT_AUTH_TOKEN>"
}
try:
deviceCli = ibmiotf.device.Client(deviceOptions)
except Exception as e:
print("Caught exception connecting device: %s" % str(e))
sys.exit()
deviceCli.connect()
for x in range (0,10):
data = { 'hello' : 'world', 'x' : x}
deviceCli.publishEvent("greeting", "json", data)
time.sleep(1)
deviceCli.disconnect()
INFO
INFO
INFO
INFO
INFO
19
Returning to the terminal where your application is running you will be able to see the application is recieving and
processing the events submitted by your device in real time.
[user@host ~]$ python test.py
(Press Ctrl+C to disconnect)
2015-12-19 00:34:27,865
ibmiotf.application.Client INFO
2015-12-19T00:34:57.687199+00:00 python-sample:MyFirstDevice
2015-12-19T00:34:58.770336+00:00 python-sample:MyFirstDevice
2015-12-19T00:34:59.686953+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:00.687080+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:01.687707+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:02.687834+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:04.393050+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:04.688588+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:05.689215+00:00 python-sample:MyFirstDevice
2015-12-19T00:35:06.688842+00:00 python-sample:MyFirstDevice
Finally, if you return to the Watson IoT platform dashboard and scroll down to Device Events you will be able to
see all the events that you just sent.
You can also examine the content of any of the events by selecting an event from the table.
20
Chapter 4. Register
21
22
Chapter 4. Register
CHAPTER 5
The IoT Platform API can be used to interact with your organization in the IoT Platform.
23
24
CHAPTER 6
Note: The IoT Platform requires TLS v1.2. We suggest the following cipher suites: ECDHE-RSA-AES256-GCMSHA384, AES256-GCM-SHA384, ECDHE-RSA-AES128-GCM-SHA256 or AES128-GCM-SHA256 (as of Jun 1
2015).
25
a:org_id:app_id
a indicates the client is an application
org_id is your unique organization ID, assigned when you sign up with the service. It will be a 6 character
alphanumeric string.
app_id is a user-defined unique string identifier for this client.
We do not impose any rules on the app_id component of the client ID
When connecting to the Quickstart service no authentication is required
An application does not need to be registered before it can connect
Note: Only one MQTT client can connect using any given client ID. As soon as a second client in your organization
connects using an app_id that you have already connected the first client will be disconnected.
26
27
28
29
30
CHAPTER 7
7.1 Constructor
The constructor builds the client instance, and accepts an options dict containing the following definitions:
org - Your organization ID.
id - The unique ID of your application within your organization.
auth-method - Method of authentication (the only value currently supported is apikey).
auth-key - API key (required if auth-method is apikey).
auth-token - API key token (required if auth-method is apikey).
If no options dict is provided, the client will connect to the IoT Platform Quickstart, and default to an unregistered
device. The options dict creates definitions which are used to interact with the IoT Platform module.
import ibmiotf.application
try:
options = {
"org": organization,
"id": appId,
"auth-method": authMethod,
"auth-key": authKey,
"auth-token": authToken
}
client = ibmiotf.application.Client(options)
except ibmiotf.ConnectionException as e:
...
31
client = ibmiotf.application.Client(options)
except ibmiotf.ConnectionException as e:
...
32
client.connect()
client.subscribeToDeviceEvents(deviceType=myDeviceType, deviceId=myDeviceId, event=myEvent)
client.subscribeToDeviceEvents(deviceType=myOtherDeviceType, deviceId=myOtherDeviceId, event=myEvent)
33
event.deviceId - string
event.event - string
event.format - string
event.data - dict
event.timestamp - datetime
import ibmiotf.application
options = ibmiotf.application.ParseConfigFile(configFilePath)
client = ibmiotf.application.Client(options)
def myEventCallback(event):
str = "%s event '%s' received from device [%s]: %s"
print(str % (event.format, event.event, event.device, json.dumps(event.data)))
...
client.connect()
client.deviceEventCallback = myEventCallback
client.subscribeToDeviceEvents()
34
35
client.deviceStatusCallback = myStatusCallback
client.subscribeToDeviceStstus()
Refer to the Organization Configuration section of the IBM IoT Platform API for information about the request &
response model and http status code.
36
37
38
39
client = ibmiotf.application.Client(options)
try:
deviceTypeInfo = client.api.getDeviceType("myDeviceType")
except IoTFCReSTException as e:
print("ERROR [" + e.httpcode + "] " + e.message)
40
The response contains parameters and application needs to retrieve the dictionary results from the response to get
the array of devices returned. Other parameters in the response are required to make further call, for example, the
_bookmark element can be used to page through results. Issue the first request without specifying a bookmark, then
take the bookmark returned in the response and provide it on the request for the next page. Repeat until the end of
the result set indicated by the absence of a bookmark. Each request must use exactly the same values for the other
parameters, or the results are undefined.
In order to pass the _bookmark or any other condition, the overloaded method must be used. The overloaded method
takes the parameters in the form of dictionary as shown below,
response = apiClient.retrieveDevices("iotsample-ardunio", parameters);
The above snippet sorts the response based on device id and uses the bookmark to page through the results.
7.12.3 Sample
The following code sample should be inserted after the constructor code in a .py file. This code demonstrates defining
the deviceId, authToken, metadata, deviceInfo parameters, and location parameters and then using the method with
those parameters and adding a device type.
deviceId = "200020002000"
authToken = "password"
metadata = {"customField1": "customValue1", "customField2": "customValue2"}
deviceInfo = {"serialNumber": "001", "manufacturer": "Blueberry", "model": "abc1", "deviceClass": "A"
location = {"longitude" : "12.78", "latitude" : "45.90", "elevation" : "2000", "accuracy" : "0", "mea
apiCli.registerDevice(deviceTypeId, deviceId, metadata, deviceInfo, location)
41
7.12.8 Sample
In this sample, the following code identifies a specific device, and updates several properties under the deviceInfo
parameter.
status = { "alert": { "enabled": True } }
deviceInfo = {descriptiveLocation: "London", hwVersion: "2.0.1", fwVersion: "2.5.1"}
apiCli.updateDevice("MyDeviceType", "200020002000", deviceInfo, status)
The response to this method contains the longitude, latitude, elevation, accuracy, measuredTimeStamp, and updatedTimeStamp properties.
42
If no date is supplied, the entry is added with the current date and time.
7.12.12 Sample
apiCli.getDeviceManagementInformation("iotsample-arduino", "00aabbccde03")
The response model for this method contains the logId, message, severity, data, and timestamp.
43
44
The response includes a list of log entries, containing log messages and timestamps.
The response will contain some parameters and the application needs to retrieve the JSON element events from the
response to get the array of events returned. Other parameters in the response are required to make further call, for
example, the _bookmark element can be used to page through results. Issue the first request without specifying a
bookmark, then take the bookmark returned in the response and provide it on the request for the next page. Repeat
until the end of the result set indicated by the absence of a bookmark. Each request must use exactly the same values
for the other parameters, or the results are undefined.
In order to pass the _bookmark or any other condition, the overloaded method must be used. The overloaded method
takes the parameters in the form of dictionary as shown below,
45
The above snippet returns the events between the start and end time.
The response will contain some parameters and the application needs to retrieve the JSON element events from the
response to get the array of events returned. As mentioned in the view events from all devices section, the overloaded
method can be used to control the output.
The response will contain more parameters and application needs to retrieve the JSON element events from the response to get the array of events returned.
46
CHAPTER 8
47
48
CHAPTER 9
Application
ApplicationClient is application client for the Internet of Things Foundation service. This section contains information
on how applications interact with devices.
9.1 Constructor
The constructor builds the application client instance. It accepts an configuration json containing the following :
org - Your organization ID
id - The unique ID of your application within your organization.
auth-key - API key
auth-token - API key token
type - use shared to enable shared subscription
If you want to use quickstart, then send only the first two properties.
var Client = require("ibmiotf");
var appClientConfig = {
"org" : orgId,
"id" : appId,
"auth-key" : apiKey,
"auth-token" : apiToken
}
var appClient = new Client.IotfApplication(appClientConfig);
.....
49
After the successful connection to the IoT Platform service, the application client sends a connect event. So all the
logic can be implemented inside this callback function.
9.3 Logging
By default, all the logs of warn are logged. If you want to enable more logs, use the log.setLevel function.
Supported log levels - trace, debug, info, warn, error.
var appClient = new Client.IotfApplication(appClientConfig);
appClient.connect();
//setting the log level to 'trace'
appClient.log.setLevel('trace');
appClient.on("connect", function () {
//Add your code here
});
50
Chapter 9. Application
};
var appClient = new Client.IotfApplication(appClientConfig);
appClient.connect();
//setting the log level to 'trace'
appClient.log.setLevel('trace');
appClient.on("connect", function () {
//Add your code here
});
51
Chapter 9. Application
deviceId
eventType
format
payload - Device event payload
topic - Original topic
var appClient = new Client.IotfApplication(appClientConfig);
appClient.connect();
appClient.on("connect", function () {
appClient.subscribeToDeviceEvents("myDeviceType","device01","+","json");
});
appClient.on("deviceEvent", function (deviceType, deviceId, eventType, format, payload) {
53
54
Chapter 9. Application
55
56
Chapter 9. Application
CHAPTER 10
10.1 Constructor
The constructor builds the client instance, and accepts a Properties object containing the following definitions:
org - Your organization ID (This is a required field. In case of quickstart flow, provide org as quickstart).
id - The unique ID of your application within your organization.
auth-method - Method of authentication (the only value currently supported is apikey).
auth-key - API key (required if auth-method is apikey).
auth-token - API key token (required if auth-method is apikey).
clean-session - true or false (required only if you want to connect the application in durable subscription.
By default the clean-session is set to true).
shared-subscription - true or false (required only if shared subscription needs to be enabled).
Note: One must set shared-subscription to true to build scalable applications which will load balance messages across multiple instances of the application. Refer to the scalable applications section for more information
about the load balancing.
The Properties object creates definitions which are used to interact with the IoT Platform module. If no options are
provided or organization is provided as quickstart, the client will connect to the IoT Platform Quickstart, and default
to an unregistered device.
The following code snippet shows how to construct the ApplicationClient instance in Quickstart mode,
import com.ibm.iotf.client.app.ApplicationClient;
import java.util.Properties;
Properties options = new Properties();
options.put("org", "quickstart");
ApplicationClient myClient = new ApplicationClient(options);
The following code snippet shows how to construct the ApplicationClient instance in registered flow,
57
After the successful connection to the IoT Platform service, the application client can perform the following operations,
like subscribing to device events, subscribing to device status, publishing device events and commands.
58
By default, applications will subscribe to all events from all connected devices. Use the type, id, event and msgFormat
parameters to control the scope of the subscription. A single client can support multiple subscriptions. The code
samples below give examples of how to subscribe to devices dependent on device type, id, event and msgFormat
parameters.
59
Once the event callback is added to the ApplicationClient, the processEvent() method is invoked whenever any event
is published on the subscribed criteria, The following snippet shows how to add the Event call back into ApplicationClient instance,
myClient.connect()
myClient.setEventCallback(new MyEventCallback());
myClient.subscribeToDeviceEvents();
Similar to subscribing to device events, the application can subscribe to commands that are sent to the devices. Following code snippet shows how to subscribe to all commands to all the devices in the organization:
myClient.connect()
myClient.setEventCallback(new MyEventCallback());
myClient.subscribeToDeviceCommands();
Overloaded methods are available to control the command subscription. The processCommand() method is called
when a command is sent to the device that matches the command subscription.
60
61
}
}
Once the status callback is added to the ApplicationClient, the processDeviceStatus() method is invoked whenever any
device is connected or disconnected from IoT Platform that matches the criteria, The following snippet shows how to
add the status call back instance into ApplicationClient,
myClient.connect()
myClient.setStatusCallback(new MyStatusCallback());
myClient.subscribeToDeviceStatus();
As similar to device status, the application can subscribe to any other application connect or disconnect status as well.
Following code snippet shows how to subscribe to the application status in the organization:
myClient.connect()
myClient.setEventCallback(new MyEventCallback());
myClient.subscribeToApplicationStatus();
Overloaded method is available to control the status subscription to a particular application. The processApplicationStatus() method is called whenever any application is connected or disconnected from IoT Platform that matches the
criteria.
62
event.addProperty("mem",
70);
10.9 Examples
MQTTApplicationDeviceEventPublish - A sample application that shows how to publish device events.
RegisteredApplicationCommandPublish - A sample application that shows how to publish a command to a
device.
RegisteredApplicationSubscribeSample - A sample application that shows how to subscribe for various events
like, device events, device commands, device status and application status.
SharedSubscriptionSample - A sample application that shows how to build a scalable application which will
load balance messages across multiple instances of the application.
63
64
CHAPTER 11
11.1 Constructor
The constructor builds the client instance, and accepts arguments containing the following definitions:
orgId - Your organization ID.
appId - The unique ID of your application within your organization.
auth-key - API key (required if auth-method is apikey).
auth-token - API key token (required if auth-method is apikey).
If only appId is provided, the client will connect to the IoT Platform Quickstart service and default to an unregistered
device. The argument lists create definitions which are used to interact with the IoT Platform module.
ApplciationClient applicationClient = new ApplciationClient(orgId, appId, apiKey, authToken);
applicationClient.connect();
65
applicationClient.connect();
applicationClient.appStatusCallback += processAppStatus;
applicationClient.subscribeToApplicationStatus();
67
68
CHAPTER 12
Important: This feature is currently available as part of a limited beta. Future updates may include changes incompatible with the current version of this feature. Try it out and let us know what you think
Note:
When connecting a device or application to Quickstart you should use the following URL instead:
http://quickstart.internetofthings.ibmcloud.com>/api/v0002/device/types/${typeId}/devices/$
Important: HTTP messaging only covers the ability to submit device events currently. Device management and
command control require MQTT connectivity in your device.
12.1.1 Authentication
Requests must include an authorization header. Basic authentication the only method supported. Applications are
authenticated by API keys, when an application makes any request to the IoT Platform API it must present an API as
its credentials:
username = use-token-auth
password = Authentication token
12.1.2 Content-Type
A Content-Type request header must be provided with the request. The following table shows the supported types
and how they are mapped to the IoT Platform internal formats.
69
Content-Type Header
text/plain
application/json
application/xml
application/octet-stream
70
CHAPTER 13
Note: The IoT Platform requires TLS v1.2. We suggest the following cipher suites: ECDHE-RSA-AES256-GCMSHA384, AES256-GCM-SHA384, ECDHE-RSA-AES128-GCM-SHA256 or AES128-GCM-SHA256 (as of Jun 1
2015).
71
The Quickstart service does not currently support MQTT Quality of Service (QoS) levels greater than 0. This is the
fastest and offers no confirmation of receipt. If you are writing device code for use with Quickstart you must also take
into account the following features present in the registered service that are not supported in Quickstart:
Subscribing to commands
MQTT connection over SSL
Clean or durable sessions
Also, messages sent from devices at a rate greater than 1 per second may be discarded.
72
13.3.2 Password
When using token based authentication submit the device authentication token as the password when making your
MQTT connection.
73
Warning: If your managed device uses a durable subscription (cleansession=false) you need to be aware that
device management commands sent to your device while it is offline will be reported as failed operations if the
device does not reconnect to the service before the request times out, however when the device later connects those
requests will be actioned by the device.
When handling request failures it is important to take this into account if you are using durable subscriptions for
your managed devices.
13.6.2 Topics
A managed device is required to subscribe to two topics to handle requests and responses from IoTF:
The managed device will subscribe to device management reponses on iotdm-1/response/+
The managed device will subscribe to device management requests on iotdm-1/+
A managed device will publish to two topics:
The managed device will publish device management responses on iotdevice-1/response/
The managed device will publish device management requests on iotdevice-1/
74
CHAPTER 14
14.1 Introduction
The Device Management capabilities in the IoT Platform create a new class of connected devices, Managed Devices.
Managed Devices must, by definition, contain a management agent which can understand the IoT Platform Device
Management Protocol, and send a Manage Device request to the IoT Platform Device Management server. Managed
devices can access the device management operations as explained later in this document.
The Device Management Protocol defines a set of supported operations. A device management agent can support
a subset of the operations, but the Manage device and Unmanage device operations must be supported. A device
supporting firmware action operations must also support observation.
The Device Management Protocol is built on top of MQTT. For details specific to how Device Management Protocol
interacts with MQTT please see MQTT Connectivity for Devices
75
14.2.1 Topic
iotdevice-1/mgmt/manage
76
"serialNumber": "string",
"manufacturer": "string",
"model": "string",
"deviceClass": "string",
"description" :"string",
"fwVersion": "string",
"hwVersion": "string",
"descriptiveLocation": "string"
}
},
"reqId": "string"
}
Response Format:
{
"rc": 200,
"reqId": "string"
}
14.3.1 Topic
iotdevice-1/mgmt/unmanage
77
Response Format:
{
"rc": 200,
"reqId": "string"
}
14.4.2 Topic
iotdevice-1/device/update/location
78
14.4.4 Topic
iotdm-1/device/update
Response Format:
{
"rc": 200,
"reqId": "string"
}
79
{
"d": {
"fields": [
{
"field": "location",
"value": {
"latitude": number,
"longitude": number,
"elevation": number,
"accuracy": number,
"measuredDateTime": "string in ISO8601 format"
}
}
]
}
}
14.5.1 Topic
iotdm-1/device/update
80
14.6.1 Topic
iotdevice-1/add/diag/errorCodes
Response Format:
{
"rc": 200,
"reqId": "string"
}
14.7.1 Topic
81
iotdevice-1/clear/diag/errorCodes
Response Format:
{
"rc": 200,
"reqId": "string"
}
14.8.1 Topic
iotdevice-1/add/diag/log
82
},
"reqId": "string"
}
Response Format:
{
"rc": 200,
"reqId": "string"
}
14.9.1 Topic
iotdevice-1/clear/diag/log
Response Format:
{
"rc": 200,
"reqId": "string"
}
83
409: A conflict occurred during the device database update. To resolve this, simplify the operation is necessary.
14.10.1 Topic
iotdm-1/observe
Response Format:
{
"rc": number,
"message": "string",
"d": {
"fields": [
{
"field": "field_name",
"value": "field_value"
}
]
84
},
"reqId": "string"
}
14.11.1 Topic
iotdm-1/cancel
Response Format:
{
"rc": number,
"message": "string",
"reqId": "string"
}
85
The field_name value is the name of the attribute that has changed, the field_value is the current value of the
attribute. The attribute can be a complex field, if multiple values in a complex field are updated as a result of a single
operation, only a single notification message should be sent.
If notify request is processed successfully, rc should be set to 200. If the request is not correct, rc should be set to
400. If the field specified in the notify request is not being observed, rc should be set to 404.
Important: Devices must implement observe, notify & cancel operations in order to support Firmware Actions Update.
14.12.1 Topic
iotdevice-1/notify
Response Format:
{
"rc": number,
"reqId": "string"
}
86
CHAPTER 15
15.1.1 Topic
iotdm-1/mgmt/initiate/device/reboot
Response Format:
{
"rc": "response_code",
"message": "string",
"reqId": "string"
}
87
The response code should be 202 if this action can be initiated immediately. If the factory reset attempt fails, the rc
should be 500 and the message field should be set accordingly, if the factory reset action is not supported, set rc
to 501 and optionally set message accordingly.
15.2.1 Topic
iotdm-1/mgmt/initiate/device/factory_reset
Response Format:
{
"rc": "response_code",
"message": "string",
"reqId": "string"
}
State
Idle
Downloading
Downloaded
Meaning
The device is currently not in the process of downloading firmware
The device is currently downloading firmware
The device has successfully downloaded a firmware update and it is ready to install
The mgmt.firmware.updateStatus attribute describes the status of firmware update. The possible values for
mgmt.firmware.updateStatus are:
88
Value
0
1
2
3
4
5
6
State
Success
In Progress
Out of Memory
Connection Lost
Verification Failed
Unsupported Image
Invalid URI
Meaning
The firmware has been successfully updated
The firmware update has been initiated but is not yet complete
An out of memory condition has been detected during the operation.
The connection was lost during the firmware download
The firmware did not pass verification
The downloaded firmware image is not supported by the device
The device could not download the firmware from the provided URI
The device management server in the IoT Platform uses the Device Management Protocol to send a request to the
devices, initiating the firmware download. There are multiple steps:
89
90
"fields" : "mgmt.firmware"
}
]
}
}
Outgoing response from device:
Topic: iotdevice-1/response
Message:
{
"rc" : 200,
"reqId" : "909b477c-cd37-4bee-83fa-1d568664fbe8"
}
After a firmware download is initiated this way, the device needs to report to the IoT Platform the status of
the download. This is possible by publishing a message to the iotdevice-1/notify-topic, where the
mgmt.firmware.state is set to either 1 (Downloading) or 2 (Downloaded). Here some examples:
Outgoing message from device:
Topic: iotdevice-1/notify
Message:
{
"reqId" : "123456789";
"d" : {
91
"fields" : [ {
"fields" : "mgmt.firmware",
"value" : {
"state" : 1
}
} ]
}
}
After the notification with mgmt.firmware.state set to 2 was published, a request will be triggered on the
iotdm-1/cancel-topic, which cancels the observation of the mgmt.firmware-field. After a response with rc
set to 200 was sent the firmware download is completed. Example:
Incoming request from the IoT Platform:
Topic: iotdm-1/cancel
Message:
{
"reqId" : "d9ca3635-64d5-46e2-93ee-7d1b573fb20f",
"d" : {
"fields" : [{
"field" : "mgmt.firmware"
}
]
}
}
92
"rc" : 200,
"reqId" : "d9ca3635-64d5-46e2-93ee-7d1b573fb20f"
}
93
In order to monitor the status of the firmware update the IoT Platform first triggers an observer request on the topic
iotdm-1/observe. When the device is ready to start the update process it sents a response with rc set to 200,
mgmt.firmware.state set to 0 and mgmt.firmware.updateStatus set to 0. Here an example:
Incoming request from the IoT Platform:
Topic: iotdm-1/observe
Message:
{
"reqId" : "909b477c-cd37-4bee-83fa-1d568664fbe8",
"d" : {
"fields" : ["mgmt.firmware"]
}
}
Outgoing response from device:
Topic: iotdevice-1/response
Message:
{
"rc" : 200,
"reqId" : "909b477c-cd37-4bee-83fa-1d568664fbe8",
"d" : {
"fields" : [{
"field" : "mgmt.firmware",
"value" : {
"state" : 0,
"updateStatus" : 0
}
}
]
}
}
Afterwards the device management server in the IoT Platform uses the device management protocol to request that the devices specified initiate the firmware installation by publishing using the topic
iotdm-1/mgmt/initiate/firmware/update. If this operation can be initiated immediately, rc should be
set to 202. If firmware was not previously downloaded successfully, rc should be set to 400. Here some example
exchange:
Incoming request from the IoT Platform:
Topic: iotdm-1/mgmt/initiate/firmware/update
Message:
{
"reqId" : "7b244053-c08e-4d89-9ed6-6eb2618a8734"
}
Outgoing response from device:
94
Topic: iotdevice-1/response
Message:
{
"rc" : 202,
"reqId" : "7b244053-c08e-4d89-9ed6-6eb2618a8734"
}
In order to finish the firmware update request the device has to report its update status to the IoT Platform
via a status message published on its iotdevice-1/notify-topic. Once firmware update is completed,
mgmt.firmware.updateStatus should be set to 0 (Success), mgmt.firmware.state should be set to
0 (Idle), downloaded firmware image can be deleted from the device and deviceInfo.fwVersion should be
set to the value of mgmt.firmware.version. Here an example notify message:
Outgoing message from device:
Topic: iotdevice-1/notify
Message:
{
"d" : {
"field" : "mgmt.firmware",
"value" : {
"state" : 0,
"updateStatus" : 0
}
}
}
After the IoT Platform received the notify of a completed firmware update it will trigger a last request on the
iotdm-1/cancel-topic for cancelation of the observation of the mgmt.firmware-field. After a response with
rc set to 200 was sent the firmware update request is completed. Example:
Incoming request from the IoT Platform:
Topic: iotdm-1/cancel
Message:
{
"reqId" : "d9ca3635-64d5-46e2-93ee-7d1b573fb20f",
"d" : {
"data" : [{
"field" : "mgmt.firmware"
}
]
}
}
95
Topic: iotdevice-1/response
Message:
{
"rc" : 200,
"reqId" : "d9ca3635-64d5-46e2-93ee-7d1b573fb20f"
}
96
CHAPTER 16
16.1 Constructor
The constructor builds the client instance, and accepts an options dict containing the following definitions:
org - Your organization ID.
type - The type of your device.
id - The ID of your device.
auth-method - Method of authentication (the only value currently supported is token).
auth-token - API key token (required if auth-method is token).
If no options dict is provided, the client will connect to the IoT Platform Quickstart, and default to an unregistered
device. The options dict creates definitions which are used to interact with the IoT Platform module.
import ibmiotf.device
try:
options = {
"org": organization,
"type": deviceType,
"id": deviceId,
"auth-method": authMethod,
"auth-token": authToken
}
client = ibmiotf.device.Client(options)
except ibmiotf.ConnectionException as e:
...
97
client = ibmiotf.device.Client(options)
except ibmiotf.ConnectionException as e:
...
The content of the configuration file must be in the following format(need not contain $ sign):
[device]
org=$orgId
type=$myDeviceType
id=$myDeviceId
auth-method=token
auth-token=$token
format - string
data - dict
timestamp - datetime
def myCommandCallback(cmd):
print("Command received: %s" % cmd.data)
if cmd.command == "setInterval":
if 'interval' not in cmd.data:
print("Error - command is missing required information: 'interval'")
else:
interval = cmd.data['interval']
elif cmd.command == "print":
if 'message' not in cmd.data:
print("Error - command is missing required information: 'message'")
else:
print(cmd.data['message'])
...
client.connect()
client.commandCallback = myCommandCallback
99
100
CHAPTER 17
17.1 Constructor
The constructor builds the device client instance. It accepts a configuration json containing the following definitions:
org - Your organization ID
type - The type of your device
id - The ID of your device
auth-method - Method of authentication (the only value currently supported is token)
auth-token - API key token (required if auth-method is token)
If you want to use Quickstart, then send only the first three properties.
var iotf = require("ibmiotf");
var config = {
"org" : "organization",
"id" : "deviceId",
"type" : "deviceType",
"auth-method" : "token",
"auth-token" : "authToken"
};
101
After the successful connection to the IoT Platform service, the device client sends a connect event. So all the device
logic can be implemented inside this callback function.
17.3 Logging
By default, all the logs of warn are logged. If you want to enable more logs, use the log.setLevel function. Supported
log levels - trace, debug, info, warn, error.
var iotf = require("ibmiotf");
var config = require("./device.json");
var deviceClient = new iotf.IotfDevice(config);
//setting the log level to debug. By default its 'warn'
deviceClient.log.setLevel('debug');
When an event is received by the IoT Platform the credentials of the connection on which the event was received
are used to determine from which device the event was sent. With this architecture it is impossible for a device to
impersonate another device.
Events can be published at any of the three quality of service levels defined by the MQTT protocol. By default events
will be published as QoS level 0. Please not that if you are using the Internet of Things Quickstart service, events can
only be published at QoS level 0.
Events can be published by using:
eventType - Type of event to be published e.g status, gps.
eventFormat - Format of the event e.g json.
data - Payload of the event.(Must be buffer/String)
QoS - MQTT quality of service for the publish event. Supported values : 0,1,2.
var deviceClient = new Client.IotfDevice(config);
deviceClient.connect();
deviceClient.on("connect", function () {
//publishing event using the default quality of service
deviceClient.publish("status","json",'{"d" : { "cpu" : 60, "mem" : 50 }}');
//publishing event using the user-defined quality of service
var myQosLevel=2
deviceClient.publish("status","json",'{"d" : { "cpu" : 60, "mem" : 50 }}', myQosLevel);
});
103
} else {
console.log("Command not supported.. " + commandName);
}
});
104
CHAPTER 18
18.1 Constructor
The constructor builds the client instance, and accepts a Properties object containing the following definitions:
org - Your organization ID. (This is a required field. In case of quickstart flow, provide org as quickstart.)
type - The type of your device. (This is a required field.)
id - The ID of your device. (This is a required field.
auth-method - Method of authentication (This is an optional field, needed only for registered flow and the only
value currently supported is token).
auth-token - API key token (This is an optional field, needed only for registered flow).
clean-session - true or false (required only if you want to connect the application in durable subscription. By
default the clean-session is set to true).
Note: One must set clean-session to false to connect the device in durable subscription. Refer to Subscription
Buffers and Clean Session for more information about the clean session.
The Properties object creates definitions which are used to interact with the IoT Platform module.
The following code shows a device publishing events in a Quickstart mode.
package com.ibm.iotf.sample.client.device;
import java.util.Properties;
import com.google.gson.JsonObject;
import com.ibm.iotf.client.device.DeviceClient;
public class QuickstartDeviceEventPublish {
public static void main(String[] args) {
//Provide the device specific data using Properties class
Properties options = new Properties();
options.setProperty("org", "quickstart");
105
options.setProperty("type", "iotsample-arduino");
options.setProperty("id", "00aabbccde03");
DeviceClient myClient = null;
try {
//Instantiate the class by passing the properties file
myClient = new DeviceClient(options);
} catch (Exception e) {
e.printStackTrace();
}
//Connect to the IBM IoT Platform
myClient.connect();
//Generate a JSON object of the event to be published
JsonObject event = new JsonObject();
event.addProperty("name", "foo");
event.addProperty("cpu", 90);
event.addProperty("mem", 70);
//Quickstart flow allows only QoS = 0
myClient.publishEvent("status", event, 0);
System.out.println("SUCCESSFULLY POSTED......");
...
106
18.1. Constructor
107
[device]
org=$orgId
typ=$myDeviceType
id=$myDeviceId
auth-method=token
auth-token=$token
108
import com.ibm.iotf.client.device.Command;
import com.ibm.iotf.client.device.CommandCallback;
import com.ibm.iotf.client.device.DeviceClient;
//Implement the CommandCallback class to provide the way in which you want the command to be handled
class MyNewCommandCallback implements CommandCallback{
public MyNewCommandCallback() {
}
//In this sample, we are just displaying the command the moment the device recieves it
@Override
109
//Provide the device specific data, as well as Auth-key and token using Properties cl
Properties options = new Properties();
options.setProperty("org", "uguhsp");
options.setProperty("type", "iotsample-arduino");
options.setProperty("id", "00aabbccde03");
options.setProperty("auth-method", "token");
options.setProperty("auth-token", "AUTH TOKEN FOR DEVICE");
DeviceClient myClient = null;
try {
//Instantiate the class by passing the properties file
myClient = new DeviceClient(options);
} catch (Exception e) {
e.printStackTrace();
}
//Pass the above implemented CommandCallback as an argument to this device client
myClient.setCommandCallback(new MyNewCommandCallback());
//Connect to the IoT Platform
myClient.connect();
}
}
110
CHAPTER 19
19.1 Constructor
The constructor builds the client instance, and accepts arguments containing the following definitions:
orgId - Your organization ID.
deviceType - The type of your device.
deviceId - The ID of your device.
auth-method - Method of authentication (the only value currently supported is token).
auth-token - API key token (required if auth-method is token).
If deviceId and deviceType are provided, the client will connect to the IoT Platform Quickstart, and default to an
unregistered device. The argument lists creates definitions which are used to interact with the IoT Platform module.
namespace com.ibm.iotf.client
public DeviceClient(string orgId, string deviceType, string deviceID, string authmethod, string autht
: base(orgId, "d" + CLIENT_ID_DELIMITER + orgId + CLIENT_ID_DELIMITER + deviceType + CLIENT_ID_DE
{
}
111
112
CHAPTER 20
20.1 Dependencies
Eclipse Paho Embedded C library - provides an MQTT C client library, check here for more information.
20.2 Installation
To install the IoT Platform client library for Embedded C follow the instructions below.
1. To install the latest version of the library, enter the following code in your command line.
[root@localhost ~]# git clone https://github.com/ibm-messaging/iotf-embeddedc.git
2. Copy the Paho library .tar file that was downloaded in the previous step to the lib directory.
cd iotf-embeddedc
cp ~/org.eclipse.paho.mqtt.embedded-c-1.0.0.tar.gz lib/
113
#include "iotfclient.h"
....
....
Iotfclient client;
char *configFilePath = "./device.cfg";
rc = initialize_configfile(&client, configFilePath);
if(rc != SUCCESS){
printf("initialize failed and returned rc = %d.\n Quitting..", rc);
return 0;
}
rc = connectiotf(&client);
if(rc != SUCCESS){
printf("Connection failed and returned rc = %d.\n Quitting..", rc);
return 0;
}
....
115
20.8 Samples
Sample device and application code is provided in GitHub.
116
CHAPTER 21
21.1 Dependencies
Eclipse Paho MQTT library - Provides a MQTT client library for mBed devices, check here for more information.
EthernetInterface library - A mBed IP library over Ethernet.
21.3 Constructor
The constructor builds the client instance, and accepts the following parameters:
org - Your organization ID. (This is a required field. In case of quickstart flow, provide org as quickstart.)
type - The type of your device. (This is a required field.)
id - The ID of your device. (This is a required field.
auth-method - Method of authentication (This is an optional field, needed only for registered flow and the only
value currently supported is token).
auth-token - API key token (This is an optional field, needed only for registered flow).
117
These arguments create definitions which are used to interact with the IoT Platform service.
The following code block shows how to create a DeviceClient instance to interact with the IoT Platform quickstart
service.
#include "DeviceClient.h"
....
....
As shown above, if the device id is not specified, the DeviceClient uses the MAC address of the device as device id
and connects to the IoT Platform. The device code can use getDeviceId() method to retrieve the device id from the
DeviceClient instance.
The following code block shows how to create a DeviceClient instance to interact with the IoT Platform Registered
organization.
#include "DeviceClient.h"
....
....
// Set IoT Platform connection parameters
char organization[11] = "hrcl78";
char deviceType[8] = "LPC1768";
char deviceId[3] = "LPC176801";
char method[6] = "token";
char token[9] = "password";
// Create DeviceClient
IoTF::DeviceClient client(organization, deviceType, deviceId, method, token);
....
118
After the successful connection, the device can publish events to the IoT Platform and listen for commands.
Also, the device can query the status of the connection using the isConnected() method as follows,
#include "DeviceClient.h"
....
....
client.isConnected();
119
#include "MQTTClient.h"
boolean status = client.connect();
// Create buffer to hold the event
char buf[250];
// Construct an event message with desired datapoints in JSON format
sprintf(buf,
"{\"d\":{\"myName\":\"IoT mbed\",\"accelX\":%0.4f,\"accelY\":%0.4f,\"accelZ\":%0.4f,
\"temp\":%0.4f,\"joystick\":\"%s\",\"potentiometer1\":%0.4f,\"potentiometer2\":%0.4f}}",
MMA.x(), MMA.y(), MMA.z(), sensor.temp(), joystickPos, ain1.read(), ain2.read());
status = client.publishEvent("blink", buf, MQTT::QOS2);
....
21.5.3 Handling the connection lost error during the event publish
When the publishEvent() method returns false, one can check the status of the connection and call reConnect() if the
connection is lost,
#include "MQTTClient.h"
status = client.publishEvent("blink", buf, MQTT::QOS2);
if(status == false) {
// Check if connection is lost and retry
while(!client.isConnected())
{
client.reConnect();
wait(5.0);
}
}
....
The library does not store the events published during the unconnected state, and hence, the device needs to call the
publishEvent() method again to send those events once the connection is reestablished.
120
#include "DeviceClient.h"
#include "Command.h"
// Process the command and set the LED blink interval
void processCommand(IoTF::Command &cmd)
{
if (strcmp(cmd.getCommand(), "blink") == 0)
{
char *payload = cmd.getPayload();
char* pos = strchr(payload, '}');
if (pos != NULL) {
*pos = '\0';
char* ratepos = strstr(payload, "rate");
if(ratepos == NULL)
return;
if ((pos = strchr(ratepos, ':')) != NULL)
{
int blink_rate = atoi(pos + 1);
blink_interval = (blink_rate <= 0) ? 0 : (blink_rate > 50 ? 1 : 50/blink_rate);
}
}
} else {
WARN("Unsupported command: %s\n", cmd.getCommand());
}
}
client.setCommandCallback(processCommand);
client.yield(10);
....
21.8 Samples
IBMIoTClientLibrarySample - A Sample code that showcases how to use IBMIoTF client library to connect the mbed
LPC1768 or FRDM-K64F devices to the IBM Internet of Things Cloud service.
121
122
CHAPTER 22
Important: This feature is currently available as part of a limited beta. Future updates may include changes incompatible with the current version of this feature. Try it out and let us know what you think
Note: The IoT Platform requires TLS v1.2. We suggest the following cipher suites: ECDHE-RSA-AES256-GCMSHA384, AES256-GCM-SHA384, ECDHE-RSA-AES128-GCM-SHA256 or AES128-GCM-SHA256 (as of Jun 1
2015).
123
22.3.2 Password
When using token based authentication submit the device authentication token as the password when making your
MQTT connection.
124
22.4.1 Example
Gateway 1
Device 1
typeId
mygateway
mydevice
deviceId
gateway1
device1
22.5.1 Example
Gateway 1
Device 1
typeId
mygateway
mydevice
deviceId
gateway1
device1
sent
to
devices
of
type
mydevice:
125
Warning: If your managed gateway uses a durable subscription (cleansession=false) you need to be aware that device management commands sent to your gateway while it is offline will be reported as failed operations, however,
when the gateway later connects those requests will be actioned by the gateway.
When handling failures it is important to take this into account if you are using durable subscriptions for your
managed gateways.
22.6.2 Topics
A managed gateway is required to subscribe to two topics to handle requests and responses from IoT Platform:
The
managed
gateway
will
subscribe
to
device
iotdm-1/type/<typeId>/id/<deviceId>/response/+
management
reponses
on
The
managed
gateway
will
subscribe
iotdm-1/type/<typeId>/id/<deviceId>/+
management
requests
on
to
device
device
management
responses
on
requests
on
The gateway is able to process device management protocol messages for both itself and on behalf other connected
devices by using the relevant <typeId> and <deviceId>.
126
CHAPTER 23
MQTT
The primary mechanism that devices and applications use to communicate with the IBM Watson IoT platform is
MQTT; this is a protocol designed for the efficient exchange of real-time data with sensor and mobile devices.
MQTT runs over TCP/IP and, while it is possible to code directly to TCP/IP, you might prefer to use a library that
handles the details of the MQTT protocol for you. You will find theres a wide range of MQTT client libraries available
at mqtt.org, with the best place to start looking being the Eclipse Paho project. IBM contributes to the development
and support of many of these libraries.
MQTT 3.1 is the version of the protocol that is in widest use today. Version 3.1.1 contains a number of minor
enhancements, and has been ratified as an OASIS Standard.
One reason for using version 3.1.1 is that the maximum length of the MQTT Client Identifier (ClientId) is increased
from the 23 character limit imposed by 3.1. The IoT service will often require longer ClientIds and will accept long
ClientIds with either version of the protocol however some 3.1 client libraries check the ClientId and enforce the 23
character limit.
127
128
129
130
CHAPTER 24
Device Model
The device model describes the metadata and management characteristics of a device. The device database in the
Watson IoT platform is the master source of device information. Applications and managed devices are able to send
updates to the database such as a location or the progress of a firmware update. Once these updates are received by
the Watson IoT platform, the device database is updated, making the information available to applications.
Note: With the exception of the management extension, the entire device model is available for both managed and
unmanaged devices. However, an unmanaged device can not directly update its device model in the database.
131
24.3 Attributes
The table below shows the list of attributes which can apply to devices in the Watson IoT platform. Additionally,
italicized attributes can also apply to device types.
API/DMA: Can be updated by API/Device Management Agent
R: Read only
W: Write and read
A: Append
132
Attribute
clientId
typeId
deviceId
classId
gatewayTypeId
gatewayId
status.alert
deviceInfo.serialNumber
deviceInfo.manufacturer
deviceInfo.model
deviceInfo.deviceClass
deviceInfo.description
deviceInfo.fwVersion
deviceInfo.hwVersion
deviceInfo.descriptiveLocation
metadata
added.auth.id
added.dateTime
refs.diag.errorCodes
refs.diag.logs
refs.location
refs.mgmt
Type
string
string
string
string
string
string
boolean
string
Description
The client ID used with MQTT connections
Device type
Device ID
Class of device (Device or Gateway)
Type ID of the gateway this device is using
Device ID of the gateway this device is using
Whether the device has an alert
The serial number of the device
API
R
R
R
R
R
R
W
W
DMA
string
string
string
string
string
string
string
W
W
W
W
W
W
W
W
W
W
W
W
R
R
R
R
R
R
complex
string
string
string
string
string
string
Prefix of attributes
diag
location
mgmt
Purpose
Error logs and diagnostic information
Location of the device, potentially updated regularly
Device management actions, e.g. firmware update
133
Attribute
diag.errorCodes[]
Type
array of
integer(s)
diag.log[]
array
diag.log[].message
string
diag.log[].timestamp string
diag.log[].logData
string
diag.log[].severity
number
Description
Array of error codes
API
A
DMA
A
Type
number
number
number
string
string
number
Description
Longitude in decimal degrees using WGS84
API
W
DMA
W
R
W
134
Attribute
mgmt.dormant
mgmt.dormantDateTime
Type Description
boolean Whether the device has become dormant
string ISO8601 date-time: Date and time at which the managed
device will become dormant
mgmt.lastActivityDateTimestring ISO8601 date-time: Date and time of last activity, updated
periodically
mgmt.supports.deviceActions
boolean Whether the device supports Reboot and Factory Reset actions
mgmt.supports.firmwareActions
boolean Whether the device supports Firmware Download and
Firmware Update actions
mgmt.firmware.version
string The version of the firmware on the device
mgmt.firmware.name
string The name of the firmware to be used on the device
mgmt.firmware.uri
string The URI from which the firmware image can be downloaded
mgmt.firmware.verifier
string The verifier such as a checksum for the firmware image to
validate its integrity
mgmt.firmware.state
num- Indicates the state of firmware download
ber
mgmt.firmware.updateStatusnum- Indicates the status of the update
ber
mgmt.firmware.updatedDateTime
string ISO8601 date-time: Date of last update
API
R
R
DMA
R
R
R
R
R
R
R
W
W
W
W
135
136
CHAPTER 25
25.1 Overview
External service integration allows you to bind metadata or function supported by another service to your Watson IoT
account.
25.2 Jasper
Jasper is an administration and management platform for SIM devices. Jasper has been integrated into the IBM
Watson IoT platform dashboard, making it possible to administer Jasper devices through your Watson IoT platform
organization dashboard.
Important: Jasper integration is currently available as part of a limited beta. Future updates may include changes
incompatible with the current version of this feature.
137
25.2.2 Configuration
In order to connect your Watson IoT Platform platform organization with your Jasper account, there are two stages of
configuration which must first be performed. The first stage of configuration is Organization Configuration.
Extension Enablement
To enable Jasper integrtion with your Watson IoT organization follow these steps:
1. When in your Watson IoT platform dashboard, click the wrench icon on the right to open the Configuration
Settings.
2. Scroll down the to the Extensions section, and set Jasper to On.
3. Enter your Jasper username, password, license key, and API endpoint.
Device Configuration
Devices which are connected to both your Watson IoT platform organization and your Jasper account can be configured
to display data from Jasper in the Watson IoT platform dashboard. Jasper configuration cannot be applied as part of
the Add Device process, only already connected devices can be configured with Jasper. To configure your Jasperconnected devices, follow these steps:
1. In the devices tab of your Watson IoT platform dashboard, find the Jasper-connected device to be configured.
2. Select the device to open the Device Drilldown view.
3. Scroll down to the Extension Configuration section. The extension configuration must be entered as JSON in
the following format:
{
"jasper": {
"iccid": "string"
}
}
4. When this has been entered, click Confirm changes to save the configuration.
If the Organization configuration has been completed correctly, the Extensions section should now appear below the
Extensions Configuration section in the Device Drilldown.
138
CHAPTER 26
The IBM Watson IoT platform is a fully managed, cloud-hosted service that makes it simple to derive value from
Internet of Things (IoT) devices.
The following document aims to answer common questions about how your organizations data is protected. Focusing
on specific areas:
Authentication: assuring the identity of users, devices or applications attempting to access your organizations
information.
Authorization: assuring that users, devices and applications have permission to access your organizations information.
Encryption: assuring that data is only readable by authorized parties and cannot be intercepted.
26.1 Terminology
139
Applications can subscribe and publish on both the event and command topics for all devices in the organization.
Applications can analyse data from many devices simultaneously, and can also simulate or proxy devices in addition
to forming the complementary side of a full duplex communication loop.
141
142
CHAPTER 27
Contribute
If its not working for you, its not working for us. The source of this documentation is available on GitHub, we
welcome both suggestions for improvement and community contributions via the use of issues and pull requests
against our repository.
143