Alibaba Cloud IoT Platform provides device SDKs that allow devices to connect to IoT Platform. This article uses a sample program provided by IoT Platform to introduce how to connect the device to IoT Platform using the provided SDK.
- The SDK used in this example is a C SDK for Linux system. We recommend that you develop this SDK on Ubuntu16.04 (64-bit)
- Software used in the development of the SDK:
mingw-5.3.1Using the following command to install the software:
apt-get install -y build-essential make git gcc
- Log on to your Linux VM instance.
- Download the C SDK 2.3.0.
wget https://github.com/aliyun/iotkit-embedded/archive/v2.3.0.zip?spm=a2c4g. 111866126.96.36.199f41492b5WHpzV&file=v2.3.0.zip
- Use the unzip command to extract files from the package.
- Open the demo program
- Change the values of ProductKey, DeviceName, and DeviceSecret in the demo to be your device certificate information, and then save the file.
See the following example:
// for demo only #define PRODUCT_KEY "a1I1n******" #define DEVICE_NAME "Light00" #define DEVICE_SECRET "n27gKXTxrUx*********QZEmoUX8TceM"
- In the top level directory, use make command to compile the sample program.
$ make distclean $ make
- Run the sample program to connect the device to IoT Platform. In the IoT Platform console, you see that the device status is online, indicating that the device has been connected to IoT Platform successfully.
Once the device has been connected to IoT Platform, it automatically report messages to IoT Platform. You see the device logs for message contents.