public class IotpSensors
extends java.lang.Object
sensors
. display
.
In addition a device event with id hearbeat
is sent
every minute. This ensure a connection attempt to IBM Watson IoT Platform
is made immediately rather than waiting for a bursty sensor to become
active.
This sample requires an IBM Watson IoT Platform service and a device configuration.
The device configuration is read from the file device.cfg
in the
current directory.
In order to see commands send from IBM Watson IoT Platform
there must be an analytic application
that sends commands with the identifier display
.
Constructor and Description |
---|
IotpSensors() |
Modifier and Type | Method and Description |
---|---|
static TStream<java.lang.String> |
displayMessages(IotDevice device,
boolean print)
Subscribe to IoTP device commands with identifier
display . |
static void |
heartBeat(IotDevice device,
boolean print)
Create a heart beat device event with
identifier
heartbeat to
ensure there is some immediate output and
the connection to IoTF happens as soon as possible. |
static void |
main(java.lang.String[] args)
Run the IotpSensors application.
|
static void |
simulatedSensors(IotDevice device,
boolean print)
Simulate two bursty sensors and send the readings as IoTF device events
with an identifier of
sensors . |
public static void main(java.lang.String[] args)
args
- Must contain the path to the device configuration file.IotpDevice.IotpDevice(org.apache.edgent.topology.Topology, File)
public static void simulatedSensors(IotDevice device, boolean print)
sensors
.device
- IoT deviceprint
- True if the data submitted as events should also be printed to
standard out.public static void heartBeat(IotDevice device, boolean print)
heartbeat
to
ensure there is some immediate output and
the connection to IoTF happens as soon as possible.device
- IoT deviceprint
- true to print generated heartbeat tuples to System.out.public static TStream<java.lang.String> displayMessages(IotDevice device, boolean print)
display
.
Subscribing to device commands returns a stream of JSON objects that
include a timestamp (tsms
), command identifier (command
)
and payload (payload
). Payload is the application specific
portion of the command. msg
key with a string display message. Note to receive commands a analytic application must exist that generates them through IBM Watson IoT Platform.
device
- the deviceprint
- true to print the received command's payload to System.out.IotDevice.commands(String...)
Copyright © 2016 The Apache Software Foundation. All Rights Reserved - bbe71fa-20161201-1641