This topic describes how to connect a street lamp device to IoT Platform and how to control the switch of the device. This helps you understand the basic capabilities of IoT Platform. After you connect the device to IoT Platform, the device can submit messages to IoT Platform and subscribe to messages from IoT Platform and IoT Platform can send commands to the device.
Before you begin
Before you connect a device to IoT Platform, you must perform the following operations:
- IoT Platform is activated.
- A development environment for the C programming language is prepared. In this topic, the device is developed on the Linux operating system by using Link SDK for C.
- A Java development environment is prepared. In this topic, the online debugging feature
of IoT Platform is used to send downstream commands. AMQP SDK for Java is used to
receive device messages.
The numbers in the preceding figure correspond to the following steps:
- Submit device data to IoT Platform.
- Create a product and add a device: Register your device in IoT Platform and obtain the device certificate information, including ProductKey, DeviceName, and DeviceSecret. Burn the device certificate to the device. When the device connects to IoT Platform, the certificate is used for authentication.
- Define a TSL model for a product: Define product features, including properties, services, and events. IoT Platform generates a Thing Specification Language (TSL) model based on the defined product features. The TSL model is used for the communication between the device and IoT Platform.
- Connect a device to IoT Platform: Develop the device SDK and pass in the device certificate to connect the device to IoT Platform. The device is activated.
- Subscribe to device messages from IoT Platform: Configure a server-side subscription to receive device messages, including online or offline notifications, device lifecycle changes, and upstream device messages.
- Send commands from IoT Platform to devices: Use the online debugging feature of IoT Platform to send commands to the device.