Using the Demo Applications > Edge Device Demo Client
Edge Device Demo Client
This section explains how to create a new AzureIotThing for this demo and then start the Edge Device Demo client. This demo application is located in the demo/edge-device-demo subdirectory of the Connector installation.
Before You Begin
In addition to the general prerequisites, you need to import the entities file for the demo.
* 
You must either be an administrator or a user with the appropriate permissions to import a file into ThingWorx Platform. For more information on importing files into ThingWorx Platform, refer to Importing and Exporting Data, Entities, and Extensions.
1. Log in to ThingWorx Composer.
2. From the Import/Export menu of Composer, select Import, as shown here:
3. In the Import window, make sure that the following options are selected:
a. Import Option > From File
b. Import Type > Entity\\
c. Import Source > Single File
4. To select the entities file for the demo, click Browse, and navigate to the location of the file for the demo. For the Edge Device Demo, the file is located in the demo\edge-device-demo\platform\entities directory (Windows).
5. Select the file, CPUDemo_AllEntities.xml, and click Open.
The window shows your selections. In the example below, under File Name, "entities XML file name" indicates where the file name CPUDemo_AllEntities.xml appears.
6. Click the Import button.
7. As long as the ThingWorx Platform returns a message, indicating that the import was successful, click Close.
One of the entities imported with this file is the Thing Template, called azureDemo1 ThingTemplate. You will use this Thing Template when creating an AzureIotThing for the demo.
Additional files that support the demo client on the ThingWorx Platform are in the demo/edge-device-demo/platform/extensions subdirectory of the installation. In the same way that you imported the Azure IoT Extension, import the GoogleWidgets_Extension.zip into the platform For assistance with importing, refer to Step 3. Import the Extensions.
Create a new AzureIotThing and Start the Client
The demo client is contained in the demo/edge-device-demo/edge subdirectory of the Azure IoT Hub Connector installation.
1. Log in to ThingWorx Composer.
2. Create a new AzureIotThing Thing, and select the azureDemo1 Thing Template as its Base Template. This Thing Template is based on the AzureIotThing Thing Template, which was imported when you imported the Azure IoT Extension. However, this derivative of that template has properties that are useful for the demonstration edge client. The demo also includes a mashup.
3. In the gatewayThing property field of this Thing, enter the name of your AzureIotHub Thing.
4. Create the device in Azure in one of the following ways:
Use the Azure IoT Hub portal.
Navigate to the ConnectionServicesHub Thing in ThingWorx and run the CreateAzureIotDevice service.
5. From the demo/edge-device-demo/conf subdirectory, open the edge-device.conf file with a text editor.
6. Edit the deviceId to be the name of the Thing that was created in step 3.
7. From the Azure IoT Hub portal, select Overview > Hostname, and copy the value from your Azure IoT Hub and paste it as the iotHubHostName value in the edge-device.conf file.
8. Edit the registryPolicyKey property to use the Primary Key that is related to the registryReadWrite policy in the Azure IoT Hub user interface.
9. Save the file.
10. From a shell or Command Prompt, set the EDGE_DEVICE_DEMO_OPTS environment variable to refer to the file you just edited:
Linux (bash/ksh):
export EDGE_DEVICE_DEMO_OPTS="-Dconfig.file=../conf/edge-device.conf"
Windows:
set EDGE_DEVICE_DEMO_OPTS=-Dconfig.file=../conf/edge-device.conf
11. Launch the demo from the demo/edge-device-demo/bin subdirectory, using the edge-device-demo command.
12. Return to the ThingWorx Composer and open the Properties page of the Azure IoT Thing that you created in step 3. Note that the properties change every five seconds or so.
13. Open the azure-iot-demo mashup and view the Load Average and CPU gauges, as well as increases in the values of the Cycle and Uptime fields. If the edge-device-demo is running on Windows, the Load Average does not register.
14. Click the Reset button to send a message to the Azure IoT Thing. The cycle and uptime reset back to their initial values. If you observe the edge-device-demo console, you may be able to spot the reset message being received at the edge, as shown here:
Reset message shown on the console
15. If desired, you can create more Things and assign the azureDemo1 Thing Template to them. To start them, pass the name of each Thing on the command line, as shown in the following example:
edge-device-demo MyThingX