- Device Connectivity Guide for Oracle Fusion Cloud IoT Intelligent Applications
- Develop Device Software Using the Client Software Libraries
- Use the Java SE Client Software Libraries
- Run the Sample Java SE Enterprise Applications
Run the Sample Java SE Enterprise Applications
Run the Java SE sample enterprise applications to learn how to use the client software library APIs. The sample enterprise application reads humidity and temperature values of directly connected or gateway devices. The sample enterprise applications can also change device attributes by sending commands through Oracle Fusion Cloud IoT Intelligent Applications.
- Create the sample applications. See Create the Java SE Client Software Library Sample Applications.
- Upload the humidity and temperature sensor device models to Oracle Fusion Cloud IoT Intelligent Applications. See Upload the Sample Device Models.
- Register the device and download the provisioning file.
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. - Run the
DirectlyConnectedDevice
or theGatewayDevice
sample applications. See Run the Sample Java SE Directly Connected Device Applications or Run the Sample Java SE Gateway Application. - Run this command to return a list of device IDs that are associated with the humidity sensor:
java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration_ID-provisioning-file.conf Password123
Replaceapp_integration_ID
and-provisioning-file.conf Password123
with the values that you recorded when adding the integration and registering the device.Output similar to the following appears:0-HA [Temperature Sensor] 0-BQ [Humidity Sensor] 0-HE [Humidity Sensor]
- Record the device ID, 0-BQ that you used to run the
DirectlyConnectedDeviceDeviceSample
sample and the device IDs 0-HE and 0-HA of the indirectly connected devices that you used to run theGatewayDeviceSample
. - Run this command to monitor the humidity and temperature sensors:
java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration_ID-provisioning-file.conf Password123 0-HA,0-HE,0-BQ
Note:
Replaceapp_integration_ID-provisioning-file.conf
with the name of the enterprise integration provisioning file andapp_integration2_ID-provisioning-file.conf
with the integration provisioning file for the control feature of theEnterpriseClientSample
application. ReplacePassword123
with the password used to secure the provisioning files.Output similar to the following appears:Press enter to exit. Tue Feb 9 16:34:09 EST 2016 : 0-HE : onChange : "humidity"=89 Tue Feb 9 16:34:13 EST 2016 : 0-BQ : onChange : "humidity"=89 Tue Feb 9 16:34:16 EST 2016 : 0-HE : onChange : "humidity"=91 Tue Feb 9 16:34:16 EST 2016 : 0-BQ : onChange : "humidity"=86 Tue Feb 9 16:34:16 EST 2016 : 0-HI : onChange : "temp"=66.0 Tue Feb 9 16:34:16 EST 2016 : 0-HI : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Tue Feb 9 16:34:16 EST 2016 : 0-HE : onAlert : "humidity"=91 (tooHumidAlert) Tue Feb 9 16:34:19 EST 2016 : 0-HE : onChange : "humidity"=89 Tue Feb 9 16:34:19 EST 2016 : 0-HI : onChange : "temp"=64.99 Tue Feb 9 16:34:23 EST 2016 : 0-BQ : onChange : "humidity"=81 Tue Feb 9 16:34:26 EST 2016 : 0-HE : onChange : "humidity"=86 Tue Feb 9 16:34:26 EST 2016 : 0-BQ : onChange : "humidity"=76 Tue Feb 9 16:34:26 EST 2016 : 0-HI : onChange : "temp"=62.25 Tue Feb 9 16:34:29 EST 2016 : 0-HE : onChange : "humidity"=81 Tue Feb 9 16:34:29 EST 2016 : 0-HI : onChange : "temp"=58.5
- Run this command to set the maximum humidity threshold of the
DirectlyConnectedDeviceSample
device:java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration2_ID-provisioning-file.conf Password123 0-BQ 67
This message appears:Tue Feb 9 18:24:56 EST 2016 : 0-BQ : Set : "maxThreshold"=67 .. ... [Humidity readings] ... Done.
Output similar to the following appears on the device console:Tue Feb 9 18:25:00 EST 2016 : 0-BQ : Set : "humidity"=73 Tue Feb 9 18:25:00 EST 2016 : 0-BQ : onChange : "maxThreshold"=67 Tue Feb 9 18:25:05 EST 2016 : 0-BQ : Set : "humidity"=57 Tue Feb 9 18:25:10 EST 2016 : 0-BQ : Set : "humidity"=60 Tue Feb 9 18:25:15 EST 2016 : 0-BQ : Set : "humidity"=64 Tue Feb 9 18:25:20 EST 2016 : 0-BQ : Set : "humidity"=67 Tue Feb 9 18:25:20 EST 2016 : 0-BQ : Alert : "humidity"=67 (tooHumidAlert) Tue Feb 9 18:25:25 EST 2016 : 0-BQ : Set : "humidity"=68 Tue Feb 9 18:25:30 EST 2016 : 0-BQ : Set : "humidity"=67
- Run this command to reset the
EnterpriseClientSample
device temperature sensor:java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration2_ID-provisioning-file.conf Password123 0-HA reset
Output similar to the following appears on the device console:... Tue Feb 9 18:18:06 EST 2016 : 0-HA : Call : reset Tue Feb 9 18:18:10 EST 2016 : 0-HA : Set : "temp"=58.5,"minTemp"=58.5,"maxTemp" ...
- Run this command to turn the
EnterpriseClientSample
device power on or off:java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration2_ID-provisioning-file.conf Password1230-HA off (or on to turn on sensor, in this case it is the temperature sensor)
Temperature data stops displaying on the device console:... Tue Feb 9 18:21:38 EST 2016 : 0-HA : Call : "power"=false ...
- Run this command to set the maximum and minimum threshold values for the
EnterpriseClientSample
device:java -cp $CL_HOME/samples/build/libs/iotcs-csl-samples.jar:$CL_HOME/lib/enterprise-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.EnterpriseClientSample app_integration2_ID-provisioning-file.conf Password123 0-HA 65 -10
Output similar to the following appears on the device console:... Tue Feb 9 18:28:15 EST 2016 : 0-HA : Alert : "temp"=66.0,"unit"=°C,"maxThreshold"=65 Tue Feb 9 18:28:15 EST 2016 : 0-HA : onChange : "minThreshold"=-10,"maxThreshold"=65 ...
Output similar to the following appears on theEnterpriseClientSample
console:Tue Feb 9 18:28:14 EST 2016 : 0-HA : Set : "maxThreshold"=65,"minThreshold"=-10 .. Tue Feb 9 18:28:14 EST 2016 : 0-HA : onChange : "startTime"=Tue Feb 9 18:27:55 EST 2015,"maxTemp"=64.99,"unit"=°C,"minThreshold"=0,"maxThreshold"=65,"temp"=64.99,"minTemp"=58.49 Tue Feb 9 18:28:14 EST 2016 : 0-HA : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Tue Feb 9 18:28:14 EST 2016 : 0-HA : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Tue Feb 9 18:28:14 EST 2016 : 0-HA : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Tue Feb 9 18:28:14 EST 2016 : 0-HA : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Tue Feb 9 18:28:14 EST 2016 : 0-HA : onAlert : "temp"=66.0,"unit"=°C,"maxThreshold"=65.0 (tooHotAlert) Done.
- Run this command to start the
advanced/.../DirectlyConnectedDeviceSample
application:java -cp $CL_HOME/samples/advanced/build/libs/iotcs-samples-advanced.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 0-BQ Tue Feb 9 18:34:44 EST 2015 : 0-BQ : Set : "humidity"=81,"maxThreshold"=90 Press enter to exit. Tue Feb 9 18:34:44 EST 2015 : 0-BQ : Set : "humidity"=86 Tue Feb 9 18:34:49 EST 2015 : 0-BQ : Set : "humidity"=89 Tue Feb 9 18:34:54 EST 2015 : 0-BQ : Set : "humidity"=91 Tue Feb 9 18:34:54 EST 2015 : 0-BQ : Alert : "humidity"=91 (tooHumidAlert) Tue Feb 9 18:34:59 EST 2015 : 0-BQ : Set : "humidity"=89 Tue Feb 9 18:35:04 EST 2015 : 0-BQ : Set : "humidity"=86
- Run this command to start the
advanced/.../GatewayDeviceSample
application:java -cp $CL_HOME/samples/advanced/build/libs/iotcs-samples-advanced.jar$CL_HOME/lib/device-library.jar:$CL_HOME/lib/ json-20200518.jar com.oracle.iot.sample.GatewayDeviceSample MY-GW-SAMPLE-provisioning-file.conf Password123
Output similar to the following appears:Creating the gateway instance... Created virtural temperature sensor 0-HY Created virtural humidity sensor 0-H4 Press enter to exit. Tue Feb 9 18:32:34 EST 2015 : 0-H4 : Set : "humidity"=81 Tue Feb 9 18:32:33 EST 2015 : 0-HY : Set : "power"=true,"temp"=58.5,"unit"=°C,"minTemp"=58.5,"maxTemp"=58.5,"minThreshold"=0,"maxThreshold"=65 Tue Feb 9 18:32:39 EST 2015 : 0-H4 : Set : "humidity"=86 Tue Feb 9 18:32:39 EST 2015 : 0-HY : Set : "temp"=62.25,"maxTemp"=62.25 Tue Feb 9 18:32:44 EST 2015 : 0-H4 : Set : "humidity"=89 Tue Feb 9 18:32:44 EST 2015 : 0-HY : Set : "temp"=64.99,"maxTemp"=64.99
- Run the following command to start the
advanced/.../GatewayDeviceSample
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.GatewayDeviceSample MY-GW-SAMPLE- provisioning-file.conf Password123 0-HY 0-H4
Output similar to the following appears:Creating the gateway instance... Created virtural temperature sensor 0-HY Created virtural humidity sensor 0-H4 Press enter to exit. Tue Feb 9 18:32:34 EST 2015 : 0-H4 : Set : "humidity"=81 Tue Feb 9 18:32:33 EST 2015 : 0-HY : Set : "power"=true,"temp"=58.5,"unit"=°C,"minTemp"=58.5,"maxTemp"=58.5,"minThreshold"=0,"maxThreshold"=65 Tue Feb 9 18:32:39 EST 2015 : 0-H4 : Set : "humidity"=86 Tue Feb 9 18:32:39 EST 2015 : 0-HY : Set : "temp"=62.25,"maxTemp"=62.25 Tue Feb 9 18:32:44 EST 2015 : 0-H4 : Set : "humidity"=89 Tue Feb 9 18:32:44 EST 2015 : 0-HY : Set : "temp"=64.99,"maxTemp"=64.99