Generating a Connection Configuration File for a C Application
Before you run your C application, you must generate the configuration files that contain the information required to connect your application to your organization in Device Cloud.
The instructions in this section are for Linux distributions. For information about creating the file for VxWorks 7, see Device Cloud Quick Start for VxWorks 7.
You use the iot-control script to generate the base connection configuration file, iot-connect.cfg. It contains the Device Cloud endpoint, port, an application token, optional proxy settings. Specify the application token of the device manager application in this file.
Each application requires a connection configuration file with the name app_id.cfg, where app_id is the value you specified for the id parameter in your application initialization code. The file contains only the associated application token, which overrides the value in the iot-connect.cfg file. For more information, see Initializing Your C Application.
If the /etc/iot directory already contains the iot-connect.cfg file when you run iot-control, it is overwritten.
If you already generated the /etc/iot/iot-connect.cfg with the base connection information, go to step 9.
You need the following:
-
the application identifier you specified in your application initialization code
-
your user name, password, and URL for Device Cloud
-
the corresponding application defined in Device Cloud
-
the C agent built on your device
-
if you connect through a proxy server, proxy configuration information
-
super user privileges on the device
When you run the device manager, it connects to Device Cloud based on the settings in the iot-connect.cfg file.
When you run your application, it connects to Device Cloud based on the settings in the iot-connect.cfg file and the token in the application-specific connection file.
The first time any application runs, the device_id file is created in the /var/lib/iot directory and is used as a prefix for the thing key. On the Management Portal, you can search for the prefix to find the applications that run on your device.