You can directly compile and run the demo in the device SDK for C on a Linux device
to connect to IoT Platform by using Message Queuing Telemetry Transport (MQTT). This
article describes how to configure and connect a Linux device to IoT Platform. In
the following example, the demo in the device SDK for C is compiled on a device that
runs the Ubuntu x86_64 operating system.
Background information
For more information about the device SDK for C, see Overview.
Create a product and a device
- Log on to the IoT Platform console.
- In the left-side navigation pane, choose . On the Products page, click Create Product to create a product.
Parameter |
Description |
Product Name |
The name of the product. |
Node Type |
Select Directly Connected Device.
|
Network Connection Method |
Select Wi-Fi.
|
Data Type |
Select ICA Standard Data Format (Alink JSON).
|
Authorization Mode |
Select Device Secret.
|
- In the left-side navigation pane, choose Devices > Devices. On the Devices page, click Add Device to add a device to the product.
After the device is added, obtain the certificate information of the device. The certificate
information includes the ProductKey, DeviceName, and DeviceSecret.
Create a TSL model
In the package of the device SDK for C provided by IoT Platform, you can obtain a
JSON file that contains a complete sample Thing Specification Language (TSL) model.
In the following example, the JSON file is imported to apply the TSL model to the
product.
- Edit the JSON file.
- Download the package of the device SDK for C.
- Decompress the package and open the model_for_examples.json file in the src/dev_model/examples directory.
- Specify the value of the ProductKey that you obtain from IoT Platform for the productKey parameter in the JSON file. Then, save the file.
- Log on to the IoT Platform console. On the Products page, find the product that you created earlier and click View in the Actions column.
- On the Define Feature tab of the Product Details page, click and then Import.
- In the Import TSL dialog box, click the Import TSL tab, upload the JSON file that you edited in the preceding step, and then click OK.
After the file is imported, all features that are defined in the JSON file appear
on the Edit Draft page.
- Click Release online to publish the TSL model.
Configure the SDK demo
Copy the package of the device SDK for C to the Linux device. Decompress the package
and modify the device information in a configuration file.
- In the wrappers/os/ubuntu directory, specify the certificate information of your device in the HAL_OS_linux.c file.
- Compile the SDK demo. In the root directory of the SDK, run the make reconfig command, enter 3, and then run the make command.
- Run the SDK demo.
In the root directory of the SDK, run the
./output/release/bin/linkkit-example-solo command. The following figure shows the result.

After the SDK demo is run, log on to the IoT Platform console. On the Device Details page, view the device status and the TSL data reported by the device.