After your devices and servers are connected to Alibaba Cloud IoT Platform, they can communicate with each other through IoT Platform.

The following figure shows the communication process between devices, servers, and IoT Platform.

iot

Devices send data to IoT Platform

After devices are connected to IoT Platform, they can communicate with the IoT Platform. The devices can send data to IoT Platform in the following ways:

  • Send custom formatted data to custom topics.
    1. On IoT Platform, you create custom topic categories and set Allowed Operations of the custom topics to Publish.

      You can create custom topics by using either of the following methods:

    2. Configure the devices to send messages to custom topics when you develop the device SDK.

      You must configure the custom topics and message format for sending messages on the device SDK. For an example about Link Kit SDK configuration that is provided by Alibaba Cloud, see the "The server receives messages from the device" section of Use custom topics for communication.

  • Send standard TSL data to topics related to TSL features.

    For more information about the features of TSL, see What is TSL.

    Devices can report properties and events.

    Implementation process:

    1. In the IoT Platform console, develop a custom TSL based on your business requirements. For more information, see Define features.
    2. When you develop your device, configure the device to report properties and events based on the defined TSL.

      For more information about the standard data formats for properties and events reported by devices, see Devices report properties and Devices report events.

      Note IoT Platform provides predefined topics related to TSL features. You can directly use these topics.

      For an example about Link Kit SDK development that is provided by Alibaba Cloud, see Report properties and events by using the device SDK.

IoT Platform forwards data to your servers

You can set IoT Platform to send messages such as device reports, changes in device status, changes in device lifecycles, TSL historical data, firmware update status, and changes in device topological relationships to your servers. You can use either of the following methods to forward data to your servers:

  • Service subscription: You can use the service subscription feature provided by IoT Platform to subscribe to one or more message types. IoT Platform can forward messages of the specified types to your server based on your subscription settings. The following two methods can be used for your server to receive messages:
    • Configure to use the AMQP SDK to receive device messages forwarded by IoT Platform. For more information, see AMQP service subscription and related topics
    • Configure to use the Message Service (MNS) SDK to receive device messages forwarded by IoT Platform in MNS queues. For more information, see MNS service subscription.
  • Data forwarding: You can use the rules engine to forward specified device data to MNS topics based on data forwarding rules. The server receives messages by using the MNS SDK.
    1. Create a rule, and configure to forward data to a MNS topic. For more information, see Configure data forwarding rules.
    2. Use MNS SDK to receive messages.

      For more information, see the message subscription section of User guide for MNS topics.

For the differences between data forwarding and service subscription, see Compare data forwarding solutions.

Servers control remote devices

Servers uses the cloud SDKs provided by IoT Platform to call the cloud APIs and send commands to devices and control the remote devices. Servers can send commands to devices in the following ways:

  • Servers send commands to custom topics and devices subscribe to these topics for receiving commands.
    • Asynchronous control: Call the Pub operation to send custom messages to custom topics.
      Note You cannot use the Pub operation to send TSL related commands.

      For more information about how to use custom topics to control remote devices, seeUse custom topics for communication.

    • Synchronous control: Call the RRpc operation to send messages to specified devices and the device returns a synchronous response.

      For more information about MQTT synchronous communication, see What is RRPC?.

      For an example about calling the RRPC operation for synchronous communication, see Control Raspberry Pi servers from IoT Platform.

    • Batch control: Call the PubBroadcast operation to publish messages to all the devices that have subscribed to the specified topic to control devices in batches.

      For more information, see Broadcast messages.

  • Use TSL to control remote devices

    You can publish property values and call services in the cloud by using the TSL-specific API.

    • Control a single device.
      • Call the SetDeviceProperty operation to send a command for configuring property values to a device.

        The device receives and runs the command asynchronously.

      • Call the InvokeThingService operation to send a service call command to a single device.

        Whether a service is called synchronously or asynchronously depends on the call method specified for your Self-defined Feature.

        If the service is defined as a Synchronous service, and the device has been developed to respond to commands synchronously, the results are returned synchronously after InvokeThingService is called.

        If the service is defined as an Asynchronous service, the results are returned asynchronously after InvokeThingService is called. The device response can be obtained using the rules engine. Set the data source of the SQL query for the rule to TSL Data Reporting and set the specific topic to thing/downlink/reply/message. For more information about configuring data forwarding rules, see Configure data forwarding rules.

    • Control devices in batches.
      • Call the SetDevicesProperty operation to send commands for property configurations to multiple devices.
      • Call the InvokeThingsService operation to send commands for service calling to multiple devices.

    For more information about how to use TSL to control remote devices, see TSL model communication.

Communication between devices

Connect devices at both ends to IoT Platform. IoT Platform is responsible for the connection and communication requests between the devices. You can use either of the following methods:

Usage of device data

Integrate with a weather service

Upload temperature and humidity data to DingTalk chatbots