Run the Sample Java SE Directly Connected Device Applications

Run the sample Java SE directly connected device applications to learn how to use the client software library APIs. The sample directly connected device applications use software to simulate temperature and humidity sensors. The sample directly connected device applications periodically send temperature, humidity, and alert messages to Oracle Fusion Cloud IoT Intelligent Applications.

About the Sample Java SE Directly Connected Device Applications

Two directly connected device sample applications are available. The first sample application is located in the com.oracle.iot.sample package and uses virtualization. The second sample application is located in the com.oracle.iot.sample.ext package and it uses a messaging API to provide direct control over the client software library.

  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 Fusion Cloud IoT Intelligent Applications. See Upload the Sample Device Models.
  3. Register the device and download the provisioning file. See Registering and Activating Devices.

    Note:

    If you are using Oracle Fusion Cloud IoT Intelligent Applications 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 DirectlyConnectedDeviceSample application:
    java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/device-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.DirectlyConnectedDeviceSample activation_id-provisioning-file.conf Password123
    Replace activation_id , -provisioning-file.conf, and Password123 with the values you recorded when you registered your device.
    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-20200518.jar com.oracle.iot.sample.DirectlyConnectedDeviceSample activation_id-provisioning-file.conf Password123
    Output similar to the following appears:
    Created virtual humidity sensor 6E6BD2A4-65A8-4482-869D-325D9E5291F2
    Tue Feb 9 16:13:53 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=81,"maxThreshold"=90
     
            Press enter to exit.
     
    Tue Feb 9 16:13:53 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=86
    Tue Feb 9 16:13:58 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=89
    Tue Feb 9 16:14:03 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=91
    Tue Feb 9 16:14:03 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Alert : "humidity"=91 (tooHumidAlert)
    Tue Feb 9 16:14:09 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=89
    Tue Feb 9 16:14:14 EST 2016 : 6E6BD2A4-65A8-4482-869D-325D9E5291F2 : Set : "humidity"=86