IoTDA uses codecs to convert data between the binary and JSON formats as well as between JSON formats.
For example, in the NB-IoT scenario where devices use CoAP over UDP to communicate with the platform, the payload of CoAP messages carries data at the application layer, at which the data type is defined by the devices. As NB-IoT devices require low power consumption, data at the application layer is generally in binary format instead of JSON. However, the platform sends data in JSON format to applications. Therefore, codec development is required for the platform to convert data between binary and JSON formats.
In the data reporting process, the codec is used in the following scenarios:
- Decoding binary data reported by a device into JSON data and sending the decoded data to an application
- Encoding JSON data returned by an application into binary data and sending the encoded data to a device
In the command delivery process, the codec is used in the following scenarios:
- Encoding JSON data delivered by an application into binary data and sending the encoded data to a device
- Decoding binary data returned by a device into JSON data and reporting the decoded data to an application
The platform provides multiple methods for developing codecs. You can select a method as required. Offline codec development is complex and time-consuming. Graphical codec development and script-based codec development are recommended.
- Graphical development: The codec of a product can be quickly developed in a visualized manner on the IoTDA console. For details, see Online Development.
- Offline Development: A codec is developed through secondary development based on the Java codec demo to implement encoding, decoding, packaging, and quality inspection. For details, see Offline Development.
- FunctionGraph development: FunctionGraph is used to implement encoding and decoding. For details, see "FunctionGraph Development".