public class IotfSensors
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 |
---|
IotfSensors() |
Modifier and Type | Method and Description |
---|---|
static TStream<java.lang.String> |
displayMessages(IotDevice device)
Subscribe to IoTF device commands with identifier
display . |
static void |
main(java.lang.String[] args) |
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)
public static void simulatedSensors(IotDevice device, boolean print)
sensors
.device
- IoTF deviceprint
- True if the data submitted as events should also be printed to
standard out.public static TStream<java.lang.String> displayMessages(IotDevice device)
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.
IotDevice.commands(String...)
Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902