Run the Sample Java SE Gateway Application

Run the sample Java SE gateway application to learn how to use the client software library APIs. The sample Java SE gateway application simulates a gateway that polls humidity and temperature sensors and sends sensor data to the Oracle Internet of Things Cloud Service instance.

  1. Create the sample applications. See Create the Java SE Client Software Library Sample Applications.
  2. Upload the humidity and temperature sensor device models to Oracle Internet of Things Cloud Service. See Upload the Sample Device Models.
  3. Register the gateway device and download the provisioning file.
    Do not reuse the device from the Running the Sample Java SE Directly Connected Device Applications procedure. This procedure requires a device with indirect activation capability.

    Note:

    If you are using Oracle Internet of Things Cloud Service version 16 4.1 or earlier, use the provisioning tool to create the trusted assets truststore. See Use the Provisioning Tool to Create the Truststore.
  4. Run this command to start the GatewayDeviceSample application:
     java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/device-library.jar:$CL_HOME/lib/json-20160212.jar com.oracle.iot.sample.GatewaydDeviceSample MY-GW-SAMPLE-provisioning-file.conf Password123
    To run the application with device policies, add this parameter to the command:
    -Dcom.oracle.iot.sample.use_policy=true
    The command to start the application with device policies:
     java -cp -Dcom.oracle.iot.sample.use_policy=true $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/device-library.jar:$CL_HOME/lib/json-20160212.jar com.oracle.iot.sample.GatewaydDeviceSample MY-GW-SAMPLE-provisioning-file.conf Password123
    Output similar to the following appears:
    Creating the gateway instance...
    Created virtual temperature sensor 0-HA
    Created virtual humidity sensor 0-HE
     
            Press enter to exit.
     
    Tue Feb 9 16:17:53 EST 2016 : 0-HE : Set : "humidity"=81
    Tue Feb 9 16:17:52 EST 2016 : 0-HA : Set : "power"=true,"temp"=58.5,"unit"=°C,"minTemp"=58.5,"maxTemp"=58.5,"minThreshold"=0,"maxThreshold"=65
    Tue Feb 9 16:17:58 EST 2016 : 0-HE : Set : "humidity"=86
    Tue Feb 9 16:17:58 EST 2016 : 0-HA : Set : "temp"=62.25,"maxTemp"=62.25
    Tue Feb 9 16:18:03 EST 2016 : 0-HE : Set : "humidity"=89
    Tue Feb 9 16:18:03 EST 2016 : 0-HA : Set : "temp"=64.99,"maxTemp"=64.99
    Tue Feb 9 16:18:08 EST 2016 : 0-HE : Set : "humidity"=91
    Tue Feb 9 16:18:08 EST 2016 : 0-HE : Alert : "humidity"=91 (tooHumidAlert)
    Tue Feb 9 16:18:08 EST 2016 : 0-HA : Set : "temp"=66.0,"maxTemp"=66.0
    Tue Feb 9 16:18:08 EST 2016 : 0-HA : Alert : "temp"=66.0,"unit"=°C,"maxThreshold"=65
    Tue Feb 9 16:18:13 EST 2016 : 0-HE : Set : "humidity"=89
    Tue Feb 9 16:18:13 EST 2016 : 0-HA : Set : "temp"=64.99