Device Cloud Client Applications

To transmit and receive information between the device and Device Cloud, you need to write a client application using the agent APIs to run on the device.

Agent APIs are provided in Python and C.

Configuration

Each client application requires a configuration file to specify the information required to connect to Device Cloud. The configuration file must specify the application token of the application created in Device Cloud and the Device Cloud endpoint, which is available on the Developer page of the Management Portal. If the application connects to Device Cloud through a proxy server, the configuration file must also specify proxy configuration information.

The Python agent provides a script to generate the configuration file, and you must specify the configuration file name. At initialization time, client applications specify the file name to use and the file location.

The C agent running on Linux searches the /etc/iot directory for configuration files. The C agent running on VxWorks 7 searches the directory specified in the DEVICE_CLOUD_CONFIG_DIR parameter, for example, /bd0:1/etc/iot/. The configuration file name must be id.cfg, where id is the value specified for the application name at initialization time.

For more information about initialization, see the following:

Thing Key

Each application on the device requires a unique thing key. When you run your application, the agent searches the run-time directory for the device_id file. The identifier in the file is used as a prefix to the application identifier (app_id) you specify when you initialize your application and the combination of the identifiers is used as the thing key. If the device_id file does not exist, the agent generates an alphanumeric string, saves it in the file, and stores the file in the configuration directory.

If applications on the device use the same configuration file directory, all applications have the same device identifier, which you can use to search the list of things on the Management Portal to find applications on the same device.

If you want to specify your own prefix, you can create the device_id file and specify the value you want. However, you must ensure that when the value is combined with the application identifier that it creates a unique thing key in your organization. If you want to manually create the thing in Device Cloud to enable your application to manually register, you must ensure that the thing key you specify follows the convention device_id-app_id, where device_id is the value in the device_id file and app_id is the value you specify in your device application initialization code.

For example, in the following thing key, 85356677-f8c9-5489-9578-277904aff540 is the device identifier in the file and app_1 is the application identifier:

85356677-f8c9-5489-9578-277904aff540-app_1

Note:

If you do not wish to append the app_id to the device_id, you can specify the value as None. In this case, only one application can use the device_id key.

Application Role

Each Device Cloud application is assigned a role. The Device role is available when your organization is created and has the permissions required for applications that use the agent API. You can copy and modify it as needed. The application should not have the organization administrator role.

For more information about roles, see Device Cloud Management Portal User's Guide: Roles and Permissions.