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 id sensors.
    Subscribes to device commands with identifier 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 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 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IotfSensors

        public IotfSensors()
    • 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 of sensors.
        Parameters:
        device - IoTF device
        print - 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 identifier 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.
        In this case the payload is expected to be a JSON object containing a msg 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...)

Copyright IBM 2015,2016 - 2f6ad0e-20160307-0902