Some devices, such as those that are resource-constrained or have network bandwidth limitations, need to send raw data to IoT Platform using passthrough. In this case, you must write a data parsing script in the IoT Platform console. This script converts uplink data from your device's custom format to Alink JSON, the standard format used by IoT Platform. It also converts downlink data from Alink JSON back to the device's custom format.
Starting March 16, 2020, you must define the protocolToRawData, rawDataToProtocol, and transformPayload methods in your data parsing script.
If you have not edited the script, the console automatically generates a script that includes these methods when you open the page.
If you have edited the script, you must add these methods to your script. For more information, see Usage examples of TSL data parsing.
Data parsing process
When IoT Platform receives data from a device, it first runs the parsing script to convert the passthrough data into Alink JSON. The platform then processes the data. Similarly, before sending data to a device, IoT Platform runs the script to convert data from Alink JSON back into the device's custom format.
Figure 1. Data parsing process
Figure 2. End-to-end process for passthrough uplink data (properties or events)
Figure 3. End-to-end process for downlink data (calling device services or setting properties)
Edit scripts
IoT Platform provides an online script editor to edit and submit scripts, and simulate data parsing. The supported scripting languages are JavaScript (ECMAScript 5), Python 2.7, and PHP. For more information, see Usage examples of TSL data parsing, JavaScript script examples, Python script examples, and PHP script examples.