quarks.samples.connectors.iotf
Class IotfSensors
- java.lang.Object
-
- quarks.samples.connectors.iotf.IotfSensors
-
public class IotfSensors extends java.lang.Object
Sample sending sensor device events to IBM Watson IoT Platform.
Simulates a couple of bursty sensors and sends the readings from the sensors to IBM Watson IoT Platform as device events with idsensors
.
Subscribes to device commands with identifierdisplay
.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 identifierdisplay
.
-
-
Constructor Summary
Constructors Constructor and Description IotfSensors()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static TStream<java.lang.String>
displayMessages(IotDevice device)
Subscribe to IoTF device commands with identifierdisplay
.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 ofsensors
.
-
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
-
simulatedSensors
public static void simulatedSensors(IotDevice device, boolean print)
Simulate two bursty sensors and send the readings as IoTF device events with an identifier ofsensors
.- Parameters:
device
- IoTF deviceprint
- True if the data submitted as events should also be printed to standard out.
-
displayMessages
public static TStream<java.lang.String> displayMessages(IotDevice device)
Subscribe to IoTF device commands with identifierdisplay
. 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.
In this case the payload is expected to be a JSON object containing amsg
key with a string display message.
The returned stream consists of the display message string extracted from the JSON payload.Note to receive commands a analytic application must exist that generates them through IBM Watson IoT Platform.
- See Also:
IotDevice.commands(String...)
-
-