ClickYesin theRename Popupto confirm the file extension change.
Openconfig.jsonin your preferred text editor. NOTE: You will need a text editor of some type to modify the config.json file.Notepad++is one such editor. However, the default Windows text editor, Notepad, is sufficient.
Copy and Pastethe following code into the empty config.json file:
When the EMS runs, the config.json file will answer the following questions:
At what IP address / port is the ThingWorx Server located?
What is your Application Key?
Where, and at what level, should we log errors?
What port should the WSEMS use to setup an HTTP server?
Should we use encryption?
Are we using Security Certificates?
What are the configuration parameters for remote-tunneling?
What are the configuration parameters for file-transfer?
We pre-defined the parameters for everything that we could, but you will still need to tell the WSEMS theIP addresswhere the ThingWorx instance is located and a validApplication Keyyou either created earlier or may create now.
TIP: You may have noticed the pre-existingconfig.json.completeandconfig.json.minimalfiles. These are example files that come with the WSEMS and are provided as an aid. The code above which you copied into your own config.json file is simply a customization of these aids. In particular, you may wish to look through the config.json.complete file, as it shows every available option which you might want to configure if you choose to make a custom application with the WSEMS. The config.json.complete file also contains comments for each of these options. However, a functional config.json file mayNOTcontain comments of any kind, so you would need to remove all comments if you choose to copy/paste some code from that file into a functional config.json of your own making.
Modify config.json to point to ThingWorx Foundation
ChangeYOUR_IP_ADDRESS_HEREto the IP address of your hosted ThingWorx instance.
Note that you may use a URL, such as "pp-180207xx36jd.devportal.ptc.io". Either way, the IP or URL must be enclosed in quotation marks (""). Also, Port 443 is the appropriate port for the hosted ThingWorx trial. Other Ports may be needed for local installs.
ChangeYOUR_APP_KEY_HEREto an Application Key which you have previously created.
Or create a new Application Key now... and remember to set theExpiration Datefar enough into the future.
Save and exit the file.
Create a config.lua file
Navigate to theC:\CDEMO_EMS\etcdirectory.
Right-click inside the folder’s white-space and selectNew -> Text Document.
Change the name ofNew Text Document.txttoconfig.lua .
ClickYeson whether you want to change the filename extension.
Open config.lua in your preferred text editor.
Copy and Paste the following code into the empty config.lua file:
In this step, you'll launch the EMS so that it can communicate with your ThingWorx Foundation platform.
Navigate to theC:\CDEMO_EMSdirectory.
HoldShiftandright-clickin thewhite spaceof the folder to open an options menu.
ClickOpen PowerShell window here.
Note that this guide assumes Windows 10, but older versions of Windows have similar command-line interfaces.
In the PowerShell window, enter the command.\wsems.exeand press theEnterkey. Note: Do not close this window, or the connection to the ThingWorx platform will close. Also, please look through the output in the wsems.exe window. The final line should indicateSuccessfully connected. Saving .booted config file. If you do not see theSaving .bootedcomment, then you likely have an error in your config.json file. Close the wsems.exe application with a Ctrl+C and delete any .booted file before making further changes.
Open another PowerShell windowas per the above instructions.
In the second PowerShell window, enter the command.\luaScriptResource.exeand press theEnterkey.
Note: Do not close this second PowerShell window, or the connection to the ThingWorx platform will close.
NOTE: When the scripts start running, the WSEMS attempts to talk to the ThingWorx platform. However, at this point in the tutorial, ThingWorx does not have detailed information about the Edge device that is attempting to connect to it so you will see an error message. This is the expected behavior which we will resolve in the next step.
The wsems.exe program runs through the config.json file in order to extract the basic connectivity information to reach the ThingWorx platform. The luaScriptResource.exe runs through the config.lua file to extract to which Thing the WSEMS should be connecting. Both .exes must be running in order to achieve connectivity with ThingWorx.
Extracts basic connectivity information to reach the ThingWorx platform.
Determines to which Thing the WSEMS should connect.
NOTE: Since the luaScriptResource.exe file which we created above has a reference to a custom template, it goes also accesses the YourEdgeThingTemplate.lua file to extend the base functionality. Both .exes must be running in order to achieve connectivity with ThingWorx.